All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tcp: fix tcp_rcv_rtt_update() use of an unscaled RTT sample
@ 2012-04-10 17:59 Neal Cardwell
  2012-04-10 18:45 ` Eric Dumazet
  2012-04-10 18:47 ` David Miller
  0 siblings, 2 replies; 9+ messages in thread
From: Neal Cardwell @ 2012-04-10 17:59 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Nandita Dukkipati, Yuchung Cheng, Eric Dumazet,
	Tom Herbert, Neal Cardwell

Fix a code path in tcp_rcv_rtt_update() that was comparing scaled and
unscaled RTT samples.

The intent in the code was to only use the 'm' measurement if it was a
new minimum.  However, since 'm' had not yet been shifted left 3 bits
but 'new_sample' had, this comparison would nearly always succeed,
leading us to erroneously set our receive-side RTT estimate to the 'm'
sample when that sample could be nearly 8x too high to use.

The overall effect is to often cause the receive-side RTT estimate to
be significantly too large (up to 40% too large for brief periods in
my tests).

Signed-off-by: Neal Cardwell <ncardwell@google.com>
---
 net/ipv4/tcp_input.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index e886e2f..e7b54d2 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -474,8 +474,11 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)
 		if (!win_dep) {
 			m -= (new_sample >> 3);
 			new_sample += m;
-		} else if (m < new_sample)
-			new_sample = m << 3;
+		} else {
+			m <<= 3;
+			if (m < new_sample)
+				new_sample = m;
+		}
 	} else {
 		/* No previous measure. */
 		new_sample = m << 3;
-- 
1.7.7.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-10 21:24 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-10 17:59 [PATCH] tcp: fix tcp_rcv_rtt_update() use of an unscaled RTT sample Neal Cardwell
2012-04-10 18:45 ` Eric Dumazet
2012-04-10 18:47 ` David Miller
2012-04-10 20:46   ` Dave Taht
2012-04-10 21:07     ` David Miller
2012-04-10 21:11       ` Eric Dumazet
2012-04-10 21:16         ` David Miller
2012-04-10 21:22           ` Eric Dumazet
2012-04-10 21:24             ` Dave Taht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.