tcp: adjust rto_base in retransmits_timed_out()
Subsystems (3)
PATCH 1/1 tcp: adjust rto_base in retransmits_timed_out()
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.
--- net/ipv4/tcp_timer.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
net/ipv4/tcp_timer.c +7 -2
@@ -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 ; }
Signature · 1 line
2.23.0.444.g18eeb5a265-goog
David Miller
maintainerFrom: Eric Dumazet <[email protected]>
Date: Mon, 30 Sep 2019 15:44:44 -0700
Quoted 8 lines
The cited commit exposed an old
retransmits_timed_out()bug which assumed it could calltcp_model_timeout()withTCP_RTO_MINasrto_basefor all states.But flows in
SYN_SENTorSYN_RECVstate uses a different RTO base (1 sec instead of 200 ms, unless BPF choses another value)
Quoted 5 lines
This caused a reduction of SYN retransmits from 6 to 4 with the default
/proc/sys/net/ipv4/tcp_syn_retriesvalue.Fixes a41e8a88b06e ("tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state")Signed-off-by Eric Dumazet <[email protected]>
Applied and queued up for -stable.