]> Pileus Git - ~andy/linux/blobdiff - net/ipv4/tcp_input.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm
[~andy/linux] / net / ipv4 / tcp_input.c
index 6333893907880bdb406198a16135fa18cec5d716..7641b2761a14869b1dfd9413b3d5be63a3610f2c 100644 (file)
@@ -1265,20 +1265,15 @@ tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, u32 prior_snd_
        return flag;
 }
 
-/* F-RTO can only be used if these conditions are satisfied:
- *  - there must be some unsent new data
- *  - the advertised window should allow sending it
- *  - TCP has never retransmitted anything other than head (SACK enhanced
- *    variant from Appendix B of RFC4138 is more robust here)
+/* F-RTO can only be used if TCP has never retransmitted anything other than
+ * head (SACK enhanced variant from Appendix B of RFC4138 is more robust here)
  */
 int tcp_use_frto(struct sock *sk)
 {
        const struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *skb;
 
-       if (!sysctl_tcp_frto || !tcp_send_head(sk) ||
-               after(TCP_SKB_CB(tcp_send_head(sk))->end_seq,
-                     tp->snd_una + tp->snd_wnd))
+       if (!sysctl_tcp_frto)
                return 0;
 
        if (IsSackFrto())
@@ -2402,14 +2397,6 @@ static int tcp_tso_acked(struct sock *sk, struct sk_buff *skb,
        return acked;
 }
 
-static u32 tcp_usrtt(struct timeval *tv)
-{
-       struct timeval now;
-
-       do_gettimeofday(&now);
-       return (now.tv_sec - tv->tv_sec) * 1000000 + (now.tv_usec - tv->tv_usec);
-}
-
 /* Remove acknowledged frames from the retransmission queue. */
 static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
 {
@@ -2420,9 +2407,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
        int acked = 0;
        __s32 seq_rtt = -1;
        u32 pkts_acked = 0;
-       void (*rtt_sample)(struct sock *sk, u32 usrtt)
-               = icsk->icsk_ca_ops->rtt_sample;
-       struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
+       ktime_t last_ackt = ktime_set(0,0);
 
        while ((skb = tcp_write_queue_head(sk)) &&
               skb != tcp_send_head(sk)) {
@@ -2471,7 +2456,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
                                seq_rtt = -1;
                        } else if (seq_rtt < 0) {
                                seq_rtt = now - scb->when;
-                               skb_get_timestamp(skb, &tv);
+                               last_ackt = skb->tstamp;
                        }
                        if (sacked & TCPCB_SACKED_ACKED)
                                tp->sacked_out -= tcp_skb_pcount(skb);
@@ -2484,7 +2469,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
                        }
                } else if (seq_rtt < 0) {
                        seq_rtt = now - scb->when;
-                       skb_get_timestamp(skb, &tv);
+                       last_ackt = skb->tstamp;
                }
                tcp_dec_pcount_approx(&tp->fackets_out, skb);
                tcp_packets_out_dec(tp, skb);
@@ -2494,13 +2479,14 @@ static int tcp_clean_rtx_queue(struct sock *sk, __s32 *seq_rtt_p)
        }
 
        if (acked&FLAG_ACKED) {
+               const struct tcp_congestion_ops *ca_ops
+                       = inet_csk(sk)->icsk_ca_ops;
+
                tcp_ack_update_rtt(sk, acked, seq_rtt);
                tcp_ack_packets_out(sk);
-               if (rtt_sample && !(acked & FLAG_RETRANS_DATA_ACKED))
-                       (*rtt_sample)(sk, tcp_usrtt(&tv));
 
-               if (icsk->icsk_ca_ops->pkts_acked)
-                       icsk->icsk_ca_ops->pkts_acked(sk, pkts_acked);
+               if (ca_ops->pkts_acked)
+                       ca_ops->pkts_acked(sk, pkts_acked, last_ackt);
        }
 
 #if FASTRETRANS_DEBUG > 0
@@ -2651,7 +2637,9 @@ static void tcp_undo_spur_to_response(struct sock *sk, int flag)
  *                  algorithm is not part of the F-RTO detection algorithm
  *                  given in RFC4138 but can be selected separately).
  * Otherwise (basically on duplicate ACK), RTO was (likely) caused by a loss
- * and TCP falls back to conventional RTO recovery.
+ * and TCP falls back to conventional RTO recovery. F-RTO allows overriding
+ * of Nagle, this is done using frto_counter states 2 and 3, when a new data
+ * segment of any size sent during F-RTO, state 2 is upgraded to 3.
  *
  * Rationale: if the RTO was spurious, new ACKs should arrive from the
  * original window even after we transmit two new data segments.
@@ -2680,7 +2668,7 @@ static int tcp_process_frto(struct sock *sk, u32 prior_snd_una, int flag)
                inet_csk(sk)->icsk_retransmits = 0;
 
        if (!before(tp->snd_una, tp->frto_highmark)) {
-               tcp_enter_frto_loss(sk, tp->frto_counter + 1, flag);
+               tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 2 : 3), flag);
                return 1;
        }
 
@@ -2706,7 +2694,7 @@ static int tcp_process_frto(struct sock *sk, u32 prior_snd_una, int flag)
                        return 1;
                }
 
-               if ((tp->frto_counter == 2) &&
+               if ((tp->frto_counter >= 2) &&
                    (!(flag&FLAG_FORWARD_PROGRESS) ||
                     ((flag&FLAG_DATA_SACKED) && !(flag&FLAG_ONLY_ORIG_SACKED)))) {
                        /* RFC4138 shortcoming (see comment above) */
@@ -2719,10 +2707,19 @@ static int tcp_process_frto(struct sock *sk, u32 prior_snd_una, int flag)
        }
 
        if (tp->frto_counter == 1) {
+               /* Sending of the next skb must be allowed or no FRTO */
+               if (!tcp_send_head(sk) ||
+                   after(TCP_SKB_CB(tcp_send_head(sk))->end_seq,
+                                    tp->snd_una + tp->snd_wnd)) {
+                       tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 2 : 3),
+                                           flag);
+                       return 1;
+               }
+
                tp->snd_cwnd = tcp_packets_in_flight(tp) + 2;
                tp->frto_counter = 2;
                return 1;
-       } else /* frto_counter == 2 */ {
+       } else {
                switch (sysctl_tcp_frto_response) {
                case 2:
                        tcp_undo_spur_to_response(sk, flag);