From patchwork Fri Jul 20 05:40:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 172127 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 8123B2C00B9 for ; Fri, 20 Jul 2012 15:40:58 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752916Ab2GTFkw (ORCPT ); Fri, 20 Jul 2012 01:40:52 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:35141 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752176Ab2GTFkt (ORCPT ); Fri, 20 Jul 2012 01:40:49 -0400 Received: by weyx8 with SMTP id x8so2301051wey.19 for ; Thu, 19 Jul 2012 22:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; bh=FiPdfKRqVB/B+XUAaU6qN/EI5xb024baf9j8sXJ3O9k=; b=yvPdNCxg6ilKlbif5o3vyivgNYcui88a7wbcaiuvyFzuG00OXweybLKhcltsnoPQbm Qgq+T6Cn0P6TiURA3h8GB3ZEA0xntO50+3Sy/XWS0HueJ6ITW2P6lyEX0CXJ3KdmQohv lJMXimtSYkKGX/3KWcDKfvzpEq3pqmcGmsArAQc/fpAU9KZDYpaogovrnCknRiOeVCVY yGxig1hUXMy1Tv0ICBYZ3q2BI0JZpOYYcinfqLV+AEVLFix97nkk89yOGdAqr0/mUA9Q 2a7WvhdEeZTHt3ohxn/vAVu5nPMMRlqKaDYy61ysg3wXOnQdF6qrXq+50HUMjR+ylZxJ a9kA== Received: by 10.216.141.84 with SMTP id f62mr2864209wej.91.1342762847514; Thu, 19 Jul 2012 22:40:47 -0700 (PDT) Received: from [172.28.91.20] ([74.125.122.49]) by mx.google.com with ESMTPS id df4sm42588410wib.4.2012.07.19.22.40.43 (version=SSLv3 cipher=OTHER); Thu, 19 Jul 2012 22:40:44 -0700 (PDT) Subject: [PATCH net-next] tcp: fix ABC in tcp_slow_start() From: Eric Dumazet To: David Miller Cc: netdev , Tom Herbert , Yuchung Cheng , Neal Cardwell , Nandita Dukkipati , John Heffner , Stephen Hemminger Date: Fri, 20 Jul 2012 07:40:41 +0200 Message-ID: <1342762841.2626.5633.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet When/if sysctl_tcp_abc > 1, we expect to increase cwnd by 2 if the received ACK acknowledges more than 2*MSS bytes, in tcp_slow_start() Problem is this RFC 3465 statement is not correctly coded, as the while () loop increases snd_cwnd one by one. So to reach the "cwnd += 2" goal, we need to use "cnt = 2*cnt + 1" Signed-off-by: Eric Dumazet Cc: Tom Herbert Cc: Yuchung Cheng Cc: Neal Cardwell Cc: Nandita Dukkipati Cc: John Heffner Cc: Stephen Hemminger --- net/ipv4/tcp_cong.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 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 04dbd7a..486379a 100644 --- a/net/ipv4/tcp_cong.c +++ b/net/ipv4/tcp_cong.c @@ -306,7 +306,7 @@ EXPORT_SYMBOL_GPL(tcp_is_cwnd_limited); */ void tcp_slow_start(struct tcp_sock *tp) { - int cnt; /* increase in packets */ + unsigned int cnt; /* increase in packets */ /* RFC3465: ABC Slow start * Increase only after a full MSS of bytes is acked @@ -318,16 +318,19 @@ void tcp_slow_start(struct tcp_sock *tp) if (sysctl_tcp_abc && tp->bytes_acked < tp->mss_cache) return; - if (sysctl_tcp_max_ssthresh > 0 && tp->snd_cwnd > sysctl_tcp_max_ssthresh) + cnt = tp->snd_cwnd; /* exponential increase */ + 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 */ /* RFC3465: ABC * We MAY increase by 2 if discovered delayed ack + * The "+ 1" in the expression is needed if we want to increase + * cwnd by 2, because the way is coded the following loop. */ if (sysctl_tcp_abc > 1 && tp->bytes_acked >= 2*tp->mss_cache) - cnt <<= 1; + cnt = 2*cnt + 1; + tp->bytes_acked = 0; tp->snd_cwnd_cnt += cnt;