提交 03b293dc 编写于 作者: E Eric Dumazet 提交者: Yang Yingliang

tcp: adjust rto_base in retransmits_timed_out()

mainline inclusion
from mainline-v5.4-rc2
commit 3256a2d6
category: bugfix
bugzilla:
https://gitee.com/openeuler/kernel/issues/I4AFRJ?from=project-issue
CVE: NA

------------------------------------------------------------

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: a41e8a88 ("tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state")
Signed-off-by: NEric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Marek Majkowski <marek@cloudflare.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
Conflicts:
        net/ipv4/tcp_timer.c
Signed-off-by: Jiazhenyuan <jiazhenyuan@uniontech.com> #openEuler_contributor
Signed-off-by: NLaibin Qiu <qiulaibin@huawei.com>
Reviewed-by: NWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 bc2bc11d
...@@ -195,8 +195,13 @@ static bool retransmits_timed_out(struct sock *sk, ...@@ -195,8 +195,13 @@ static bool retransmits_timed_out(struct sock *sk,
return false; return false;
start_ts = tcp_sk(sk)->retrans_stamp; start_ts = tcp_sk(sk)->retrans_stamp;
if (likely(timeout == 0)) if (likely(timeout == 0)) {
timeout = tcp_model_timeout(sk, boundary, TCP_RTO_MIN); 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 (tcp_time_stamp(tcp_sk(sk)) - start_ts) >= timeout; return (tcp_time_stamp(tcp_sk(sk)) - start_ts) >= timeout;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册