Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139825
b: refs/heads/master
c: 797108d
h: refs/heads/master
i:
  139823: 368c72e
v: v3
  • Loading branch information
Ilpo Järvinen authored and David S. Miller committed Apr 2, 2009
1 parent 33d9a6a commit 535382b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 48 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0de8ca597d7b449e9e7ce7af138944acf06c8f05
refs/heads/master: 797108d134a91afca9fa59c572336b279bc66afb
15 changes: 0 additions & 15 deletions trunk/include/net/tcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -616,21 +616,6 @@ static inline int tcp_skb_mss(const struct sk_buff *skb)
return skb_shinfo(skb)->gso_size;
}

static inline void tcp_dec_pcount_approx_int(__u32 *count, const int decr)
{
if (*count) {
*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));
}

/* Events passed to congestion control interface */
enum tcp_ca_event {
CA_EVENT_TX_START, /* first transmit when no packets in flight */
Expand Down
66 changes: 34 additions & 32 deletions trunk/net/ipv4/tcp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,36 @@ static void tcp_adjust_fackets_out(struct sock *sk, struct sk_buff *skb,
tp->fackets_out -= decr;
}

/* Pcount in the middle of the write queue got changed, we need to do various
* tweaks to fix counters
*/
static void tcp_adjust_pcount(struct sock *sk, struct sk_buff *skb, int decr)
{
struct tcp_sock *tp = tcp_sk(sk);

tp->packets_out -= decr;

if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)
tp->sacked_out -= decr;
if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)
tp->retrans_out -= decr;
if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST)
tp->lost_out -= decr;

/* Reno case is special. Sigh... */
if (tcp_is_reno(tp) && decr > 0)
tp->sacked_out -= min_t(u32, tp->sacked_out, decr);

tcp_adjust_fackets_out(sk, skb, decr);

if (tp->lost_skb_hint &&
before(TCP_SKB_CB(skb)->seq, TCP_SKB_CB(tp->lost_skb_hint)->seq) &&
(tcp_is_fack(tp) || TCP_SKB_CB(skb)->sacked))
tp->lost_cnt_hint -= decr;

tcp_verify_left_out(tp);
}

/* 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.
Expand Down Expand Up @@ -836,28 +866,8 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len,
int diff = old_factor - tcp_skb_pcount(skb) -
tcp_skb_pcount(buff);

tp->packets_out -= diff;

if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_ACKED)
tp->sacked_out -= diff;
if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS)
tp->retrans_out -= diff;

if (TCP_SKB_CB(skb)->sacked & TCPCB_LOST)
tp->lost_out -= 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(sk, skb, diff);

if (tp->lost_skb_hint &&
before(TCP_SKB_CB(skb)->seq,
TCP_SKB_CB(tp->lost_skb_hint)->seq) &&
(tcp_is_fack(tp) || TCP_SKB_CB(skb)->sacked))
tp->lost_cnt_hint -= diff;
if (diff)
tcp_adjust_pcount(sk, skb, diff);
}

/* Link BUFF into the send queue. */
Expand Down Expand Up @@ -1768,22 +1778,14 @@ static void tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb)
* packet counting does not break.
*/
TCP_SKB_CB(skb)->sacked |= TCP_SKB_CB(next_skb)->sacked & TCPCB_EVER_RETRANS;
if (TCP_SKB_CB(next_skb)->sacked & TCPCB_SACKED_RETRANS)
tp->retrans_out -= tcp_skb_pcount(next_skb);
if (TCP_SKB_CB(next_skb)->sacked & TCPCB_LOST)
tp->lost_out -= tcp_skb_pcount(next_skb);
/* Reno case is special. Sigh... */
if (tcp_is_reno(tp) && tp->sacked_out)
tcp_dec_pcount_approx(&tp->sacked_out, next_skb);

tcp_adjust_fackets_out(sk, 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);
if (next_skb == tp->retransmit_skb_hint)
tp->retransmit_skb_hint = skb;

tcp_adjust_pcount(sk, next_skb, tcp_skb_pcount(next_skb));

sk_wmem_free_skb(sk, next_skb);
}

Expand Down

0 comments on commit 535382b

Please sign in to comment.