Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Pasi Kärkkäinen" <pasik@iki.fi>, "David Miller" <davem@davemloft.net>
Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>,
	Stephen Hemminger <stephen@networkplumber.org>,
	netdev@vger.kernel.org, Neal Cardwell <ncardwell@google.com>,
	Yuchung Cheng <ycheng@google.com>
Subject: [PATCH] tcp: fix an infinite loop in tcp_slow_start()
Date: Sat, 02 Feb 2013 07:23:16 -0800	[thread overview]
Message-ID: <1359818596.30177.84.camel@edumazet-glaptop> (raw)
In-Reply-To: <20130202142832.GP8912@reaktio.net>

From: Eric Dumazet <edumazet@google.com>

Since commit 9dc274151a548 (tcp: fix ABC in tcp_slow_start()),
a nul snd_cwnd triggers an infinite loop in tcp_slow_start()

Avoid this infinite loop and log a one time error for further
analysis. FRTO code is suspected to cause this bug.

Reported-by: Pasi Kärkkäinen <pasik@iki.fi>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
---
 net/ipv4/tcp_cong.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
index 291f2ed..cdf2e70 100644
--- a/net/ipv4/tcp_cong.c
+++ b/net/ipv4/tcp_cong.c
@@ -310,6 +310,12 @@ void tcp_slow_start(struct tcp_sock *tp)
 {
 	int cnt; /* increase in packets */
 	unsigned int delta = 0;
+	u32 snd_cwnd = tp->snd_cwnd;
+
+	if (unlikely(!snd_cwnd)) {
+		pr_err_once("snd_cwnd is nul, please report this bug.\n");
+		snd_cwnd = 1U;
+	}
 
 	/* RFC3465: ABC Slow start
 	 * Increase only after a full MSS of bytes is acked
@@ -324,7 +330,7 @@ void tcp_slow_start(struct tcp_sock *tp)
 	if (sysctl_tcp_max_ssthresh > 0 && tp->snd_cwnd > sysctl_tcp_max_ssthresh)
 		cnt = sysctl_tcp_max_ssthresh >> 1;	/* limited slow start */
 	else
-		cnt = tp->snd_cwnd;			/* exponential increase */
+		cnt = snd_cwnd;				/* exponential increase */
 
 	/* RFC3465: ABC
 	 * We MAY increase by 2 if discovered delayed ack
@@ -334,11 +340,11 @@ void tcp_slow_start(struct tcp_sock *tp)
 	tp->bytes_acked = 0;
 
 	tp->snd_cwnd_cnt += cnt;
-	while (tp->snd_cwnd_cnt >= tp->snd_cwnd) {
-		tp->snd_cwnd_cnt -= tp->snd_cwnd;
+	while (tp->snd_cwnd_cnt >= snd_cwnd) {
+		tp->snd_cwnd_cnt -= snd_cwnd;
 		delta++;
 	}
-	tp->snd_cwnd = min(tp->snd_cwnd + delta, tp->snd_cwnd_clamp);
+	tp->snd_cwnd = min(snd_cwnd + delta, tp->snd_cwnd_clamp);
 }
 EXPORT_SYMBOL_GPL(tcp_slow_start);
 

  parent reply	other threads:[~2013-02-02 15:23 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-23 16:12 Linux 3.6.x kernel crash in tcp_slow_start / bictcp_cong_avoid with wfica Pasi Kärkkäinen
2013-01-23 21:44 ` Hannes Frederic Sowa
2013-01-23 21:51   ` Pasi Kärkkäinen
2013-01-23 22:00     ` Hannes Frederic Sowa
2013-01-24  7:14       ` Pasi Kärkkäinen
2013-01-23 22:25     ` Eric Dumazet
2013-01-23 23:26     ` Stephen Hemminger
2013-01-23 23:41       ` Hannes Frederic Sowa
2013-01-23 23:47         ` Eric Dumazet
2013-01-24  6:59           ` Pasi Kärkkäinen
2013-01-24 13:51           ` Hannes Frederic Sowa
2013-02-02  3:51             ` Eric Dumazet
2013-02-02 14:28               ` Pasi Kärkkäinen
2013-02-02 15:14                 ` [PATCH] tcp: tcp_process_frto() should not set snd_cwnd to 0 Eric Dumazet
2013-02-02 15:57                   ` Neal Cardwell
2013-02-02 17:32                     ` Eric Dumazet
2013-02-03 19:13                       ` [PATCH] tcp: frto " Eric Dumazet
2013-02-03 21:01                         ` David Miller
2013-02-04 12:14                         ` Ilpo Järvinen
2013-02-04 15:07                           ` Eric Dumazet
2013-02-05 19:44                             ` Eric Dumazet
2013-02-05 19:49                           ` Neal Cardwell
2013-02-06 20:55                             ` David Miller
2013-02-06 21:13                               ` Pasi Kärkkäinen
2013-02-06 21:19                                 ` David Miller
2013-02-06 21:21                                   ` Pasi Kärkkäinen
2013-02-02 15:23                 ` Eric Dumazet [this message]
2013-02-03 21:01                   ` [PATCH] tcp: fix an infinite loop in tcp_slow_start() 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=1359818596.30177.84.camel@edumazet-glaptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=hannes@stressinduktion.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pasik@iki.fi \
    --cc=stephen@networkplumber.org \
    --cc=ycheng@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox