Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: David Miller <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>, "Jerry Chu" <hkchu@google.com>,
	"Ilpo Järvinen" <ilpo.jarvinen@helsinki.fi>,
	"Jamal Hadi Salim" <jhs@mojatatu.com>,
	"Jim Gettys" <jg@freedesktop.org>,
	"Dave Taht" <dave.taht@gmail.com>
Subject: [PATCH] tcp: ECN blackhole should not force quickack mode
Date: Fri, 23 Sep 2011 08:02:19 +0200	[thread overview]
Message-ID: <1316757739.2560.12.camel@edumazet-laptop> (raw)

While playing with a new ADSL box at home, I discovered that ECN
blackhole can trigger suboptimal quickack mode on linux : We send one
ACK for each incoming data frame, without any delay and eventual
piggyback.

This is because TCP_ECN_check_ce() considers that if no ECT is seen on a
segment, this is because this segment was a retransmit.

Refine this heuristic and apply it only if we seen ECT in a previous
segment, to detect ECN blackhole at IP level.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
CC: Jamal Hadi Salim <jhs@mojatatu.com>
CC: Jerry Chu <hkchu@google.com>
CC: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
CC: Jim Gettys <jg@freedesktop.org>
CC: Dave Taht <dave.taht@gmail.com>
---
Another possibility is to remove this (not in RFC 3168) heuristic, what
do you think ?

 include/net/tcp.h    |    1 +
 net/ipv4/tcp_input.c |   23 ++++++++++++++++-------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index f357bef..702aefc 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -356,6 +356,7 @@ static inline void tcp_dec_quickack_mode(struct sock *sk,
 #define	TCP_ECN_OK		1
 #define	TCP_ECN_QUEUE_CWR	2
 #define	TCP_ECN_DEMAND_CWR	4
+#define	TCP_ECN_SEEN		8
 
 static __inline__ void
 TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a5d01b1..5a4408c 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -217,16 +217,25 @@ static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp)
 	tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR;
 }
 
-static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb)
+static inline void TCP_ECN_check_ce(struct tcp_sock *tp, const struct sk_buff *skb)
 {
-	if (tp->ecn_flags & TCP_ECN_OK) {
-		if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags))
-			tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
+	if (!(tp->ecn_flags & TCP_ECN_OK))
+		return;
+
+	switch (TCP_SKB_CB(skb)->flags & INET_ECN_MASK) {
+	case INET_ECN_NOT_ECT:
 		/* Funny extension: if ECT is not set on a segment,
-		 * it is surely retransmit. It is not in ECN RFC,
-		 * but Linux follows this rule. */
-		else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags)))
+		 * and we already seen ECT on a previous segment,
+		 * it is probably a retransmit.
+		 */
+		if (tp->ecn_flags & TCP_ECN_SEEN)
 			tcp_enter_quickack_mode((struct sock *)tp);
+		break;
+	case INET_ECN_CE:
+		tp->ecn_flags |= TCP_ECN_DEMAND_CWR;
+		/* fallinto */
+	default:
+		tp->ecn_flags |= TCP_ECN_SEEN;
 	}
 }
 

             reply	other threads:[~2011-09-23  6:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23  6:02 Eric Dumazet [this message]
2011-09-23 17:47 ` [PATCH] tcp: ECN blackhole should not force quickack mode David Miller
2011-09-23 19:17 ` Ilpo Järvinen
2011-09-24  0:55 ` Jamal Hadi Salim
2011-09-25 19:24   ` Eric Dumazet
2011-09-26  1:07     ` jamal
2011-09-26  1:13       ` jamal
2011-09-26  8:26         ` Eric Dumazet
2011-09-26 12:00           ` jamal
2011-09-26 12:44             ` Eric Dumazet
2011-09-27  4:59 ` David Miller
2011-09-27  6:00   ` [PATCH net-next] tcp: unalias tcp_skb_cb flags and ip_dsfield Eric Dumazet
2011-09-27  6:20     ` David Miller
2011-09-27  7:37       ` Christoph Paasch
2011-09-27  8:01         ` Eric Dumazet
2011-09-27  8:08         ` David Miller
2011-09-27  8:38           ` Christoph Paasch
2011-09-27  9:23             ` Eric Dumazet
2011-09-27  9:28               ` Christoph Paasch
2011-09-27  9:40                 ` Eric Dumazet
2011-09-27  9:51       ` [PATCH net-next] tcp: rename tcp_skb_cb flags Eric Dumazet
2011-09-27 17:25         ` David Miller

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=1316757739.2560.12.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=dave.taht@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hkchu@google.com \
    --cc=ilpo.jarvinen@helsinki.fi \
    --cc=jg@freedesktop.org \
    --cc=jhs@mojatatu.com \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox