All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>,
	Pasi Sarolahti <pasi.sarolahti@nokia.com>
Subject: [PATCH 14/18] [TCP] FRTO: Reverse RETRANS bit clearing logic
Date: Mon, 19 Feb 2007 13:38:08 +0200	[thread overview]
Message-ID: <11718850921389-git-send-email-ilpo.jarvinen@helsinki.fi> (raw)
In-Reply-To: <11718850921409-git-send-email-ilpo.jarvinen@helsinki.fi>

Previously RETRANS bits were cleared on the entry to FRTO. We
postpone that into tcp_enter_frto_loss, which is really the
place were the clearing should be done anyway. This allows
simplification of the logic from a clearing loop to the head skb
clearing only.

Besides, the other changes made in the previous patches to
tcp_use_frto made it impossible for the non-SACKed FRTO to be
entered if other than the head has been rexmitted.

With SACK-enhanced FRTO (and Appendix B), however, there can be
a number retransmissions in flight when RTO expires (same thing
could happen before this patchset also with non-SACK FRTO). To
not introduce any jumpiness into the packet counting during FRTO,
instead of clearing RETRANS bits from skbs during entry, do it
later on.

Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
 net/ipv4/tcp_input.c |   35 +++++++++++++++++++++++------------
 1 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 8f0aa9d..2c0b387 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -1268,7 +1268,11 @@ int tcp_use_frto(struct sock *sk)
 
 /* RTO occurred, but do not yet enter Loss state. Instead, defer RTO
  * recovery a bit and use heuristics in tcp_process_frto() to detect if
- * the RTO was spurious.
+ * the RTO was spurious. Only clear SACKED_RETRANS of the head here to
+ * keep retrans_out counting accurate (with SACK F-RTO, other than head
+ * may still have that bit set); TCPCB_LOST and remaining SACKED_RETRANS
+ * bits are handled if the Loss state is really to be entered (in
+ * tcp_enter_frto_loss).
  *
  * Do like tcp_enter_loss() would; when RTO expires the second time it
  * does:
@@ -1289,17 +1293,13 @@ void tcp_enter_frto(struct sock *sk)
 		tcp_ca_event(sk, CA_EVENT_FRTO);
 	}
 
-	/* Have to clear retransmission markers here to keep the bookkeeping
-	 * in shape, even though we are not yet in Loss state.
-	 * If something was really lost, it is eventually caught up
-	 * in tcp_enter_frto_loss.
-	 */
-	tp->retrans_out = 0;
 	tp->undo_marker = tp->snd_una;
 	tp->undo_retrans = 0;
 
-	sk_stream_for_retrans_queue(skb, sk) {
+	skb = skb_peek(&sk->sk_write_queue);
+	if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) {
 		TCP_SKB_CB(skb)->sacked &= ~TCPCB_SACKED_RETRANS;
+		tp->retrans_out -= tcp_skb_pcount(skb);
 	}
 	tcp_sync_left_out(tp);
 
@@ -1313,7 +1313,7 @@ void tcp_enter_frto(struct sock *sk)
  * which indicates that we should follow the traditional RTO recovery,
  * i.e. mark everything lost and do go-back-N retransmission.
  */
-static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments)
+static void tcp_enter_frto_loss(struct sock *sk, int allowed_segments, int flag)
 {
 	struct tcp_sock *tp = tcp_sk(sk);
 	struct sk_buff *skb;
@@ -1322,10 +1322,21 @@ static void tcp_enter_frto_loss(struct s
 	tp->sacked_out = 0;
 	tp->lost_out = 0;
 	tp->fackets_out = 0;
+	tp->retrans_out = 0;
 
 	sk_stream_for_retrans_queue(skb, sk) {
 		cnt += tcp_skb_pcount(skb);
-		TCP_SKB_CB(skb)->sacked &= ~TCPCB_LOST;
+		/*
+		 * Count the retransmission made on RTO correctly (only when
+		 * waiting for the first ACK and did not get it)...
+		 */
+		if ((tp->frto_counter == 1) && !(flag&FLAG_DATA_ACKED)) {
+			tp->retrans_out += tcp_skb_pcount(skb);
+			/* ...enter this if branch just for the first segment */
+			flag |= FLAG_DATA_ACKED;
+		} else {
+			TCP_SKB_CB(skb)->sacked &= ~(TCPCB_LOST|TCPCB_SACKED_RETRANS);
+		}
 		if (!(TCP_SKB_CB(skb)->sacked&TCPCB_SACKED_ACKED)) {
 
 			/* Do not mark those segments lost that were
@@ -2550,7 +2561,7 @@ static int tcp_process_frto(struct sock 
 		inet_csk(sk)->icsk_retransmits = 0;
 
 	if (!before(tp->snd_una, tp->frto_highmark)) {
-		tcp_enter_frto_loss(sk, tp->frto_counter + 1);
+		tcp_enter_frto_loss(sk, tp->frto_counter + 1, flag);
 		return 1;
 	}
 
@@ -2562,7 +2573,7 @@ static int tcp_process_frto(struct sock 
 		return 1;
 
 	if (!(flag&FLAG_DATA_ACKED)) {
-		tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 0 : 3));
+		tcp_enter_frto_loss(sk, (tp->frto_counter == 1 ? 0 : 3), flag);
 		return 1;
 	}
 
-- 
1.4.2


  reply	other threads:[~2007-02-19 11:38 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-19 11:37 [PATCHSET 0/18] FRTO: fixes and small changes + SACK enhanced version Ilpo Järvinen
2007-02-19 11:37 ` [PATCH 1/18] [TCP] FRTO: Incorrectly clears TCPCB_EVER_RETRANS bit Ilpo Järvinen
2007-02-19 11:37   ` [PATCH 2/18] [TCP] FRTO: Separated response from FRTO detection algorithm Ilpo Järvinen
2007-02-19 11:37     ` [PATCH 3/18] [TCP] FRTO: Moved tcp_use_frto from tcp.h to tcp_input.c Ilpo Järvinen
2007-02-19 11:37       ` [PATCH 4/18] [TCP] FRTO: Comment cleanup & improvement Ilpo Järvinen
2007-02-19 11:37         ` [PATCH 5/18] [TCP] FRTO: Consecutive RTOs keep prior_ssthresh and ssthresh Ilpo Järvinen
2007-02-19 11:38           ` [PATCH 6/18] [TCP] FRTO: Use Disorder state during operation instead of Open Ilpo Järvinen
2007-02-19 11:38             ` [PATCH 7/18] [TCP] FRTO: Ignore some uninteresting ACKs Ilpo Järvinen
2007-02-19 11:38               ` [PATCH 8/18] [TCP] FRTO: fixes fallback to conventional recovery Ilpo Järvinen
2007-02-19 11:38                 ` [PATCH 9/18] [TCP] FRTO: Response should reset also snd_cwnd_cnt Ilpo Järvinen
2007-02-19 11:38                   ` [PATCH 10/18] [TCP]: Don't enter to fast recovery while using FRTO Ilpo Järvinen
2007-02-19 11:38                     ` [PATCH 11/18] [TCP] FRTO: frto_counter modulo-op converted to two assignments Ilpo Järvinen
2007-02-19 11:38                       ` [PATCH 12/18] [TCP]: Prevent unrelated cwnd adjustment while using FRTO Ilpo Järvinen
2007-02-19 11:38                         ` [PATCH 13/18] [TCP] FRTO: Entry is allowed only during (New)Reno like recovery Ilpo Järvinen
2007-02-19 11:38                           ` Ilpo Järvinen [this message]
     [not found]                             ` <1171885092244-git- send-email-ilpo.jarvinen@helsinki.fi>
2007-02-19 11:38                             ` [PATCH 15/18] [TCP] FRTO: Fake cwnd for ssthresh callback Ilpo Järvinen
2007-02-19 11:38                               ` [PATCH 16/18] [TCP]: Prevent reordering adjustments during FRTO Ilpo Järvinen
2007-02-19 11:38                                 ` [PATCH 17/18] [TCP]: SACK enhanced FRTO Ilpo Järvinen
2007-02-19 11:38                                   ` [PATCH 18/18] [TCP] FRTO: Sysctl documentation for SACK enhanced version Ilpo Järvinen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11718850921389-git-send-email-ilpo.jarvinen@helsinki.fi \
    --to=ilpo.jarvinen@helsinki.fi \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=pasi.sarolahti@nokia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.