]> git.baikalelectronics.ru Git - kernel.git/commit
tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state
authorEric Dumazet <edumazet@google.com>
Thu, 26 Sep 2019 22:42:51 +0000 (15:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 27 Sep 2019 18:42:24 +0000 (20:42 +0200)
commite6d5a47929fd07c104fa60332dee59802ca13ff5
tree4cb7c743f2425c421a5604ae6232843a4055c949
parentb71f1fd1a0f44b200cb4706cdccf8d69428abd0d
tcp: better handle TCP_USER_TIMEOUT in SYN_SENT state

Yuchung Cheng and Marek Majkowski independently reported a weird
behavior of TCP_USER_TIMEOUT option when used at connect() time.

When the TCP_USER_TIMEOUT is reached, tcp_write_timeout()
believes the flow should live, and the following condition
in tcp_clamp_rto_to_user_timeout() programs one jiffie timers :

    remaining = icsk->icsk_user_timeout - elapsed;
    if (remaining <= 0)
        return 1; /* user timeout has passed; fire ASAP */

This silly situation ends when the max syn rtx count is reached.

This patch makes sure we honor both TCP_SYNCNT and TCP_USER_TIMEOUT,
avoiding these spurious SYN packets.

Fixes: c7f129363144 ("tcp: Add tcp_clamp_rto_to_user_timeout() helper to improve accuracy")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Yuchung Cheng <ycheng@google.com>
Reported-by: Marek Majkowski <marek@cloudflare.com>
Cc: Jon Maxwell <jmaxwell37@gmail.com>
Link: https://marc.info/?l=linux-netdev&m=156940118307949&w=2
Acked-by: Jon Maxwell <jmaxwell37@gmail.com>
Tested-by: Marek Majkowski <marek@cloudflare.com>
Signed-off-by: Marek Majkowski <marek@cloudflare.com>
Acked-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_timer.c