Linux Kernel Selftest development
 help / color / mirror / Atom feed
From: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@bootlin.com>
To: Alexei Starovoitov <ast@kernel.org>,
	 Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	 Martin KaFai Lau <martin.lau@linux.dev>,
	 Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	 Yonghong Song <yonghong.song@linux.dev>,
	 John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	 Stanislav Fomichev <sdf@fomichev.me>,
	Hao Luo <haoluo@google.com>,  Jiri Olsa <jolsa@kernel.org>,
	Mykola Lysenko <mykolal@fb.com>,  Shuah Khan <shuah@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	 Alexis Lothore <alexis.lothore@bootlin.com>,
	bpf@vger.kernel.org,  linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	 "Bastien Curutchet (eBPF Foundation)"
	<bastien.curutchet@bootlin.com>
Subject: [PATCH bpf-next 06/10] selftests/bpf: test_tunnel: Move ip6erspan tunnel test to test_progs
Date: Thu, 27 Feb 2025 14:24:21 +0100	[thread overview]
Message-ID: <20250227-tunnels-v1-6-33df5c30aa04@bootlin.com> (raw)
In-Reply-To: <20250227-tunnels-v1-0-33df5c30aa04@bootlin.com>

ip6erspan tunnels are tested in the test_tunnel.sh but not in the
test_progs framework.

Add a new test in test_progs to test ip6erspan tunnels. It uses the same
network topology and the same BPF programs than the script.
Remove test_ip6erspan() from the script.

Signed-off-by: Bastien Curutchet (eBPF Foundation) <bastien.curutchet@bootlin.com>
---
 .../testing/selftests/bpf/prog_tests/test_tunnel.c | 41 +++++++++++++++
 tools/testing/selftests/bpf/test_tunnel.sh         | 58 ----------------------
 2 files changed, 41 insertions(+), 58 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
index c45170dc55dd93cdf613cc5798b7df78e3080661..cec0b71b5bdd6d88e7b41b99de081b5370896188 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_tunnel.c
@@ -109,6 +109,9 @@
 #define ERSPAN_TUNL_DEV0 "erspan00"
 #define ERSPAN_TUNL_DEV1 "erspan11"
 
+#define IP6ERSPAN_TUNL_DEV0 "ip6erspan00"
+#define IP6ERSPAN_TUNL_DEV1 "ip6erspan11"
+
 #define PING_ARGS "-i 0.01 -c 3 -w 10 -q"
 
 static int config_device(void)
@@ -926,6 +929,42 @@ static void test_erspan_tunnel(enum erspan_test test)
 	test_tunnel_kern__destroy(skel);
 }
 
+static void test_ip6erspan_tunnel(enum erspan_test test)
+{
+	struct test_tunnel_kern *skel;
+	int set_fd, get_fd;
+	int err;
+
+	skel = test_tunnel_kern__open_and_load();
+	if (!ASSERT_OK_PTR(skel, "test_tunnel_kern__open_and_load"))
+		return;
+
+	switch (test) {
+	case V1:
+		err = add_ipv6_tunnel(IP6ERSPAN_TUNL_DEV0, IP6ERSPAN_TUNL_DEV1,
+				      "ip6erspan", "seq key 2 erspan_ver 1 erspan 123");
+		break;
+	case V2:
+		err = add_ipv6_tunnel(IP6ERSPAN_TUNL_DEV0, IP6ERSPAN_TUNL_DEV1,
+				      "ip6erspan",
+				      "seq key 2 erspan_ver 2 erspan_dir egress erspan_hwid 7");
+		break;
+	}
+	if (!ASSERT_OK(err, "add tunnel"))
+		goto done;
+
+	set_fd = bpf_program__fd(skel->progs.ip4ip6erspan_set_tunnel);
+	get_fd = bpf_program__fd(skel->progs.ip4ip6erspan_get_tunnel);
+	if (generic_attach(IP6ERSPAN_TUNL_DEV1, get_fd, set_fd))
+		goto done;
+
+	ping6_veth0();
+	ping_dev1();
+done:
+	delete_tunnel(IP6ERSPAN_TUNL_DEV0, IP6ERSPAN_TUNL_DEV1);
+	test_tunnel_kern__destroy(skel);
+}
+
 #define RUN_TEST(name, ...)						\
 	({								\
 		if (test__start_subtest(#name)) {			\
@@ -951,6 +990,8 @@ static void *test_tunnel_run_tests(void *arg)
 	RUN_TEST(ip6gre_tunnel, IP6GRETAP);
 	RUN_TEST(erspan_tunnel, V1);
 	RUN_TEST(erspan_tunnel, V2);
+	RUN_TEST(ip6erspan_tunnel, V1);
+	RUN_TEST(ip6erspan_tunnel, V2);
 
 	return NULL;
 }
diff --git a/tools/testing/selftests/bpf/test_tunnel.sh b/tools/testing/selftests/bpf/test_tunnel.sh
index e8e7839fb5b5f69a50a6f1fcd606d1cb6dee3c64..2b486df9724ddfe2fde4e9695274cc8ab0b036d4 100755
--- a/tools/testing/selftests/bpf/test_tunnel.sh
+++ b/tools/testing/selftests/bpf/test_tunnel.sh
@@ -64,36 +64,6 @@ config_device()
 	ip addr add dev veth1 172.16.1.200/24
 }
 
-add_ip6erspan_tunnel()
-{
-
-	# assign ipv6 address
-	ip netns exec at_ns0 ip addr add ::11/96 dev veth0
-	ip netns exec at_ns0 ip link set dev veth0 up
-	ip addr add dev veth1 ::22/96
-	ip link set dev veth1 up
-
-	# at_ns0 namespace
-	if [ "$1" == "v1" ]; then
-		ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type $TYPE seq key 2 \
-		local ::11 remote ::22 \
-		erspan_ver 1 erspan 123
-	else
-		ip netns exec at_ns0 \
-		ip link add dev $DEV_NS type $TYPE seq key 2 \
-		local ::11 remote ::22 \
-		erspan_ver 2 erspan_dir egress erspan_hwid 7
-	fi
-	ip netns exec at_ns0 ip addr add dev $DEV_NS 10.1.1.100/24
-	ip netns exec at_ns0 ip link set dev $DEV_NS up
-
-	# root namespace
-	ip link add dev $DEV type $TYPE external
-	ip addr add dev $DEV 10.1.1.200/24
-	ip link set dev $DEV up
-}
-
 add_geneve_tunnel()
 {
 	# at_ns0 namespace
@@ -166,29 +136,6 @@ add_ip6tnl_tunnel()
 	ip link set dev $DEV up
 }
 
-test_ip6erspan()
-{
-	TYPE=ip6erspan
-	DEV_NS=ip6erspan00
-	DEV=ip6erspan11
-	ret=0
-
-	check $TYPE
-	config_device
-	add_ip6erspan_tunnel $1
-	attach_bpf $DEV ip4ip6erspan_set_tunnel ip4ip6erspan_get_tunnel
-	ping6 $PING_ARG ::11
-	ip netns exec at_ns0 ping $PING_ARG 10.1.1.200
-	check_err $?
-	cleanup
-
-	if [ $ret -ne 0 ]; then
-                echo -e ${RED}"FAIL: $TYPE"${NC}
-                return 1
-        fi
-        echo -e ${GREEN}"PASS: $TYPE"${NC}
-}
-
 test_geneve()
 {
 	TYPE=geneve
@@ -341,7 +288,6 @@ cleanup()
 	ip link del ip6ip6tnl11 2> /dev/null
 	ip link del geneve11 2> /dev/null
 	ip link del ip6geneve11 2> /dev/null
-	ip link del ip6erspan11 2> /dev/null
 }
 
 cleanup_exit()
@@ -378,10 +324,6 @@ bpf_tunnel_test()
 {
 	local errors=0
 
-	echo "Testing IP6ERSPAN tunnel..."
-	test_ip6erspan v2
-	errors=$(( $errors + $? ))
-
 	echo "Testing GENEVE tunnel..."
 	test_geneve
 	errors=$(( $errors + $? ))

-- 
2.48.1


  parent reply	other threads:[~2025-02-27 13:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 13:24 [PATCH bpf-next 00/10] selftests/bpf: Migrate test_tunnel.sh to test_progs Bastien Curutchet (eBPF Foundation)
2025-02-27 13:24 ` [PATCH bpf-next 01/10] selftests/bpf: test_tunnel: Add generic_attach* helpers Bastien Curutchet (eBPF Foundation)
2025-02-27 22:08   ` Stanislav Fomichev
2025-02-28  8:13     ` Bastien Curutchet
2025-02-27 13:24 ` [PATCH bpf-next 02/10] selftests/bpf: test_tunnel: Add ping helpers Bastien Curutchet (eBPF Foundation)
2025-02-27 22:10   ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 03/10] selftests/bpf: test_tunnel: Move gre tunnel test to test_progs Bastien Curutchet (eBPF Foundation)
2025-02-27 22:17   ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 04/10] selftests/bpf: test_tunnel: Move ip6gre " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:18   ` Stanislav Fomichev
2025-02-28  8:15     ` Bastien Curutchet
2025-02-27 13:24 ` [PATCH bpf-next 05/10] selftests/bpf: test_tunnel: Move erspan tunnel tests " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:19   ` Stanislav Fomichev
2025-02-27 13:24 ` Bastien Curutchet (eBPF Foundation) [this message]
2025-02-27 22:20   ` [PATCH bpf-next 06/10] selftests/bpf: test_tunnel: Move ip6erspan tunnel test " Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 07/10] selftests/bpf: test_tunnel: Move geneve " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:21   ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 08/10] selftests/bpf: test_tunnel: Move ip6geneve " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:21   ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 09/10] selftests/bpf: test_tunnel: Move ip6tnl tunnel tests " Bastien Curutchet (eBPF Foundation)
2025-02-27 22:22   ` Stanislav Fomichev
2025-02-27 13:24 ` [PATCH bpf-next 10/10] selftests/bpf: test_tunnel: Remove test_tunnel.sh Bastien Curutchet (eBPF Foundation)
2025-02-27 22:22   ` Stanislav Fomichev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250227-tunnels-v1-6-33df5c30aa04@bootlin.com \
    --to=bastien.curutchet@bootlin.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=mykolal@fb.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox