diff options
author | 2025-05-19 13:57:55 -0700 | |
---|---|---|
committer | 2025-05-23 10:24:18 +0100 | |
commit | ae4f2f59e1f9c7c9cab1641a3c9645e587f0bc72 (patch) | |
tree | 312fb2dd1cdc980a88eeea8fb45b744b5ffda06a /net/core/sock.c | |
parent | scm: Move scm_recv() from scm.h to scm.c. (diff) | |
download | wireguard-linux-ae4f2f59e1f9c7c9cab1641a3c9645e587f0bc72.tar.xz wireguard-linux-ae4f2f59e1f9c7c9cab1641a3c9645e587f0bc72.zip |
tcp: Restrict SO_TXREHASH to TCP socket.
sk->sk_txrehash is only used for TCP.
Let's restrict SO_TXREHASH to TCP to reflect this.
Later, we will make sk_txrehash a part of the union for other
protocol families.
Note that we need to modify BPF selftest not to get/set
SO_TEREHASH for non-TCP sockets.
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/sock.c')
-rw-r--r-- | net/core/sock.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/core/sock.c b/net/core/sock.c index 347ce75482f5..d7d6d3a8efe5 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1276,6 +1276,8 @@ int sk_setsockopt(struct sock *sk, int level, int optname, return 0; } case SO_TXREHASH: + if (!sk_is_tcp(sk)) + return -EOPNOTSUPP; if (val < -1 || val > 1) return -EINVAL; if ((u8)val == SOCK_TXREHASH_DEFAULT) @@ -2102,6 +2104,9 @@ int sk_getsockopt(struct sock *sk, int level, int optname, break; case SO_TXREHASH: + if (!sk_is_tcp(sk)) + return -EOPNOTSUPP; + /* Paired with WRITE_ONCE() in sk_setsockopt() */ v.val = READ_ONCE(sk->sk_txrehash); break; |