From: Jakub Kicinski <kuba@kernel.org>
Date: Mon, 19 May 2025 07:00:42 -0700
On Thu, 15 May 2025 15:49:08 -0700 Kuniyuki Iwashima wrote:
quoted
The v2 of the BPF LSM extension part will be posted later, once
this series is merged into net-next and has landed in bpf-next.
This breaks existing BPF selftests ever so slightly, I think:
Error: #358 setget_sockopt
Error: #358 setget_sockopt
...
test_udp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: actual 0 < expected 1
test_udp:PASS:nr_bind 0 nsec
test_udp:PASS:start_server 0 nsec
test_udp:FAIL:nr_socket_post_create unexpected nr_socket_post_create: actual 0 < expected 1
https://github.com/kernel-patches/bpf/actions/runs/15112428845/job/42475218987
Thanks for catching!
The test needs to avoid applying SO_TXREHASH to non-TCP sockets,
so I'll fold this into patch 4.
---8<---
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 */
---8<---