From patchwork Sat Feb 2 15:23:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 217675 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 88C392C008E for ; Sun, 3 Feb 2013 02:23:23 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757754Ab3BBPXV (ORCPT ); Sat, 2 Feb 2013 10:23:21 -0500 Received: from mail-pa0-f44.google.com ([209.85.220.44]:61439 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752730Ab3BBPXT (ORCPT ); Sat, 2 Feb 2013 10:23:19 -0500 Received: by mail-pa0-f44.google.com with SMTP id hz11so2674785pad.3 for ; Sat, 02 Feb 2013 07:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:subject:from:to:cc:date:in-reply-to :references:content-type:x-mailer:content-transfer-encoding :mime-version; bh=Vug5OsHPqgTL/HLtOQ1ySTOKmr2j09wfGJ67xKCB2po=; b=WveGpXpF2FW6ZpL4Jj2hYu7bhhA8gClA+tEstGFdVVkl4HhHXKIutpExkSD3iiOCzq pimayuC8VQFOZtQsmszJy7s9fWH1Y0xI8f9RpE1W7Ak1jmrcwWXbNyAc4cBXWq8oH8qQ eenOHXyO5yTiEtDu/74yySfUtipkUB48Cai7ONs7oz6U5oTNtDsRK/Ex6TVrFu1kXM0s SymUeXJ626sjDfnDttUa5JhrPyQ0bYhJWAs01Nj1y0ZtOfdoGFXpG1tEtTxh6fBjs4DJ Uv6BjpP+YE79bthJOrvZXYnqcT6B3/gZ9kSA65zAIq4rvNwHRG6NZlkImeAUAPTVRbxD MJvA== X-Received: by 10.68.224.130 with SMTP id rc2mr41115250pbc.156.1359818598880; Sat, 02 Feb 2013 07:23:18 -0800 (PST) Received: from [192.168.1.119] (c-67-170-232-166.hsd1.ca.comcast.net. [67.170.232.166]) by mx.google.com with ESMTPS id ug6sm11985415pbc.4.2013.02.02.07.23.17 (version=SSLv3 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 07:23:18 -0800 (PST) Message-ID: <1359818596.30177.84.camel@edumazet-glaptop> Subject: [PATCH] tcp: fix an infinite loop in tcp_slow_start() From: Eric Dumazet To: Pasi =?ISO-8859-1?Q?K=E4rkk=E4inen?= , David Miller Cc: Hannes Frederic Sowa , Stephen Hemminger , netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng Date: Sat, 02 Feb 2013 07:23:16 -0800 In-Reply-To: <20130202142832.GP8912@reaktio.net> References: <20130123161238.GE8912@reaktio.net> <20130123214445.GA16641@order.stressinduktion.org> <20130123215151.GF8912@reaktio.net> <20130123152642.4a8389ba@nehalam.linuxnetplumber.net> <20130123234116.GC16641@order.stressinduktion.org> <1358984831.12374.1227.camel@edumazet-glaptop> <20130124135120.GD16641@order.stressinduktion.org> <1359777110.30177.58.camel@edumazet-glaptop> <20130202142832.GP8912@reaktio.net> X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet 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 Signed-off-by: Eric Dumazet Cc: Neal Cardwell Cc: Yuchung Cheng --- net/ipv4/tcp_cong.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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);