diff options
| author | Kuniyuki Iwashima <kuniyu@amazon.com> | 2025-05-19 13:57:55 -0700 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2025-05-23 10:24:18 +0100 |
| commit | ae4f2f59e1f9c7c9cab1641a3c9645e587f0bc72 (patch) | |
| tree | 312fb2dd1cdc980a88eeea8fb45b744b5ffda06a /tools/testing | |
| parent | scm: Move scm_recv() from scm.h to scm.c. (diff) | |
| download | linux-ae4f2f59e1f9c7c9cab1641a3c9645e587f0bc72.tar.gz 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 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/setget_sockopt.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/setget_sockopt.c b/tools/testing/selftests/bpf/progs/setget_sockopt.c index 0107a24b7522..d330b1511979 100644 --- a/tools/testing/selftests/bpf/progs/setget_sockopt.c +++ b/tools/testing/selftests/bpf/progs/setget_sockopt.c @@ -83,6 +83,14 @@ struct loop_ctx { struct sock *sk; }; +static bool sk_is_tcp(struct sock *sk) +{ + return (sk->__sk_common.skc_family == AF_INET || + sk->__sk_common.skc_family == AF_INET6) && + sk->sk_type == SOCK_STREAM && + sk->sk_protocol == IPPROTO_TCP; +} + static int bpf_test_sockopt_flip(void *ctx, struct sock *sk, const struct sockopt_test *t, int level) @@ -91,6 +99,9 @@ static int bpf_test_sockopt_flip(void *ctx, struct sock *sk, opt = t->opt; + if (opt == SO_TXREHASH && !sk_is_tcp(sk)) + return 0; + if (bpf_getsockopt(ctx, level, opt, &old, sizeof(old))) return 1; /* kernel initialized txrehash to 255 */ |
