[TCP]: Add tcp_dec_pcount_approx int variant
authorIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Fri, 15 Jun 2007 09:58:38 +0000 (12:58 +0300)
committerDavid S. Miller <davem@sunset.davemloft.net>
Wed, 10 Oct 2007 23:47:54 +0000 (16:47 -0700)
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tcp.h
net/ipv4/tcp_output.c

index dde04afbe0a468315e63edbf1ed08757762c7507..9d3438f6b52f3ba469f1dd85acd33cfc444245d3 100644 (file)
@@ -599,16 +599,21 @@ static inline int tcp_skb_mss(const struct sk_buff *skb)
        return skb_shinfo(skb)->gso_size;
 }
 
-static inline void tcp_dec_pcount_approx(__u32 *count,
-                                        const struct sk_buff *skb)
+static inline void tcp_dec_pcount_approx_int(__u32 *count, const int decr)
 {
        if (*count) {
-               *count -= tcp_skb_pcount(skb);
+               *count -= decr;
                if ((int)*count < 0)
                        *count = 0;
        }
 }
 
+static inline void tcp_dec_pcount_approx(__u32 *count,
+                                        const struct sk_buff *skb)
+{
+       tcp_dec_pcount_approx_int(count, tcp_skb_pcount(skb));
+}
+
 static inline void tcp_packets_out_inc(struct sock *sk,
                                       const struct sk_buff *skb)
 {
index 3abe22e4b57622ca6a6ecbca64dc54a2d34efed9..3c8c8e7f6f6d331aa0001ba0bdeb6bbec85a135d 100644 (file)
@@ -740,22 +740,16 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
                if (diff > 0) {
                        /* Adjust Reno SACK estimate. */
                        if (!tp->rx_opt.sack_ok) {
-                               tp->sacked_out -= diff;
-                               if ((int)tp->sacked_out < 0)
-                                       tp->sacked_out = 0;
+                               tcp_dec_pcount_approx_int(&tp->sacked_out, diff);
                                tcp_sync_left_out(tp);
                        }
 
-                       tp->fackets_out -= diff;
-                       if ((int)tp->fackets_out < 0)
-                               tp->fackets_out = 0;
+                       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)) {
-                               tp->fastpath_cnt_hint -= diff;
-                               if ((int)tp->fastpath_cnt_hint < 0)
-                                       tp->fastpath_cnt_hint = 0;
+                               tcp_dec_pcount_approx_int(&tp->fastpath_cnt_hint, diff);
                        }
                }
        }