Subject: Re: [PATCH bpf] selftests/bpf: remove sockmap_ktls disconnect_after_delete test

From: "Ihor Solodrai" <[email-masked]>
Date: Tue, 15 Apr 2025 17:00:54 +0000

On 4/15/25 9:53 AM, Jiayuan Chen wrote:
> April 16, 2025 at 24:33, "Ihor Solodrai" <[email-masked]> 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-masked]/
>> Signed-off-by: Ihor Solodrai <[email-masked]>
>
> Reviewed-by: Jiayuan Chen <[email-masked]>
>
> 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-masked]>
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-masked]/

Signed-off-by: Ihor Solodrai <[email-masked]>
---
 .../selftests/bpf/prog_tests/sockmap_ktls.c   | 68 -------------------
 1 file changed, 68 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
index 49b85c1c7552..3044f54b16d6 100644
--- a/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
+++ b/tools/testing/selftests/bpf/prog_tests/sockmap_ktls.c
@@ -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);
 
-- 
2.49.0

> Thanks.