netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tcp: adjust rto_base in retransmits_timed_out()
@ 2019-09-30 22:44 Eric Dumazet
  2019-10-02  1:41 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2019-09-30 22:44 UTC (permalink / raw)
  To: David S . Miller
  Cc: netdev, Neal Cardwell, Eric Dumazet, Eric Dumazet, Yuchung Cheng,
	Marek Majkowski

The cited commit exposed an old retransmits_timed_out() bug
which assumed it could call tcp_model_timeout() with
TCP_RTO_MIN as rto_base for all states.

But flows in SYN_SENT or SYN_RECV state uses a different
RTO base (1 sec instead of 200 ms, unless BPF choses
another value)

This caused a reduction of SYN retransmits from 6 to 4 with
the default /proc/sys/net/ipv4/tcp_syn_retries value.

Fixes: a41e8a88b06e ("tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Marek Majkowski <marek@cloudflare.com>
---
 net/ipv4/tcp_timer.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
index 40de2d2364a1eca14c259d77ebed361d17829eb9..05be564414e9b4aad64321e381fc0afa10980190 100644
--- a/net/ipv4/tcp_timer.c
+++ b/net/ipv4/tcp_timer.c
@@ -198,8 +198,13 @@ static bool retransmits_timed_out(struct sock *sk,
 		return false;
 
 	start_ts = tcp_sk(sk)->retrans_stamp;
-	if (likely(timeout == 0))
-		timeout = tcp_model_timeout(sk, boundary, TCP_RTO_MIN);
+	if (likely(timeout == 0)) {
+		unsigned int rto_base = TCP_RTO_MIN;
+
+		if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))
+			rto_base = tcp_timeout_init(sk);
+		timeout = tcp_model_timeout(sk, boundary, rto_base);
+	}
 
 	return (s32)(tcp_time_stamp(tcp_sk(sk)) - start_ts - timeout) >= 0;
 }
-- 
2.23.0.444.g18eeb5a265-goog


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

* Re: [PATCH net] tcp: adjust rto_base in retransmits_timed_out()
  2019-09-30 22:44 [PATCH net] tcp: adjust rto_base in retransmits_timed_out() Eric Dumazet
@ 2019-10-02  1:41 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-10-02  1:41 UTC (permalink / raw)
  To: edumazet; +Cc: netdev, ncardwell, eric.dumazet, ycheng, marek

From: Eric Dumazet <edumazet@google.com>
Date: Mon, 30 Sep 2019 15:44:44 -0700

> The cited commit exposed an old retransmits_timed_out() bug
> which assumed it could call tcp_model_timeout() with
> TCP_RTO_MIN as rto_base for all states.
> 
> But flows in SYN_SENT or SYN_RECV state uses a different
> RTO base (1 sec instead of 200 ms, unless BPF choses
> another value)
> 
> This caused a reduction of SYN retransmits from 6 to 4 with
> the default /proc/sys/net/ipv4/tcp_syn_retries value.
> 
> Fixes: a41e8a88b06e ("tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state")
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2019-10-02  1:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-30 22:44 [PATCH net] tcp: adjust rto_base in retransmits_timed_out() Eric Dumazet
2019-10-02  1:41 ` David Miller

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).