]> git.baikalelectronics.ru Git - kernel.git/commitdiff
tcp: Change SYN ACK retransmit behaviour to account for rehash
authorAkhmat Karakotov <hmukos@yandex-team.ru>
Mon, 31 Jan 2022 13:31:25 +0000 (16:31 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 31 Jan 2022 15:05:25 +0000 (15:05 +0000)
Disabling rehash behavior did not affect SYN ACK retransmits because hash
was forcefully changed bypassing the sk_rethink_hash function. This patch
adds a condition which checks for rehash mode before resetting hash.

Signed-off-by: Akhmat Karakotov <hmukos@yandex-team.ru>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/sock.c
net/ipv4/tcp_output.c

index 5e711b42898fcaa8e5d60e909d6accf67902def3..d6804685f17f0674b450f4368fbfaedd98fae7c9 100644 (file)
@@ -1452,7 +1452,8 @@ set_sndbuf:
                        ret = -EINVAL;
                        break;
                }
-               sk->sk_txrehash = (u8)val;
+               /* Paired with READ_ONCE() in tcp_rtx_synack() */
+               WRITE_ONCE(sk->sk_txrehash, (u8)val);
                break;
 
        default:
index 11c06b9db80158ef581f0c608c912bbef6759cde..e76bf1e9251e87ab62afdab4fe491d6814b47e5b 100644 (file)
@@ -4092,7 +4092,9 @@ int tcp_rtx_synack(const struct sock *sk, struct request_sock *req)
        struct flowi fl;
        int res;
 
-       tcp_rsk(req)->txhash = net_tx_rndhash();
+       /* Paired with WRITE_ONCE() in sock_setsockopt() */
+       if (READ_ONCE(sk->sk_txrehash) == SOCK_TXREHASH_ENABLED)
+               tcp_rsk(req)->txhash = net_tx_rndhash();
        res = af_ops->send_synack(sk, NULL, &fl, req, NULL, TCP_SYNACK_NORMAL,
                                  NULL);
        if (!res) {