From patchwork Sat Sep 20 17:52:21 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [net-next,03/15] tcp: add helper for lost bit toggling Date: Sat, 20 Sep 2008 07:52:21 -0000 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 723 Message-Id: <1221933153-11874-4-git-send-email-ilpo.jarvinen@helsinki.fi> To: David Miller Cc: netdev@vger.kernel.org, "=?utf-8?q?Ilpo=20J=E4rvinen?=" Signed-off-by: Ilpo Järvinen --- include/net/tcp.h | 1 + net/ipv4/tcp_input.c | 36 +++++++++++++++++++----------------- net/ipv4/tcp_output.c | 3 +-- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/net/tcp.h b/include/net/tcp.h index b716763..38551bb 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -472,6 +472,7 @@ extern void tcp_send_delayed_ack(struct sock *sk); /* tcp_input.c */ extern void tcp_cwnd_application_limited(struct sock *sk); +extern void tcp_skb_mark_lost(struct tcp_sock *tp, struct sk_buff *skb); /* tcp_timer.c */ extern void tcp_init_xmit_timers(struct sock *); diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 9e95ad6..f46c7fe 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -992,6 +992,18 @@ static void tcp_verify_retransmit_hint(struct tcp_sock *tp, struct sk_buff *skb) tp->retransmit_skb_hint = NULL; } +static void __tcp_skb_mark_lost(struct tcp_sock *tp, struct sk_buff *skb) +{ + tp->lost_out += tcp_skb_pcount(skb); + TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; +} + +void tcp_skb_mark_lost(struct tcp_sock *tp, struct sk_buff *skb) +{ + __tcp_skb_mark_lost(tp, skb); + tcp_verify_retransmit_hint(tp, skb); +} + /* This procedure tags the retransmission queue when SACKs arrive. * * We have three tag bits: SACKED(S), RETRANS(R) and LOST(L). @@ -1168,13 +1180,9 @@ static void tcp_mark_lost_retrans(struct sock *sk) TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS; tp->retrans_out -= tcp_skb_pcount(skb); - /* clear lost hint */ - tp->retransmit_skb_hint = NULL; - - if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_LOST|TCPCB_SACKED_ACKED))) { - tp->lost_out += tcp_skb_pcount(skb); - TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; - } + if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_LOST|TCPCB_SACKED_ACKED))) + __tcp_skb_mark_lost(tp, skb); + tcp_verify_retransmit_hint(tp, skb); NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPLOSTRETRANSMIT); } else { if (before(ack_seq, new_low_seq)) @@ -2216,11 +2224,8 @@ static void tcp_mark_head_lost(struct sock *sk, int packets) cnt = packets; } - if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_SACKED_ACKED|TCPCB_LOST))) { - TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; - tp->lost_out += tcp_skb_pcount(skb); - tcp_verify_retransmit_hint(tp, skb); - } + if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_SACKED_ACKED|TCPCB_LOST))) + tcp_skb_mark_lost(tp, skb); } tcp_verify_left_out(tp); } @@ -2262,11 +2267,8 @@ static void tcp_update_scoreboard(struct sock *sk, int fast_rexmit) if (!tcp_skb_timedout(sk, skb)) break; - if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_SACKED_ACKED|TCPCB_LOST))) { - TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; - tp->lost_out += tcp_skb_pcount(skb); - tcp_verify_retransmit_hint(tp, skb); - } + if (!(TCP_SKB_CB(skb)->sacked & (TCPCB_SACKED_ACKED|TCPCB_LOST))) + tcp_skb_mark_lost(tp, skb); } tp->scoreboard_skb_hint = skb; diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 2242c2c..1b8d980 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1848,8 +1848,7 @@ void tcp_simple_retransmit(struct sock *sk) tp->retrans_out -= tcp_skb_pcount(skb); } if (!(TCP_SKB_CB(skb)->sacked & TCPCB_LOST)) { - TCP_SKB_CB(skb)->sacked |= TCPCB_LOST; - tp->lost_out += tcp_skb_pcount(skb); + tcp_skb_mark_lost(tp, skb); lost = 1; } }