Commit af610b4c authored by Ilpo Järvinen's avatar Ilpo Järvinen Committed by David S. Miller

[TCP]: Add tcp_dec_pcount_approx int variant

Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@helsinki.fi>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bdf1ee5d
...@@ -599,16 +599,21 @@ static inline int tcp_skb_mss(const struct sk_buff *skb) ...@@ -599,16 +599,21 @@ static inline int tcp_skb_mss(const struct sk_buff *skb)
return skb_shinfo(skb)->gso_size; return skb_shinfo(skb)->gso_size;
} }
static inline void tcp_dec_pcount_approx(__u32 *count, static inline void tcp_dec_pcount_approx_int(__u32 *count, const int decr)
const struct sk_buff *skb)
{ {
if (*count) { if (*count) {
*count -= tcp_skb_pcount(skb); *count -= decr;
if ((int)*count < 0) if ((int)*count < 0)
*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, static inline void tcp_packets_out_inc(struct sock *sk,
const struct sk_buff *skb) const struct sk_buff *skb)
{ {
......
...@@ -740,22 +740,16 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss ...@@ -740,22 +740,16 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss
if (diff > 0) { if (diff > 0) {
/* Adjust Reno SACK estimate. */ /* Adjust Reno SACK estimate. */
if (!tp->rx_opt.sack_ok) { if (!tp->rx_opt.sack_ok) {
tp->sacked_out -= diff; tcp_dec_pcount_approx_int(&tp->sacked_out, diff);
if ((int)tp->sacked_out < 0)
tp->sacked_out = 0;
tcp_sync_left_out(tp); tcp_sync_left_out(tp);
} }
tp->fackets_out -= diff; tcp_dec_pcount_approx_int(&tp->fackets_out, diff);
if ((int)tp->fackets_out < 0)
tp->fackets_out = 0;
/* SACK fastpath might overwrite it unless dealt with */ /* SACK fastpath might overwrite it unless dealt with */
if (tp->fastpath_skb_hint != NULL && if (tp->fastpath_skb_hint != NULL &&
after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq, after(TCP_SKB_CB(tp->fastpath_skb_hint)->seq,
TCP_SKB_CB(skb)->seq)) { TCP_SKB_CB(skb)->seq)) {
tp->fastpath_cnt_hint -= diff; tcp_dec_pcount_approx_int(&tp->fastpath_cnt_hint, diff);
if ((int)tp->fastpath_cnt_hint < 0)
tp->fastpath_cnt_hint = 0;
} }
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment