Re: [PATCH v4 net-next 0/9] af_unix: Introduce SO_PASSRIGHTS.

From
Kuniyuki Iwashima <hidden>
Date
2025-05-19 17:09:37
Reply to
Jakub Kicinski, 2025-05-19
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<---
Thread (22 messages) 22 messages, 3 authors, last reply 2025-05-19
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help