diff options
| author | Ilpo Järvinen <ilpo.jarvinen@helsinki.fi> | 2007-06-15 05:58:38 -0400 |
|---|---|---|
| committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:47:54 -0400 |
| commit | af610b4ca19f513a50d47ea93ed57241383c8081 (patch) | |
| tree | b7bc4e7f7969b10a2a8d3e3de7375f64df93dd4e | |
| parent | bdf1ee5d3bd38d0c44bd7baa74e07adcbe4ceab1 (diff) | |
[TCP]: Add tcp_dec_pcount_approx int variant
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/net/tcp.h | 11 | ||||
| -rw-r--r-- | net/ipv4/tcp_output.c | 12 |
2 files changed, 11 insertions, 12 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h index dde04afbe0a4..9d3438f6b52f 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
| @@ -599,16 +599,21 @@ static inline int tcp_skb_mss(const struct sk_buff *skb) | |||
| 599 | return skb_shinfo(skb)->gso_size; | 599 | return skb_shinfo(skb)->gso_size; |
| 600 | } | 600 | } |
| 601 | 601 | ||
| 602 | static inline void tcp_dec_pcount_approx(__u32 *count, | 602 | static inline void tcp_dec_pcount_approx_int(__u32 *count, const int decr) |
| 603 | const struct sk_buff *skb) | ||
| 604 | { | 603 | { |
| 605 | if (*count) { | 604 | if (*count) { |
| 606 | *count -= tcp_skb_pcount(skb); | 605 | *count -= decr; |
| 607 | if ((int)*count < 0) | 606 | if ((int)*count < 0) |
| 608 | *count = 0; | 607 | *count = 0; |
| 609 | } | 608 | } |
| 610 | } | 609 | } |
| 611 | 610 | ||
| 611 | static inline void tcp_dec_pcount_approx(__u32 *count, | ||
| 612 | const struct sk_buff *skb) | ||
| 613 | { | ||
| 614 | tcp_dec_pcount_approx_int(count, tcp_skb_pcount(skb)); | ||
| 615 | } | ||
| 616 | |||
| 612 | static inline void tcp_packets_out_inc(struct sock *sk, | 617 | static inline void tcp_packets_out_inc(struct sock *sk, |
| 613 | const struct sk_buff *skb) | 618 | const struct sk_buff *skb) |
| 614 | { | 619 | { |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 3abe22e4b576..3c8c8e7f6f6d 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -740,22 +740,16 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss | |||
| 740 | if (diff > 0) { | 740 | if (diff > 0) { |
| 741 | /* Adjust Reno SACK estimate. */ | 741 | /* Adjust Reno SACK estimate. */ |
| 742 | if (!tp->rx_opt.sack_ok) { | 742 | if (!tp->rx_opt.sack_ok) { |
| 743 | tp->sacked_out -= diff; | 743 | tcp_dec_pcount_approx_int(&tp->sacked_out, diff); |
| 744 | if ((int)tp->sacked_out < 0) | ||
| 745 | tp->sacked_out = 0; | ||
| 746 | tcp_sync_left_out(tp); | 744 | tcp_sync_left_out(tp); |
| 747 | } | 745 | } |
| 748 | 746 | ||
| 749 | tp->fackets_out -= diff; | 747 | tcp_dec_pcount_approx_int(&tp->fackets_out, diff); |
| 750 | if ((int)tp->fackets_out < 0) | ||
| 751 | tp->fackets_out = 0; | ||
| 752 | /* SACK fastpath might overwrite it unless dealt with */ | 748 | /* SACK fastpath might overwrite it unless dealt with */ |
| 753 | if (tp->fastpath_skb_hint != NULL && | 749 | if (tp->fastpath_skb_hint != NULL && |
| 754 | after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq, | 750 | after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq, |
| 755 | TCP_SKB_CB(skb)->seq)) { | 751 | TCP_SKB_CB(skb)->seq)) { |
| 756 | tp->fastpath_cnt_hint -= diff; | 752 | tcp_dec_pcount_approx_int(&tp->fastpath_cnt_hint, diff); |
| 757 | if ((int)tp->fastpath_cnt_hint < 0) | ||
| 758 | tp->fastpath_cnt_hint = 0; | ||
| 759 | } | 753 | } |
| 760 | } | 754 | } |
| 761 | } | 755 | } |
