All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF
@ 2026-08-15 12:50 Ricardo B. Marlière (SUSE)
  2026-08-15 12:50 ` [PATCH 7.1.y v2 1/2] selftests/bpf: Ensure UDP sockets are bound Ricardo B. Marlière (SUSE)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-15 12:50 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, sashal, gregkh
  Cc: linux-kselftest, linux-kernel, stable,
	Ricardo B. Marlière (SUSE), Michal Luczaj, Kuniyuki Iwashima,
	Jakub Sitnicki

Hi,

Please consider merging the following patches, found through openSUSE CI,
for test_progs (subtests sockmap_basic and sockmap_listen):

https://openqa.opensuse.org/tests/6159071/logfile?filename=test_progs.tap.txt#line-4034
https://openqa.opensuse.org/tests/6159071/logfile?filename=test_progs.tap.txt#line-4212

Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
---
Changes in v2:
- Corrected upstream refs
- Link to v1: https://patch.msgid.link/20260813-7-1-y-selftests-bpf-udp_xsk-v1-0-cd5c51e7dcec@marliere.net

---
Michal Luczaj (2):
      selftests/bpf: Ensure UDP sockets are bound
      selftests/bpf: Adapt sockmap update error handling

 .../selftests/bpf/prog_tests/sockmap_basic.c        |  6 +++---
 .../selftests/bpf/prog_tests/sockmap_listen.c       | 21 +++++++++++----------
 2 files changed, 14 insertions(+), 13 deletions(-)
---
base-commit: e2466b32e02a49318b99520c40b397062c65c84c
change-id: 20260813-7-1-y-selftests-bpf-udp_xsk-04c781561aeb

Best regards,
--  
Ricardo B. Marlière (SUSE) <ricardo@marliere.net>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 7.1.y v2 1/2] selftests/bpf: Ensure UDP sockets are bound
  2026-08-15 12:50 [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Ricardo B. Marlière (SUSE)
@ 2026-08-15 12:50 ` Ricardo B. Marlière (SUSE)
  2026-08-15 12:50 ` [PATCH 7.1.y v2 2/2] selftests/bpf: Adapt sockmap update error handling Ricardo B. Marlière (SUSE)
  2026-08-17  3:25 ` [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-15 12:50 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, sashal, gregkh
  Cc: linux-kselftest, linux-kernel, stable,
	Ricardo B. Marlière (SUSE), Michal Luczaj, Kuniyuki Iwashima,
	Jakub Sitnicki

From: Michal Luczaj <mhal@rbox.co>

[ Upstream commit fe3ff273767ef22fe8a7cb3816f264927c190e50 ]

Update sockmap_basic tests to bind sockets before they are used. This
accommodates the recent change in sockmap that rejects unbound UDP sockets.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20260707-sockmap-lookup-udp-leak-v4-1-f878346f27ab@rbox.co
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
---
 tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
index d2846579285f..b4019d1a5575 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
@@ -807,7 +807,7 @@ static void test_sockmap_many_socket(void)
 		return;
 	}
 
-	udp = xsocket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
+	udp = socket_loopback(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK);
 	if (udp < 0) {
 		close(dgram);
 		close(tcp);
@@ -876,7 +876,7 @@ static void test_sockmap_many_maps(void)
 		return;
 	}
 
-	udp = xsocket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
+	udp = socket_loopback(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK);
 	if (udp < 0) {
 		close(dgram);
 		close(tcp);
@@ -947,7 +947,7 @@ static void test_sockmap_same_sock(void)
 		return;
 	}
 
-	udp = xsocket(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
+	udp = socket_loopback(AF_INET, SOCK_DGRAM | SOCK_NONBLOCK);
 	if (udp < 0) {
 		close(dgram);
 		close(tcp);

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 7.1.y v2 2/2] selftests/bpf: Adapt sockmap update error handling
  2026-08-15 12:50 [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Ricardo B. Marlière (SUSE)
  2026-08-15 12:50 ` [PATCH 7.1.y v2 1/2] selftests/bpf: Ensure UDP sockets are bound Ricardo B. Marlière (SUSE)
@ 2026-08-15 12:50 ` Ricardo B. Marlière (SUSE)
  2026-08-17  3:25 ` [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Ricardo B. Marlière (SUSE) @ 2026-08-15 12:50 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, sashal, gregkh
  Cc: linux-kselftest, linux-kernel, stable,
	Ricardo B. Marlière (SUSE), Michal Luczaj, Kuniyuki Iwashima,
	Jakub Sitnicki

From: Michal Luczaj <mhal@rbox.co>

[ Upstream commit 30581eda4a07ff15db623612cac578e81869e96f ]

Update sockmap_listen to accommodate the recent change in sockmap that
rejects unbound UDP sockets.

TCP: Reject unbound and bound (unless established or listening).
UDP: Accept only bound sockets.

While at it, migrate to ASSERT_* and enforce reverse xmas tree.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20260707-sockmap-lookup-udp-leak-v4-3-f878346f27ab@rbox.co
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Ricardo B. Marlière (SUSE) <ricardo@marliere.net>
---
 .../selftests/bpf/prog_tests/sockmap_listen.c       | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
index cc0c68bab907..1c96a3cf4b97 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
@@ -53,8 +53,8 @@ static void test_insert_opened(struct test_sockmap_listen *skel __always_unused,
 			       int family, int sotype, int mapfd)
 {
 	u32 key = 0;
-	u64 value;
 	int err, s;
+	u64 value;
 
 	s = xsocket(family, sotype, 0);
 	if (s == -1)
@@ -63,11 +63,8 @@ static void test_insert_opened(struct test_sockmap_listen *skel __always_unused,
 	errno = 0;
 	value = s;
 	err = bpf_map_update_elem(mapfd, &key, &value, BPF_NOEXIST);
-	if (sotype == SOCK_STREAM) {
-		if (!err || errno != EOPNOTSUPP)
-			FAIL_ERRNO("map_update: expected EOPNOTSUPP");
-	} else if (err)
-		FAIL_ERRNO("map_update: expected success");
+	ASSERT_ERR(err, "map_update");
+	ASSERT_EQ(errno, EOPNOTSUPP, "errno");
 	xclose(s);
 }
 
@@ -77,8 +74,8 @@ static void test_insert_bound(struct test_sockmap_listen *skel __always_unused,
 	struct sockaddr_storage addr;
 	socklen_t len = 0;
 	u32 key = 0;
-	u64 value;
 	int err, s;
+	u64 value;
 
 	init_addr_loopback(family, &addr, &len);
 
@@ -93,8 +90,12 @@ static void test_insert_bound(struct test_sockmap_listen *skel __always_unused,
 	errno = 0;
 	value = s;
 	err = bpf_map_update_elem(mapfd, &key, &value, BPF_NOEXIST);
-	if (!err || errno != EOPNOTSUPP)
-		FAIL_ERRNO("map_update: expected EOPNOTSUPP");
+	if (sotype == SOCK_STREAM) {
+		ASSERT_ERR(err, "map_update");
+		ASSERT_EQ(errno, EOPNOTSUPP, "errno");
+	} else {
+		ASSERT_OK(err, "map_update");
+	}
 close:
 	xclose(s);
 }
@@ -1289,7 +1290,7 @@ static void test_ops(struct test_sockmap_listen *skel, struct bpf_map *map,
 		/* insert */
 		TEST(test_insert_invalid),
 		TEST(test_insert_opened),
-		TEST(test_insert_bound, SOCK_STREAM),
+		TEST(test_insert_bound),
 		TEST(test_insert),
 		/* delete */
 		TEST(test_delete_after_insert),

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF
  2026-08-15 12:50 [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Ricardo B. Marlière (SUSE)
  2026-08-15 12:50 ` [PATCH 7.1.y v2 1/2] selftests/bpf: Ensure UDP sockets are bound Ricardo B. Marlière (SUSE)
  2026-08-15 12:50 ` [PATCH 7.1.y v2 2/2] selftests/bpf: Adapt sockmap update error handling Ricardo B. Marlière (SUSE)
@ 2026-08-17  3:25 ` Sasha Levin
  2 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2026-08-17  3:25 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Martin KaFai Lau, Eduard Zingerman, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, gregkh
  Cc: Sasha Levin, linux-kselftest, linux-kernel, stable,
	Ricardo B. Marlière (SUSE), Michal Luczaj, Kuniyuki Iwashima,
	Jakub Sitnicki

> Please consider merging the following patches, found through openSUSE CI,
> for test_progs (subtests sockmap_basic and sockmap_listen):
>
> Changes in v2:
> - Corrected upstream refs

Queued the series for 7.1, thanks.

The kernel-side change these tests follow is released on the older trees too,
so I picked the same fixes up for 6.18, 6.12, 6.6 and 6.1 as well - 6.6 and
6.1 only needed the sockmap update error handling change, and 6.1 also needed
the test_maps.c counterpart.

-- 
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-17  3:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-15 12:50 [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Ricardo B. Marlière (SUSE)
2026-08-15 12:50 ` [PATCH 7.1.y v2 1/2] selftests/bpf: Ensure UDP sockets are bound Ricardo B. Marlière (SUSE)
2026-08-15 12:50 ` [PATCH 7.1.y v2 2/2] selftests/bpf: Adapt sockmap update error handling Ricardo B. Marlière (SUSE)
2026-08-17  3:25 ` [PATCH 7.1.y v2 0/2] selftests: Fixes for BPF Sasha Levin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.