]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/tcp_output.c
Merge branch 'nfs-server-stable' of git://linux-nfs.org/~bfields/linux
[linux-2.6-omap-h63xx.git] / net / ipv4 / tcp_output.c
index a61a3e3082aea7ade442b29c1918923f50290807..324b4207254ae411728dd8a3cc1740f5ac0ce267 100644 (file)
@@ -646,16 +646,32 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, unsigned
                skb_shinfo(skb)->gso_size = 0;
                skb_shinfo(skb)->gso_type = 0;
        } else {
-               unsigned int factor;
-
-               factor = skb->len + (mss_now - 1);
-               factor /= mss_now;
-               skb_shinfo(skb)->gso_segs = factor;
+               skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(skb->len, mss_now);
                skb_shinfo(skb)->gso_size = mss_now;
                skb_shinfo(skb)->gso_type = sk->sk_gso_type;
        }
 }
 
+/* When a modification to fackets out becomes necessary, we need to check
+ * skb is counted to fackets_out or not. Another important thing is to
+ * tweak SACK fastpath hint too as it would overwrite all changes unless
+ * hint is also changed.
+ */
+static void tcp_adjust_fackets_out(struct tcp_sock *tp, struct sk_buff *skb,
+                                  int decr)
+{
+       if (!tp->sacked_out || tcp_is_reno(tp))
+               return;
+
+       if (!before(tp->highest_sack, TCP_SKB_CB(skb)->seq))
+               tp->fackets_out -= decr;
+
+       /* cnt_hint is "off-by-one" compared with fackets_out (see sacktag) */
+       if (tp->fastpath_skb_hint != NULL &&
+           after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq, TCP_SKB_CB(skb)->seq))
+               tp->fastpath_cnt_hint -= decr;
+}
+
 /* Function to create two new TCP segments.  Shrinks the given segment
  * to the specified size and appends a new segment with the rest of the
  * packet to the list.  This won't be called frequently, I hope.
@@ -671,7 +687,7 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
 
        BUG_ON(len > skb->len);
 
-       clear_all_retrans_hints(tp);
+       tcp_clear_retrans_hints_partial(tp);
        nsize = skb_headlen(skb) - len;
        if (nsize < 0)
                nsize = 0;
@@ -696,6 +712,10 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
        TCP_SKB_CB(buff)->end_seq = TCP_SKB_CB(skb)->end_seq;
        TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq;
 
+       if (tcp_is_sack(tp) && tp->sacked_out &&
+           (TCP_SKB_CB(skb)->seq == tp->highest_sack))
+               tp->highest_sack = TCP_SKB_CB(buff)->seq;
+
        /* PSH and FIN should only be set in the second packet. */
        flags = TCP_SKB_CB(skb)->flags;
        TCP_SKB_CB(skb)->flags = flags & ~(TCPCB_FLAG_FIN|TCPCB_FLAG_PSH);
@@ -747,21 +767,12 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
                if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST)
                        tp->lost_out -= diff;
 
-               if (diff > 0) {
-                       /* Adjust Reno SACK estimate. */
-                       if (tcp_is_reno(tp)) {
-                               tcp_dec_pcount_approx_int(&tp->sacked_out, diff);
-                               tcp_verify_left_out(tp);
-                       }
-
-                       tcp_dec_pcount_approx_int(&tp->fackets_out, diff);
-                       /* SACK fastpath might overwrite it unless dealt with */
-                       if (tp->fastpath_skb_hint != NULL &&
-                           after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq,
-                                 TCP_SKB_CB(skb)->seq)) {
-                               tcp_dec_pcount_approx_int(&tp->fastpath_cnt_hint, diff);
-                       }
+               /* Adjust Reno SACK estimate. */
+               if (tcp_is_reno(tp) && diff > 0) {
+                       tcp_dec_pcount_approx_int(&tp->sacked_out, diff);
+                       tcp_verify_left_out(tp);
                }
+               tcp_adjust_fackets_out(tp, skb, diff);
        }
 
        /* Link BUFF into the send queue. */
@@ -1708,8 +1719,9 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
                BUG_ON(tcp_skb_pcount(skb) != 1 ||
                       tcp_skb_pcount(next_skb) != 1);
 
-               /* changing transmit queue under us so clear hints */
-               clear_all_retrans_hints(tp);
+               if (WARN_ON(tcp_is_sack(tp) && tp->sacked_out &&
+                   (TCP_SKB_CB(next_skb)->seq == tp->highest_sack)))
+                       return;
 
                /* Ok.  We will be able to collapse the packet. */
                tcp_unlink_write_queue(next_skb, sk);
@@ -1743,11 +1755,17 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *skb, int m
                if (tcp_is_reno(tp) && tp->sacked_out)
                        tcp_dec_pcount_approx(&tp->sacked_out, next_skb);
 
-               /* Not quite right: it can be > snd.fack, but
-                * it is better to underestimate fackets.
-                */
-               tcp_dec_pcount_approx(&tp->fackets_out, next_skb);
+               tcp_adjust_fackets_out(tp, next_skb, tcp_skb_pcount(next_skb));
                tp->packets_out -= tcp_skb_pcount(next_skb);
+
+               /* changed transmit queue under us so clear hints */
+               tcp_clear_retrans_hints_partial(tp);
+               /* manually tune sacktag skb hint */
+               if (tp->fastpath_skb_hint == next_skb) {
+                       tp->fastpath_skb_hint = skb;
+                       tp->fastpath_cnt_hint -= tcp_skb_pcount(skb);
+               }
+
                sk_stream_free_skb(sk, next_skb);
        }
 }
@@ -1781,7 +1799,7 @@ void tcp_simple_retransmit(struct sock *sk)
                }
        }
 
-       clear_all_retrans_hints(tp);
+       tcp_clear_all_retrans_hints(tp);
 
        if (!lost)
                return;
@@ -1896,6 +1914,8 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
                                printk(KERN_DEBUG "retrans_out leaked.\n");
                }
 #endif
+               if (!tp->retrans_out)
+                       tp->lost_retrans_low = tp->snd_nxt;
                TCP_SKB_CB(skb)->sacked |= TCPCB_RETRANS;
                tp->retrans_out += tcp_skb_pcount(skb);