Skip to content

Commit 673f813

Browse files
edumazetgregkh
authored andcommitted
tcp: adjust rto_base in retransmits_timed_out()
[ Upstream commit 3256a2d ] 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: a41e8a8 ("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> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent ff05232 commit 673f813

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

‎net/ipv4/tcp_timer.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,13 @@ static bool retransmits_timed_out(struct sock *sk,
198198
return false;
199199

200200
start_ts = tcp_sk(sk)->retrans_stamp;
201-
if (likely(timeout == 0))
202-
timeout = tcp_model_timeout(sk, boundary, TCP_RTO_MIN);
201+
if (likely(timeout == 0)) {
202+
unsigned int rto_base = TCP_RTO_MIN;
203+
204+
if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV))
205+
rto_base = tcp_timeout_init(sk);
206+
timeout = tcp_model_timeout(sk, boundary, rto_base);
207+
}
203208

204209
return (s32)(tcp_time_stamp(tcp_sk(sk)) - start_ts - timeout) >= 0;
205210
}

0 commit comments

Comments
 (0)