Skip to contentSkip to conversation

selftests/bpf: remove sockmap_ktls disconnect_after_delete test

PATCH In review Ihor Solodrai 3 participants 7 messages Apr 15, 2025 – Apr 16, 2025

Subsystems (5)
lore
Share & tools
lore

Ihor Solodrai

author reviewer
#0 lore raw

PATCH 1/1 selftests/bpf: remove sockmap_ktls disconnect_after_delete test

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI after recent merges from netdev:
* https://github.com/kernel-patches/bpf/actions/runs/14458537639
* https://github.com/kernel-patches/bpf/actions/runs/14457178732

It happens because disconnect has been disabled for TLS [1], and it renders the test case invalid. Remove it from the suite.

[1] https://lore.kernel.org/netdev/[email protected]/

---
 .../selftests/bpf/prog_tests/sockmap_ktls.c   | 68 -------------------
 1 file changed, 68 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c +0 -68
index 2d0796314862..47c0701e0938 100644
@@ -10,72 +10,6 @@
 #define MAX_TEST_NAME 80
 #define TCP_ULP 31
 
-static int tcp_server(int family)
-{
-	int err, s;
-
-	s = socket(family, SOCK_STREAM, 0);
-	if (!ASSERT_GE(s, 0, "socket"))
-		return -1;
-
-	err = listen(s, SOMAXCONN);
-	if (!ASSERT_OK(err, "listen"))
-		return -1;
-
-	return s;
-}
-
-static int disconnect(int fd)
-{
-	struct sockaddr unspec = { AF_UNSPEC };
-
-	return connect(fd, &unspec, sizeof(unspec));
-}
-
-/* Disconnect (unhash) a kTLS socket after removing it from sockmap. */
-static void test_sockmap_ktls_disconnect_after_delete(int family, int map)
-{
-	struct sockaddr_storage addr = {0};
-	socklen_t len = sizeof(addr);
-	int err, cli, srv, zero = 0;
-
-	srv = tcp_server(family);
-	if (srv == -1)
-		return;
-
-	err = getsockname(srv, (struct sockaddr *)&addr, &len);
-	if (!ASSERT_OK(err, "getsockopt"))
-		goto close_srv;
-
-	cli = socket(family, SOCK_STREAM, 0);
-	if (!ASSERT_GE(cli, 0, "socket"))
-		goto close_srv;
-
-	err = connect(cli, (struct sockaddr *)&addr, len);
-	if (!ASSERT_OK(err, "connect"))
-		goto close_cli;
-
-	err = bpf_map_update_elem(map, &zero, &cli, 0);
-	if (!ASSERT_OK(err, "bpf_map_update_elem"))
-		goto close_cli;
-
-	err = setsockopt(cli, IPPROTO_TCP, TCP_ULP, "tls", strlen("tls"));
-	if (!ASSERT_OK(err, "setsockopt(TCP_ULP)"))
-		goto close_cli;
-
-	err = bpf_map_delete_elem(map, &zero);
-	if (!ASSERT_OK(err, "bpf_map_delete_elem"))
-		goto close_cli;
-
-	err = disconnect(cli);
-	ASSERT_OK(err, "disconnect");
-
-close_cli:
-	close(cli);
-close_srv:
-	close(srv);
-}
-
 static void test_sockmap_ktls_update_fails_when_sock_has_ulp(int family, int map)
 {
 	struct sockaddr_storage addr = {};
@@ -154,8 +88,6 @@ static void run_tests(int family, enum bpf_map_type map_type)
 	if (!ASSERT_GE(map, 0, "bpf_map_create"))
 		return;
 
-	if (test__start_subtest(fmt_test_name("disconnect_after_delete", family, map_type)))
-		test_sockmap_ktls_disconnect_after_delete(family, map);
 	if (test__start_subtest(fmt_test_name("update_fails_when_sock_has_ulp", family, map_type)))
 		test_sockmap_ktls_update_fails_when_sock_has_ulp(family, map);
 
Signature · 1 line
2.49.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Ihor Solodrai

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI after recent merges from netdev:
* https://github.com/kernel-patches/bpf/actions/runs/14458537639
* https://github.com/kernel-patches/bpf/actions/runs/14457178732
It happens because disconnect has been disabled for TLS [1], and it renders the test case invalid. Remove it from the suite.
[1] https://lore.kernel.org/netdev/[email protected]/

The original selftest patch used disconnect to re-produce the endless loop caused by tcp_bpf_unhash, which has already been removed.

I hope this doesn't conflict with bpf-next...

Thanks.

author reviewer
#2 lore raw
Quoted 11 lines · Jiayuan Chen
Quoted 9 lines · Ihor Solodrai

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI after recent merges from netdev:
* https://github.com/kernel-patches/bpf/actions/runs/14458537639
* https://github.com/kernel-patches/bpf/actions/runs/14457178732
It happens because disconnect has been disabled for TLS [1], and it renders the test case invalid. Remove it from the suite.
[1] https://lore.kernel.org/netdev/[email protected]/

Quoted 6 lines

The original selftest patch used disconnect to re-produce the endless loop caused by tcp_bpf_unhash, which has already been removed.

I hope this doesn't conflict with bpf-next...

I just tried applying to bpf-next, and it does indeed have a conflict... Although kdiff3 merged it automatically.

What's the right way to resolve this? Send for bpf-next?

From 21ecc409c7e78e52cbb27296b039c13860ace7fa Mon Sep 17 00:00:00 2001
From: Ihor Solodrai <[email protected]>
Date: Tue, 15 Apr 2025 09:22:50 -0700
Subject: [PATCH] selftests/bpf: remove sockmap_ktls disconnect_after_delete
test

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI after recent merges from netdev:
* https://github.com/kernel-patches/bpf/actions/runs/14458537639
* https://github.com/kernel-patches/bpf/actions/runs/14457178732

It happens because disconnect has been disabled for TLS [1], and it renders the test case invalid. Remove it from the suite.

[1] https://lore.kernel.org/netdev/[email protected]/

---
 .../selftests/bpf/prog_tests/sockmap_ktls.c   | 68 -------------------
 1 file changed, 68 deletions(-)
tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c +0 -68
index 49b85c1c7552..3044f54b16d6 100644
@@ -61,72 +61,6 @@ static int create_ktls_pairs(int family, int sotype, int *c, int *p)
 	return 0;
 }
 
-static int tcp_server(int family)
-{
-	int err, s;
-
-	s = socket(family, SOCK_STREAM, 0);
-	if (!ASSERT_GE(s, 0, "socket"))
-		return -1;
-
-	err = listen(s, SOMAXCONN);
-	if (!ASSERT_OK(err, "listen"))
-		return -1;
-
-	return s;
-}
-
-static int disconnect(int fd)
-{
-	struct sockaddr unspec = { AF_UNSPEC };
-
-	return connect(fd, &unspec, sizeof(unspec));
-}
-
-/* Disconnect (unhash) a kTLS socket after removing it from sockmap. */
-static void test_sockmap_ktls_disconnect_after_delete(int family, int map)
-{
-	struct sockaddr_storage addr = {0};
-	socklen_t len = sizeof(addr);
-	int err, cli, srv, zero = 0;
-
-	srv = tcp_server(family);
-	if (srv == -1)
-		return;
-
-	err = getsockname(srv, (struct sockaddr *)&addr, &len);
-	if (!ASSERT_OK(err, "getsockopt"))
-		goto close_srv;
-
-	cli = socket(family, SOCK_STREAM, 0);
-	if (!ASSERT_GE(cli, 0, "socket"))
-		goto close_srv;
-
-	err = connect(cli, (struct sockaddr *)&addr, len);
-	if (!ASSERT_OK(err, "connect"))
-		goto close_cli;
-
-	err = bpf_map_update_elem(map, &zero, &cli, 0);
-	if (!ASSERT_OK(err, "bpf_map_update_elem"))
-		goto close_cli;
-
-	err = setsockopt(cli, IPPROTO_TCP, TCP_ULP, "tls", strlen("tls"));
-	if (!ASSERT_OK(err, "setsockopt(TCP_ULP)"))
-		goto close_cli;
-
-	err = bpf_map_delete_elem(map, &zero);
-	if (!ASSERT_OK(err, "bpf_map_delete_elem"))
-		goto close_cli;
-
-	err = disconnect(cli);
-	ASSERT_OK(err, "disconnect");
-
-close_cli:
-	close(cli);
-close_srv:
-	close(srv);
-}
-
 static void test_sockmap_ktls_update_fails_when_sock_has_ulp(int family, int map)
 {
 	struct sockaddr_storage addr = {};
@@ -314,8 +248,6 @@ static void run_tests(int family, enum bpf_map_type map_type)
 	if (!ASSERT_GE(map, 0, "bpf_map_create"))
 		return;
 
-	if (test__start_subtest(fmt_test_name("disconnect_after_delete", family, map_type)))
-		test_sockmap_ktls_disconnect_after_delete(family, map);
 	if (test__start_subtest(fmt_test_name("update_fails_when_sock_has_ulp", family, map_type)))
 		test_sockmap_ktls_update_fails_when_sock_has_ulp(family, map);
 
Signature · 1 line
2.49.0
Quoted 2 lines

Thanks.

#3 lore raw
Quoted 18 lines · Ihor Solodrai
Quoted 16 lines · Jiayuan Chen
Quoted 9 lines · Ihor Solodrai

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI after recent merges from netdev:
* https://github.com/kernel-patches/bpf/actions/runs/14458537639
* https://github.com/kernel-patches/bpf/actions/runs/14457178732
It happens because disconnect has been disabled for TLS [1], and it renders the test case invalid. Remove it from the suite.
[1] https://lore.kernel.org/netdev/[email protected]/

The original selftest patch used disconnect to re-produce the endless loop caused by tcp_bpf_unhash, which has already been removed.

Quoted 6 lines
Quoted 1 line

I hope this doesn't conflict with bpf-next...

I just tried applying to bpf-next, and it does indeed have a conflict... Although kdiff3 merged it automatically.

What's the right way to resolve this? Send for bpf-next?

What commit in bpf-next does it conflict with ?

In general, avoiding merge conflicts is preferred.

author reviewer
#4 lore raw
Quoted 21 lines · Alexei Starovoitov
Quoted 20 lines · Ihor Solodrai
Quoted 17 lines · Jiayuan Chen
Quoted 9 lines · Ihor Solodrai

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI after recent merges from netdev:
* https://github.com/kernel-patches/bpf/actions/runs/14458537639
* https://github.com/kernel-patches/bpf/actions/runs/14457178732
It happens because disconnect has been disabled for TLS [1], and it renders the test case invalid. Remove it from the suite.
[1] https://lore.kernel.org/netdev/[email protected]/

The original selftest patch used disconnect to re-produce the endless loop caused by tcp_bpf_unhash, which has already been removed.

I hope this doesn't conflict with bpf-next...

Quoted 8 lines
Quoted 4 lines

I just tried applying to bpf-next, and it does indeed have a conflict... Although kdiff3 merged it automatically.

What's the right way to resolve this? Send for bpf-next?

What commit in bpf-next does it conflict with ?

In general, avoiding merge conflicts is preferred.

https://web.git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=05ebde1bcb50a71cd56d8edd3008f53a781146e9
https://lore.kernel.org/bpf/[email protected]/

It adds tests in the same file. The code to delete simply moved.

I think we can avoid conflict by applying 05ebde1bcb50 to bpf first, if that's an option (it might depend on other changes, idk). Then the version of the patch for bpf-next would apply to both trees.

If not, then apply only to bpf-next, and disable the test on CI?

#5 lore raw
Quoted 42 lines · Ihor Solodrai
Quoted 32 lines · Alexei Starovoitov
Quoted 3 lines · Ihor Solodrai

On 4/15/25 9:53 AM, Jiayuan Chen wrote:

April 16, 2025 at 24:33, "Ihor Solodrai" <[email protected]> wrote:

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI

after recent merges from netdev:

* https://github.com/kernel-patches/bpf/actions/runs/14458537639

* https://github.com/kernel-patches/bpf/actions/runs/14457178732

It happens because disconnect has been disabled for TLS [1], and it

renders the test case invalid. Remove it from the suite.

[1] https://lore.kernel.org/netdev/[email protected]/

The original selftest patch used disconnect to re-produce the endless loop caused by tcp_bpf_unhash, which has already been removed. I hope this doesn't conflict with bpf-next...

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

I just tried applying to bpf-next, and it does indeed have a
conflict... Although kdiff3 merged it automatically. What's the right way to resolve this? Send for bpf-next?

What commit in bpf-next does it conflict with ? In general, avoiding merge conflicts is preferred.

Quoted 8 lines

https://web.git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=05ebde1bcb50a71cd56d8edd3008f53a781146e9
https://lore.kernel.org/bpf/[email protected]/
It adds tests in the same file. The code to delete simply moved. I think we can avoid conflict by applying 05ebde1bcb50 to bpf first, if that's an option (it might depend on other changes, idk). Then the version of the patch for bpf-next would apply to both trees. If not, then apply only to bpf-next, and disable the test on CI?

I'm not sure whether we can cherry-pick the commit to bpf branch.

I believe it would be more convenient for the maintainer to merge the patch that only removes 'ASSERT_OK(err, "disconnect");', as this change will not introduce conflicts with the bpf-next branch.
Once the bpf branch is merged into bpf-next, you can then remove the entire function in the bpf-next branch.

#6 lore raw
Quoted 57 lines · Jiayuan Chen
Quoted 42 lines · Ihor Solodrai
Quoted 32 lines · Alexei Starovoitov
Quoted 3 lines · Ihor Solodrai

On 4/15/25 9:53 AM, Jiayuan Chen wrote:

April 16, 2025 at 24:33, "Ihor Solodrai" <[email protected]> wrote:

"sockmap_ktls disconnect_after_delete" test has been failing on BPF CI

after recent merges from netdev:

* https://github.com/kernel-patches/bpf/actions/runs/14458537639

* https://github.com/kernel-patches/bpf/actions/runs/14457178732

It happens because disconnect has been disabled for TLS [1], and it

renders the test case invalid. Remove it from the suite.

[1] https://lore.kernel.org/netdev/[email protected]/

The original selftest patch used disconnect to re-produce the endless loop caused by tcp_bpf_unhash, which has already been removed. I hope this doesn't conflict with bpf-next...

Quoted 1 line
Quoted 7 lines
Quoted 4 lines

I just tried applying to bpf-next, and it does indeed have a
conflict... Although kdiff3 merged it automatically. What's the right way to resolve this? Send for bpf-next?

What commit in bpf-next does it conflict with ? In general, avoiding merge conflicts is preferred.

Quoted 8 lines

https://web.git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/commit/?id=05ebde1bcb50a71cd56d8edd3008f53a781146e9
https://lore.kernel.org/bpf/[email protected]/
It adds tests in the same file. The code to delete simply moved. I think we can avoid conflict by applying 05ebde1bcb50 to bpf first, if that's an option (it might depend on other changes, idk). Then the version of the patch for bpf-next would apply to both trees. If not, then apply only to bpf-next, and disable the test on CI?

Quoted 7 lines

I'm not sure whether we can cherry-pick the commit to bpf branch.

I believe it would be more convenient for the maintainer to merge the patch that only removes 'ASSERT_OK(err, "disconnect");', as this change will not introduce conflicts with the bpf-next branch.
Once the bpf branch is merged into bpf-next, you can then remove the entire function in the bpf-next branch.

Let's do that. Pls prepare such single-liner against bpf tree.