]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/tcp_output.c
tcp: remove tp->lost_out guard to make joining diff nicer
[linux-2.6-omap-h63xx.git] / net / ipv4 / tcp_output.c
index 8165f5aa8c71b68f5d01dee2abb8dad5c7449c44..9f44be633ef645ac47dd72e1cf8abf61fd91ace9 100644 (file)
@@ -750,7 +750,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
 
        BUG_ON(len > skb->len);
 
-       tcp_clear_retrans_hints_partial(tp);
+       tcp_clear_all_retrans_hints(tp);
        nsize = skb_headlen(skb) - len;
        if (nsize < 0)
                nsize = 0;
@@ -1823,7 +1823,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb,
        tp->packets_out -= tcp_skb_pcount(next_skb);
 
        /* changed transmit queue under us so clear hints */
-       tcp_clear_retrans_hints_partial(tp);
+       tcp_clear_all_retrans_hints(tp);
 
        sk_wmem_free_skb(sk, next_skb);
 }
@@ -1838,7 +1838,7 @@ void tcp_simple_retransmit(struct sock *sk)
        struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *skb;
        unsigned int mss = tcp_current_mss(sk, 0);
-       int lost = 0;
+       u32 prior_lost = tp->lost_out;
 
        tcp_for_write_queue(skb, sk) {
                if (skb == tcp_send_head(sk))
@@ -1849,17 +1849,13 @@ void tcp_simple_retransmit(struct sock *sk)
                                TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
                                tp->retrans_out -= tcp_skb_pcount(skb);
                        }
-                       if (!(TCP_SKB_CB(skb)->sacked & TCPCB_LOST)) {
-                               TCP_SKB_CB(skb)->sacked |= TCPCB_LOST;
-                               tp->lost_out += tcp_skb_pcount(skb);
-                               lost = 1;
-                       }
+                       tcp_skb_mark_lost_uncond_verify(tp, skb);
                }
        }
 
        tcp_clear_all_retrans_hints(tp);
 
-       if (!lost)
+       if (prior_lost == tp->lost_out)
                return;
 
        if (tcp_is_reno(tp))
@@ -1996,6 +1992,33 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
        return err;
 }
 
+static int tcp_can_forward_retransmit(struct sock *sk)
+{
+       const struct inet_connection_sock *icsk = inet_csk(sk);
+       struct tcp_sock *tp = tcp_sk(sk);
+
+       /* Forward retransmissions are possible only during Recovery. */
+       if (icsk->icsk_ca_state != TCP_CA_Recovery)
+               return 0;
+
+       /* No forward retransmissions in Reno are possible. */
+       if (tcp_is_reno(tp))
+               return 0;
+
+       /* Yeah, we have to make difficult choice between forward transmission
+        * and retransmission... Both ways have their merits...
+        *
+        * For now we do not retransmit anything, while we have some new
+        * segments to send. In the other cases, follow rule 3 for
+        * NextSeg() specified in RFC3517.
+        */
+
+       if (tcp_may_send_now(sk))
+               return 0;
+
+       return 1;
+}
+
 /* This gets called after a retransmit timeout, and the initially
  * retransmitted data is acknowledged.  It tries to continue
  * resending the rest of the retransmit queue, until either
@@ -2009,87 +2032,60 @@ void tcp_xmit_retransmit_queue(struct sock *sk)
        const struct inet_connection_sock *icsk = inet_csk(sk);
        struct tcp_sock *tp = tcp_sk(sk);
        struct sk_buff *skb;
-       int packet_cnt;
+       int mib_idx;
+
+       if (!tp->lost_out)
+               tp->retransmit_high = tp->snd_una;
 
-       if (tp->retransmit_skb_hint) {
+       if (tp->retransmit_skb_hint)
                skb = tp->retransmit_skb_hint;
-               packet_cnt = tp->retransmit_cnt_hint;
-       } else {
+       else
                skb = tcp_write_queue_head(sk);
-               packet_cnt = 0;
-       }
 
        /* First pass: retransmit lost packets. */
-       if (tp->lost_out) {
-               tcp_for_write_queue_from(skb, sk) {
-                       __u8 sacked = TCP_SKB_CB(skb)->sacked;
-
-                       if (skb == tcp_send_head(sk))
-                               break;
-                       /* we could do better than to assign each time */
-                       tp->retransmit_skb_hint = skb;
-                       tp->retransmit_cnt_hint = packet_cnt;
-
-                       /* Assume this retransmit will generate
-                        * only one packet for congestion window
-                        * calculation purposes.  This works because
-                        * tcp_retransmit_skb() will chop up the
-                        * packet to be MSS sized and all the
-                        * packet counting works out.
-                        */
-                       if (tcp_packets_in_flight(tp) >= tp->snd_cwnd)
-                               return;
-
-                       if (sacked & TCPCB_LOST) {
-                               if (!(sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))) {
-                                       int mib_idx;
-
-                                       if (tcp_retransmit_skb(sk, skb)) {
-                                               tp->retransmit_skb_hint = NULL;
-                                               return;
-                                       }
-                                       if (icsk->icsk_ca_state != TCP_CA_Loss)
-                                               mib_idx = LINUX_MIB_TCPFASTRETRANS;
-                                       else
-                                               mib_idx = LINUX_MIB_TCPSLOWSTARTRETRANS;
-                                       NET_INC_STATS_BH(sock_net(sk), mib_idx);
-
-                                       if (skb == tcp_write_queue_head(sk))
-                                               inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
-                                                                         inet_csk(sk)->icsk_rto,
-                                                                         TCP_RTO_MAX);
-                               }
-
-                               packet_cnt += tcp_skb_pcount(skb);
-                               if (packet_cnt >= tp->lost_out)
-                                       break;
-                       }
-               }
-       }
-
-       /* OK, demanded retransmission is finished. */
+       tcp_for_write_queue_from(skb, sk) {
+               __u8 sacked = TCP_SKB_CB(skb)->sacked;
 
-       /* Forward retransmissions are possible only during Recovery. */
-       if (icsk->icsk_ca_state != TCP_CA_Recovery)
-               return;
+               if (skb == tcp_send_head(sk))
+                       break;
+               /* we could do better than to assign each time */
+               tp->retransmit_skb_hint = skb;
+
+               /* Assume this retransmit will generate
+                * only one packet for congestion window
+                * calculation purposes.  This works because
+                * tcp_retransmit_skb() will chop up the
+                * packet to be MSS sized and all the
+                * packet counting works out.
+                */
+               if (tcp_packets_in_flight(tp) >= tp->snd_cwnd)
+                       return;
+               if (!before(TCP_SKB_CB(skb)->seq, tp->retransmit_high))
+                       break;
+               if (sacked & (TCPCB_SACKED_ACKED|TCPCB_SACKED_RETRANS))
+                       continue;
 
-       /* No forward retransmissions in Reno are possible. */
-       if (tcp_is_reno(tp))
-               return;
+               if (!(sacked & TCPCB_LOST))
+                       continue;
 
-       /* Yeah, we have to make difficult choice between forward transmission
-        * and retransmission... Both ways have their merits...
-        *
-        * For now we do not retransmit anything, while we have some new
-        * segments to send. In the other cases, follow rule 3 for
-        * NextSeg() specified in RFC3517.
-        */
+               if (tcp_retransmit_skb(sk, skb)) {
+                       tp->retransmit_skb_hint = NULL;
+                       return;
+               }
+               if (icsk->icsk_ca_state != TCP_CA_Loss)
+                       mib_idx = LINUX_MIB_TCPFASTRETRANS;
+               else
+                       mib_idx = LINUX_MIB_TCPSLOWSTARTRETRANS;
+               NET_INC_STATS_BH(sock_net(sk), mib_idx);
 
-       if (tcp_may_send_now(sk))
-               return;
+               if (skb == tcp_write_queue_head(sk))
+                       inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS,
+                                                 inet_csk(sk)->icsk_rto,
+                                                 TCP_RTO_MAX);
+       }
 
-       /* If nothing is SACKed, highest_sack in the loop won't be valid */
-       if (!tp->sacked_out)
+       /* OK, demanded retransmission is finished. */
+       if (!tcp_can_forward_retransmit(sk))
                return;
 
        if (tp->forward_skb_hint)