* [PATCH net] tcp: fix potential underestimation on rcv_rtt
@ 2017-12-13 0:28 Wei Wang
2017-12-13 15:04 ` Neal Cardwell
2017-12-13 21:03 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Wei Wang @ 2017-12-13 0:28 UTC (permalink / raw)
To: David Miller, netdev; +Cc: Eric Dumazet, Wei Wang
From: Wei Wang <weiwan@google.com>
When ms timestamp is used, current logic uses 1us in
tcp_rcv_rtt_update() when the real rcv_rtt is within 1 - 999us.
This could cause rcv_rtt underestimation.
Fix it by always using a min value of 1ms if ms timestamp is used.
Fixes: 645f4c6f2ebd ("tcp: switch rcv_rtt_est and rcvq_space to high
resolution timestamps")
Signed-off-by: Wei Wang <weiwan@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
net/ipv4/tcp_input.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 9550cc42de2d..45f750e85714 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -508,9 +508,6 @@ static void tcp_rcv_rtt_update(struct tcp_sock *tp, u32 sample, int win_dep)
u32 new_sample = tp->rcv_rtt_est.rtt_us;
long m = sample;
- if (m == 0)
- m = 1;
-
if (new_sample != 0) {
/* If we sample in larger samples in the non-timestamp
* case, we could grossly overestimate the RTT especially
@@ -547,6 +544,8 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp)
if (before(tp->rcv_nxt, tp->rcv_rtt_est.seq))
return;
delta_us = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcv_rtt_est.time);
+ if (!delta_us)
+ delta_us = 1;
tcp_rcv_rtt_update(tp, delta_us, 1);
new_measure:
@@ -563,8 +562,11 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
(TCP_SKB_CB(skb)->end_seq -
TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss)) {
u32 delta = tcp_time_stamp(tp) - tp->rx_opt.rcv_tsecr;
- u32 delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
+ u32 delta_us;
+ if (!delta)
+ delta = 1;
+ delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
tcp_rcv_rtt_update(tp, delta_us, 0);
}
}
--
2.15.1.424.g9478a66081-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] tcp: fix potential underestimation on rcv_rtt
2017-12-13 0:28 [PATCH net] tcp: fix potential underestimation on rcv_rtt Wei Wang
@ 2017-12-13 15:04 ` Neal Cardwell
2017-12-13 21:03 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Neal Cardwell @ 2017-12-13 15:04 UTC (permalink / raw)
To: Wei Wang; +Cc: David Miller, Netdev, Eric Dumazet
On Tue, Dec 12, 2017 at 7:28 PM, Wei Wang <weiwan@google.com> wrote:
> From: Wei Wang <weiwan@google.com>
>
> When ms timestamp is used, current logic uses 1us in
> tcp_rcv_rtt_update() when the real rcv_rtt is within 1 - 999us.
> This could cause rcv_rtt underestimation.
> Fix it by always using a min value of 1ms if ms timestamp is used.
>
> Fixes: 645f4c6f2ebd ("tcp: switch rcv_rtt_est and rcvq_space to high
> resolution timestamps")
>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> ---
Acked-by: Neal Cardwell <ncardwell@google.com>
Thanks!
neal
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] tcp: fix potential underestimation on rcv_rtt
2017-12-13 0:28 [PATCH net] tcp: fix potential underestimation on rcv_rtt Wei Wang
2017-12-13 15:04 ` Neal Cardwell
@ 2017-12-13 21:03 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-12-13 21:03 UTC (permalink / raw)
To: weiwan; +Cc: netdev, edumazet
From: Wei Wang <weiwan@google.com>
Date: Tue, 12 Dec 2017 16:28:58 -0800
> From: Wei Wang <weiwan@google.com>
>
> When ms timestamp is used, current logic uses 1us in
> tcp_rcv_rtt_update() when the real rcv_rtt is within 1 - 999us.
> This could cause rcv_rtt underestimation.
> Fix it by always using a min value of 1ms if ms timestamp is used.
>
> Fixes: 645f4c6f2ebd ("tcp: switch rcv_rtt_est and rcvq_space to high
> resolution timestamps")
>
> Signed-off-by: Wei Wang <weiwan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
Please, in the future, do not wrap long Fixes: tag lines. Also, do
not add an empty line between Fixes: and other tags like Signed-off-by.
That are all tags and belong together as a seamless block of text.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-13 21:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-13 0:28 [PATCH net] tcp: fix potential underestimation on rcv_rtt Wei Wang
2017-12-13 15:04 ` Neal Cardwell
2017-12-13 21:03 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox