netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>,
	Sangtae Ha <sangtae.ha@gmail.com>,
	Injong Rhee <injongrhee@gmail.com>
Cc: Valdis.Kletnieks@vt.edu, rdunlap@xenotime.net, lkml@techboom.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] tcp_cubic: limit delayed_ack ratio to prevent divide error
Date: Wed, 4 May 2011 13:04:56 -0700	[thread overview]
Message-ID: <20110504130456.425dee68@nehalam> (raw)
In-Reply-To: <20110504.124053.260068550.davem@davemloft.net>

TCP Cubic keeps a metric that estimates the amount of delayed
acknowledgements to use in adjusting the window. If an abnormally
large number of packets are acknowledged at once, then the update
could wrap and reach zero. This kind of ACK could only
happen when there was a large window and huge number of
ACK's were lost.

This patch limits the value of delayed ack ratio. The choice of 32
is just a conservative value since normally it should be range of 
1 to 4 packets.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
Patch against 2.6.39-rc5+


--- a/net/ipv4/tcp_cubic.c	2011-05-04 11:58:49.666027155 -0700
+++ b/net/ipv4/tcp_cubic.c	2011-05-04 12:52:34.716767304 -0700
@@ -93,6 +93,7 @@ struct bictcp {
 	u32	ack_cnt;	/* number of acks */
 	u32	tcp_cwnd;	/* estimated tcp cwnd */
 #define ACK_RATIO_SHIFT	4
+#define ACK_RATIO_LIMIT (32u << ACK_RATIO_SHIFT)
 	u16	delayed_ack;	/* estimate the ratio of Packets/ACKs << 4 */
 	u8	sample_cnt;	/* number of samples to decide curr_rtt */
 	u8	found;		/* the exit point is found? */
@@ -398,8 +399,12 @@ static void bictcp_acked(struct sock *sk
 	u32 delay;
 
 	if (icsk->icsk_ca_state == TCP_CA_Open) {
-		cnt -= ca->delayed_ack >> ACK_RATIO_SHIFT;
-		ca->delayed_ack += cnt;
+		u32 ratio = ca->delayed_ack;
+
+		ratio -= ca->delayed_ack >> ACK_RATIO_SHIFT;
+		ratio += cnt;
+
+		ca->delayed_ack = min(ratio, ACK_RATIO_LIMIT);
 	}
 
 	/* Some calls are for duplicates without timetamps */

  parent reply	other threads:[~2011-05-04 20:04 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <4DC178D3.6030308@techboom.com>
2011-05-04 17:49 ` Divide error in bictcp_cong_avoid ? Randy Dunlap
2011-05-04 18:33   ` Stephen Hemminger
2011-05-04 18:35     ` Randy Dunlap
2011-05-04 19:03       ` TB
2011-05-04 18:56     ` David Miller
2011-05-04 19:31     ` Valdis.Kletnieks
2011-05-04 19:37       ` Stephen Hemminger
2011-05-04 19:40         ` David Miller
2011-05-04 20:01           ` Valdis.Kletnieks
2011-05-04 20:04           ` Stephen Hemminger [this message]
2011-05-04 20:53             ` [PATCH] tcp_cubic: limit delayed_ack ratio to prevent divide error Brandeburg, Jesse
2011-05-06 16:15               ` TB
2011-05-06 16:53                 ` Stephen Hemminger
2011-05-06 17:39                   ` TB
2011-05-11 14:49                   ` TB
2011-05-11 15:22                     ` Stephen Hemminger
2011-05-11 15:35                       ` TB
2011-05-08 22:52             ` 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=20110504130456.425dee68@nehalam \
    --to=shemminger@vyatta.com \
    --cc=Valdis.Kletnieks@vt.edu \
    --cc=davem@davemloft.net \
    --cc=injongrhee@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkml@techboom.com \
    --cc=netdev@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    --cc=sangtae.ha@gmail.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;
as well as URLs for NNTP newsgroup(s).