tcp: fix TCP socket rehash stats mis-accounting
authorYuchung Cheng <ycheng@google.com>
Tue, 19 Jan 2021 19:26:19 +0000 (11:26 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jan 2021 10:55:23 +0000 (11:55 +0100)
commita6fc8314dc40c3101a68b5c6bf85472f95c89f89
tree08ba4e35ffb556cb04e5aa436962156b8a455de8
parentfee5a83dfc4af016b8cd957d8bd4e289954588ef
tcp: fix TCP socket rehash stats mis-accounting

commit 9c30ae8398b0813e237bde387d67a7f74ab2db2d upstream.

The previous commit 32efcc06d2a1 ("tcp: export count for rehash attempts")
would mis-account rehashing SNMP and socket stats:

  a. During handshake of an active open, only counts the first
     SYN timeout

  b. After handshake of passive and active open, stop updating
     after (roughly) TCP_RETRIES1 recurring RTOs

  c. After the socket aborts, over count timeout_rehash by 1

This patch fixes this by checking the rehash result from sk_rethink_txhash.

Fixes: 32efcc06d2a1 ("tcp: export count for rehash attempts")
Signed-off-by: Yuchung Cheng <ycheng@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Neal Cardwell <ncardwell@google.com>
Link: https://lore.kernel.org/r/20210119192619.1848270-1-ycheng@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/sock.h
net/ipv4/tcp_input.c
net/ipv4/tcp_timer.c