aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/net/core/sock.c
diff options
context:
space:
mode:
authorKevin Yang <yyd@google.com>2023-02-07 02:08:20 +0000
committerDavid S. Miller <davem@davemloft.net>2023-02-08 09:07:11 +0000
commitc11204c78d6966c5bda6dd05c3ac5cbb193f93e3 (patch)
tree54f64528a4dd356ee84f12c30f5174c41577b4d7 /net/core/sock.c
parentnet: ethernet: mtk_eth_soc: fix wrong parameters order in __xdp_rxq_info_reg() (diff)
downloadwireguard-linux-c11204c78d6966c5bda6dd05c3ac5cbb193f93e3.tar.xz
wireguard-linux-c11204c78d6966c5bda6dd05c3ac5cbb193f93e3.zip
txhash: fix sk->sk_txrehash default
This code fix a bug that sk->sk_txrehash gets its default enable value from sysctl_txrehash only when the socket is a TCP listener. We should have sysctl_txrehash to set the default sk->sk_txrehash, no matter TCP, nor listerner/connector. Tested by following packetdrill: 0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 +0 socket(..., SOCK_DGRAM, IPPROTO_UDP) = 4 // SO_TXREHASH == 74, default to sysctl_txrehash == 1 +0 getsockopt(3, SOL_SOCKET, 74, [1], [4]) = 0 +0 getsockopt(4, SOL_SOCKET, 74, [1], [4]) = 0 Fixes: 26859240e4ee ("txhash: Add socket option to control TX hash rethink behavior") Signed-off-by: Kevin Yang <yyd@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r--net/core/sock.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/core/sock.c b/net/core/sock.c
index f954d5893e79..6f27c24016fe 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1531,6 +1531,8 @@ set_sndbuf:
ret = -EINVAL;
break;
}
+ if ((u8)val == SOCK_TXREHASH_DEFAULT)
+ val = READ_ONCE(sock_net(sk)->core.sysctl_txrehash);
/* Paired with READ_ONCE() in tcp_rtx_synack() */
WRITE_ONCE(sk->sk_txrehash, (u8)val);
break;
@@ -3451,7 +3453,6 @@ void sock_init_data(struct socket *sock, struct sock *sk)
sk->sk_pacing_rate = ~0UL;
WRITE_ONCE(sk->sk_pacing_shift, 10);
sk->sk_incoming_cpu = -1;
- sk->sk_txrehash = SOCK_TXREHASH_DEFAULT;
sk_rx_queue_clear(sk);
/*