On Mon, Jul 15, 2024 at 11:53:45AM +0200, Alexis Lothoré (eBPF Foundation) wrote: > test_xdp_veth.sh tests that XDP return codes work as expected, by bringing > up multiple veth pairs isolated in different namespaces, attaching specific > xdp programs to each interface, and ensuring that the whole chain allows to > ping one end interface from the first one. The test runs well but is > currently not integrated in test_progs, which prevents it from being run > automatically in the CI infrastructure. > > Rewrite it as a C test relying on libbpf to allow running it in the CI > infrastructure. The new code brings up the same network infrastructure and > reuses the same eBPF programs as test_xdp_veth.sh, for which skeletons are > already generated by the bpf tests makefile. > > Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@xxxxxxxxxxx> > --- > The new code has been tested in an aarch64 qemu instance: > Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED > > I have also checked that some minor alterations in the network > configuration (altering the redirect map, or not loading one of the xdp > programs) make the test fail. > > On my testing setup, the test takes a bit more than 3 seconds to run on > average. > > Changes in v2: > - fix many formatting issues raised by checkpatch > - use static namespaces instead of random ones > - use SYS_NOFAIL instead of snprintf() + system () > - squashed the new test addition patch and the old test removal patch > --- > tools/testing/selftests/bpf/Makefile | 1 - > .../selftests/bpf/prog_tests/test_xdp_veth.c | 211 +++++++++++++++++++++ > tools/testing/selftests/bpf/test_xdp_veth.sh | 121 ------------ > 3 files changed, 211 insertions(+), 122 deletions(-) > > diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile > index a7932bead77d..2864a0dc04d5 100644 > --- a/tools/testing/selftests/bpf/Makefile > +++ b/tools/testing/selftests/bpf/Makefile > @@ -117,7 +117,6 @@ TEST_PROGS := test_kmod.sh \ > test_xdp_redirect.sh \ > test_xdp_redirect_multi.sh \ > test_xdp_meta.sh \ > - test_xdp_veth.sh \ > test_tunnel.sh \ > test_lwt_seg6local.sh \ > test_lirc_mode2.sh \ > diff --git a/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c b/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c > new file mode 100644 > index 000000000000..3ffeb411c131 > --- /dev/null > +++ b/tools/testing/selftests/bpf/prog_tests/test_xdp_veth.c > @@ -0,0 +1,211 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/** > + * Create 3 namespaces with 3 veth peers, and > + * forward packets in-between using native XDP > + * > + * XDP_TX > + * NS1(veth11) NS2(veth22) NS3(veth33) > + * | | | > + * | | | > + * (veth1, (veth2, (veth3, > + * id:111) id:122) id:133) > + * ^ | ^ | ^ | > + * | | XDP_REDIRECT | | XDP_REDIRECT | | > + * | ------------------ ------------------ | > + * ----------------------------------------- > + * XDP_REDIRECT > + */ Hi Alexis, A minor nit from my side. The comment above starts with '/**' but otherwise it is not a Kernel doc. It's probably best if it's a networking-style multi-line comment instead. /* Create 3 namespaces with 3 veth peers, and * ... */ ...