BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/2] Enable INET_XFRM_TUNNEL in config
@ 2024-06-11  2:27 Geliang Tang
  2024-06-11  2:27 ` [PATCH bpf-next v2 1/2] selftests/bpf: " Geliang Tang
  2024-06-11  2:27 ` [PATCH bpf-next v2 2/2] selftests/bpf: Close netns in error paths in test_tunnel Geliang Tang
  0 siblings, 2 replies; 3+ messages in thread
From: Geliang Tang @ 2024-06-11  2:27 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Shuah Khan
  Cc: Geliang Tang, bpf, linux-kselftest

From: Geliang Tang <tanggeliang@kylinos.cn>

v2:
 - resend patch 1.
 - another fix for test_tunnel.

Geliang Tang (2):
  selftests/bpf: Enable INET_XFRM_TUNNEL in config
  selftests/bpf: Close netns in error paths in test_tunnel

 tools/testing/selftests/bpf/config            |  4 +++
 .../selftests/bpf/prog_tests/test_tunnel.c    | 27 +++++++++++++------
 2 files changed, 23 insertions(+), 8 deletions(-)

-- 
2.43.0


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

* [PATCH bpf-next v2 1/2] selftests/bpf: Enable INET_XFRM_TUNNEL in config
  2024-06-11  2:27 [PATCH bpf-next v2 0/2] Enable INET_XFRM_TUNNEL in config Geliang Tang
@ 2024-06-11  2:27 ` Geliang Tang
  2024-06-11  2:27 ` [PATCH bpf-next v2 2/2] selftests/bpf: Close netns in error paths in test_tunnel Geliang Tang
  1 sibling, 0 replies; 3+ messages in thread
From: Geliang Tang @ 2024-06-11  2:27 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Shuah Khan
  Cc: Geliang Tang, bpf, linux-kselftest

From: Geliang Tang <tanggeliang@kylinos.cn>

The kconfigs CONFIG_INET_XFRM_TUNNEL and CONFIG_INET6_XFRM_TUNNEL are
needed by test_tunnel tests. This patch enables them together with the
dependent kconfigs CONFIG_INET_IPCOMP and CONFIG_INET6_IPCOMP.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/bpf/config | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/bpf/config b/tools/testing/selftests/bpf/config
index 2fb16da78dce..de358b51a05a 100644
--- a/tools/testing/selftests/bpf/config
+++ b/tools/testing/selftests/bpf/config
@@ -96,3 +96,7 @@ CONFIG_XDP_SOCKETS=y
 CONFIG_XFRM_INTERFACE=y
 CONFIG_TCP_CONG_DCTCP=y
 CONFIG_TCP_CONG_BBR=y
+CONFIG_INET_IPCOMP=y
+CONFIG_INET_XFRM_TUNNEL=y
+CONFIG_INET6_IPCOMP=y
+CONFIG_INET6_XFRM_TUNNEL=y
-- 
2.43.0


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

* [PATCH bpf-next v2 2/2] selftests/bpf: Close netns in error paths in test_tunnel
  2024-06-11  2:27 [PATCH bpf-next v2 0/2] Enable INET_XFRM_TUNNEL in config Geliang Tang
  2024-06-11  2:27 ` [PATCH bpf-next v2 1/2] selftests/bpf: " Geliang Tang
@ 2024-06-11  2:27 ` Geliang Tang
  1 sibling, 0 replies; 3+ messages in thread
From: Geliang Tang @ 2024-06-11  2:27 UTC (permalink / raw)
  To: Andrii Nakryiko, Eduard Zingerman, Mykola Lysenko,
	Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu,
	Yonghong Song, John Fastabend, KP Singh, Stanislav Fomichev,
	Hao Luo, Jiri Olsa, Shuah Khan
  Cc: Geliang Tang, bpf, linux-kselftest

From: Geliang Tang <tanggeliang@kylinos.cn>

netns created by open_netns() should be closed in error paths in
test_vxlan_tunnel(), test_ip6vxlan_tunnel() and test_ipip_tunnel().

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../selftests/bpf/prog_tests/test_tunnel.c    | 27 +++++++++++++------
 1 file changed, 19 insertions(+), 8 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
index cec746e77cd3..f19e8177bcec 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
@@ -448,14 +448,20 @@ static void test_vxlan_tunnel(void)
 	if (!ASSERT_OK_PTR(nstoken, "setns src"))
 		goto done;
 	ifindex = if_nametoindex(VXLAN_TUNL_DEV0);
-	if (!ASSERT_NEQ(ifindex, 0, "vxlan00 ifindex"))
+	if (!ASSERT_NEQ(ifindex, 0, "vxlan00 ifindex")) {
+		close_netns(nstoken);
 		goto done;
+	}
 	tc_hook.ifindex = ifindex;
 	set_dst_prog_fd = bpf_program__fd(skel->progs.vxlan_set_tunnel_dst);
-	if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd"))
+	if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd")) {
+		close_netns(nstoken);
 		goto done;
-	if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd))
+	}
+	if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd)) {
+		close_netns(nstoken);
 		goto done;
+	}
 	close_netns(nstoken);
 
 	/* use veth1 ip 2 as tunnel source ip */
@@ -521,14 +527,20 @@ static void test_ip6vxlan_tunnel(void)
 	if (!ASSERT_OK_PTR(nstoken, "setns src"))
 		goto done;
 	ifindex = if_nametoindex(IP6VXLAN_TUNL_DEV0);
-	if (!ASSERT_NEQ(ifindex, 0, "ip6vxlan00 ifindex"))
+	if (!ASSERT_NEQ(ifindex, 0, "ip6vxlan00 ifindex")) {
+		close_netns(nstoken);
 		goto done;
+	}
 	tc_hook.ifindex = ifindex;
 	set_dst_prog_fd = bpf_program__fd(skel->progs.ip6vxlan_set_tunnel_dst);
-	if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd"))
+	if (!ASSERT_GE(set_dst_prog_fd, 0, "bpf_program__fd")) {
+		close_netns(nstoken);
 		goto done;
-	if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd))
+	}
+	if (attach_tc_prog(&tc_hook, -1, set_dst_prog_fd)) {
+		close_netns(nstoken);
 		goto done;
+	}
 	close_netns(nstoken);
 
 	/* use veth1 ip 2 as tunnel source ip */
@@ -615,8 +627,7 @@ static void test_ipip_tunnel(enum ipip_encap encap)
 	if (!ASSERT_OK_PTR(nstoken, "setns"))
 		goto done;
 	err = test_ping(AF_INET, IP4_ADDR_TUNL_DEV1);
-	if (!ASSERT_OK(err, "test_ping"))
-		goto done;
+	ASSERT_OK(err, "test_ping");
 	close_netns(nstoken);
 
 done:
-- 
2.43.0


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

end of thread, other threads:[~2024-06-11  2:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-11  2:27 [PATCH bpf-next v2 0/2] Enable INET_XFRM_TUNNEL in config Geliang Tang
2024-06-11  2:27 ` [PATCH bpf-next v2 1/2] selftests/bpf: " Geliang Tang
2024-06-11  2:27 ` [PATCH bpf-next v2 2/2] selftests/bpf: Close netns in error paths in test_tunnel Geliang Tang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox