Skip to contentSkip to conversation

selftests/bpf: convert test_xdp_features.sh to test_progs

PATCH Superseded Alexis Lothoré (eBPF Foundation) 5 participants 13 messages Sep 10, 2024 – Oct 4, 2024

Subsystems (6)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 selftests/bpf: convert test_xdp_features.sh to test_progs

test_xdp_features.sh is a shell script allowing to test that xdp features advertised by an interface are indeed delivered. The test works by starting two instance of the same program, both attaching specific xdp programs to each side of a veth link, and then make those programs manage packets and collect stats to check whether tested XDP feature is indeed delivered or not. However this test is not integrated in test_progs framework and so can not run automatically in CI.

Rewrite test_xdp_features to integrate it in test_progs so it can run automatically in CI. The main changes brought by the rewrite are the following:
- instead of running to separated processes (each one managing either the tester veth or the DUT vet), run a single process
- slightly change testing direction (v0 is the tester in local namespace, v1 is the Device Under Test in remote namespace)
- group all tests previously managed by test_xdp_features as subtests (one per tested XDP feature). As a consequence, run only once some steps instead of once per subtest (eg: starting/stopping the udp server). On the contrary, make sure that each subtest properly cleans up its state (ie detach xdp programs, reset test stats, etc)
- since there is now a single process, get rid of the "control" tcp channel used to configure DUT. Configuring the DUT now only consists in switching to DUT network namespace and run the relevant commands
- since there is no more control channel, get rid of TLVs, keep only the CMD_ECHO packet type, and set it as a magic
- simplify network setup: use only ipv6 instead of both ipv4 and ipv6, force static neighbours instead of waiting for autoconfiguration, do not force gro (fetch xdp features only once xdp programs are loaded instead)

The existing XDP programs are reused, with some minor changes:
- tester and dut stats maps are converted to global variables for easier usage
- programs do not use TLV struct anymore but the magic replacing the echo command
- avoid to accidentally make tests pass: drop packets instead of forwarding them to userspace when they do not match the expected payload
- make sure to perform host <-> network endianness conversion on constants rather than packet parts

---
Changes in v2:
- fix endianness management in userspace packet parsing (call htonl on constant rather than packet part)

The xdp_features rewrite has been tested in a x86_64 qemu environment on my machine and in CI. In my environment, the test takes a bit less than 2s to execute.

  # ./test_progs -a xdp_features
  #561/1   xdp_features/XDP_PASS:OK
  #561/2   xdp_features/XDP_DROP:OK
  #561/3   xdp_features/XDP_ABORTED:OK
  #561/4   xdp_features/XDP_TX:OK
  #561/5   xdp_features/XDP_REDIRECT:OK
  #561/6   xdp_features/XDP_NDO_XMIT:OK
  #561     xdp_features:OK
  Summary: 1/6 PASSED, 0 SKIPPED, 0 FAILED
---
 tools/testing/selftests/bpf/.gitignore             |   1 -
 tools/testing/selftests/bpf/Makefile               |  10 +-
 .../selftests/bpf/prog_tests/xdp_features.c        | 446 +++++++++++++
 tools/testing/selftests/bpf/progs/xdp_features.c   |  49 +-
 tools/testing/selftests/bpf/test_xdp_features.sh   | 107 ---
 tools/testing/selftests/bpf/xdp_features.c         | 718 ---------------------
 tools/testing/selftests/bpf/xdp_features.h         |  17 +-
 7 files changed, 462 insertions(+), 886 deletions(-)
tools/testing/selftests/bpf/.gitignore +0 -1
index e6533b3400de..93bf35213042 100644
@@ -48,4 +48,3 @@ xskxceiver
 xdp_redirect_multi
 xdp_synproxy
 xdp_hw_metadata
-xdp_features
tools/testing/selftests/bpf/Makefile +2 -8
index 04716a5e43f1..db4a802c3e06 100644
@@ -145,8 +145,7 @@ TEST_PROGS := test_kmod.sh \
 	test_bpftool.sh \
 	test_bpftool_metadata.sh \
 	test_doc_build.sh \
-	test_xsk.sh \
-	test_xdp_features.sh
+	test_xsk.sh
 
 TEST_PROGS_EXTENDED := with_addr.sh \
 	with_tunnels.sh ima_setup.sh verify_sig_setup.sh \
@@ -157,7 +156,7 @@ TEST_GEN_PROGS_EXTENDED = \
 	flow_dissector_load test_flow_dissector test_tcp_check_syncookie_user \
 	test_lirc_mode2_user xdping test_cpp runqslower bench bpf_testmod.ko \
 	xskxceiver xdp_redirect_multi xdp_synproxy veristat xdp_hw_metadata \
-	xdp_features bpf_test_no_cfi.ko
+	bpf_test_no_cfi.ko
 
 TEST_GEN_FILES += liburandom_read.so urandom_read sign-file uprobe_multi
 
@@ -519,7 +518,6 @@ test_subskeleton_lib.skel.h-deps := test_subskeleton_lib2.bpf.o test_subskeleton
 test_usdt.skel.h-deps := test_usdt.bpf.o test_usdt_multispec.bpf.o
 xsk_xdp_progs.skel.h-deps := xsk_xdp_progs.bpf.o
 xdp_hw_metadata.skel.h-deps := xdp_hw_metadata.bpf.o
-xdp_features.skel.h-deps := xdp_features.bpf.o
 
 LINKED_BPF_OBJS := $(foreach skel,$(LINKED_SKELS),$($(skel)-deps))
 LINKED_BPF_SRCS := $(patsubst %.bpf.o,%.c,$(LINKED_BPF_OBJS))
@@ -787,10 +785,6 @@ $(OUTPUT)/xdp_hw_metadata: xdp_hw_metadata.c $(OUTPUT)/network_helpers.o $(OUTPU
 	$(call msg,BINARY,,$@)
 	$(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@
 
-$(OUTPUT)/xdp_features: xdp_features.c $(OUTPUT)/network_helpers.o $(OUTPUT)/xdp_features.skel.h | $(OUTPUT)
-	$(call msg,BINARY,,$@)
-	$(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@
-
 # Make sure we are able to include and link libbpf against c++.
 $(OUTPUT)/test_cpp: test_cpp.cpp $(OUTPUT)/test_core_extern.skel.h $(BPFOBJ)
 	$(call msg,CXX,,$@)
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +446 -0

446 lines not on this page · raw message

tools/testing/selftests/bpf/progs/xdp_features.c +13 -36

110 lines not on this page · raw message

tools/testing/selftests/bpf/test_xdp_features.sh deleted +0 -107

107 lines not on this page · raw message

tools/testing/selftests/bpf/xdp_features.c deleted +0 -718

718 lines not on this page · raw message

tools/testing/selftests/bpf/xdp_features.h +1 -16
index 2670c541713b..2fa7a2e156c7 100644
@@ -1,20 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
-/* test commands */
-enum test_commands {
-	CMD_STOP,		/* CMD */
-	CMD_START,		/* CMD */
-	CMD_ECHO,		/* CMD */
-	CMD_ACK,		/* CMD + data */
-	CMD_GET_XDP_CAP,	/* CMD */
-	CMD_GET_STATS,		/* CMD */
-};
+#define CMD_ECHO	0x4543484F /* 4 bytes magic */
 
-#define DUT_CTRL_PORT	12345
 #define DUT_ECHO_PORT	12346
-
-struct tlv_hdr {
-	__be16 type;
-	__be16 len;
-	__u8 data[];
-};

---
base-commit: b9a1776000bbc3b794a398e1ef8bec3dd6ed57ab
change-id: 20240730-convert_xdp_tests-ccd66bfe33db

Best regards,

Signature · 3 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
reviewer
#1 lore raw
Quoted 40 lines · Alexis Lothoré (eBPF Foundation)

test_xdp_features.sh is a shell script allowing to test that xdp features advertised by an interface are indeed delivered. The test works by starting two instance of the same program, both attaching specific xdp programs to each side of a veth link, and then make those programs manage packets and collect stats to check whether tested XDP feature is indeed delivered or not. However this test is not integrated in test_progs framework and so can not run automatically in CI.

Rewrite test_xdp_features to integrate it in test_progs so it can run automatically in CI. The main changes brought by the rewrite are the following:
- instead of running to separated processes (each one managing either the tester veth or the DUT vet), run a single process
- slightly change testing direction (v0 is the tester in local namespace, v1 is the Device Under Test in remote namespace)
- group all tests previously managed by test_xdp_features as subtests (one per tested XDP feature). As a consequence, run only once some steps instead of once per subtest (eg: starting/stopping the udp server). On the contrary, make sure that each subtest properly cleans up its state (ie detach xdp programs, reset test stats, etc)
- since there is now a single process, get rid of the "control" tcp channel used to configure DUT. Configuring the DUT now only consists in switching to DUT network namespace and run the relevant commands
- since there is no more control channel, get rid of TLVs, keep only the CMD_ECHO packet type, and set it as a magic
- simplify network setup: use only ipv6 instead of both ipv4 and ipv6, force static neighbours instead of waiting for autoconfiguration, do not force gro (fetch xdp features only once xdp programs are loaded instead)

The existing XDP programs are reused, with some minor changes:
- tester and dut stats maps are converted to global variables for easier usage
- programs do not use TLV struct anymore but the magic replacing the echo command
- avoid to accidentally make tests pass: drop packets instead of forwarding them to userspace when they do not match the expected payload
- make sure to perform host <-> network endianness conversion on constants rather than packet parts

...

Quoted 6 lines
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +0 -0
new file mode 100644
index 000000000000..bcb36a2d2767

tools/testing/selftests/bpf/prog_tests/xdp_features.c line 10

Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +10 -0
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/**
+ * Test XDP features
+ *
+ * Sets up a veth pair, and for each xdp feature under test:
+ * - asks the tested interface its xdp capabilities through bpf_xdp_query
+ * - attach and run some specific programs on both interfaces to check if
+ *   announced capability is respected
+ */

Hi Alexis,

This is neither a full review nor an issue that needs to block progress. But, FWIIW, the comment above is not a Kernel doc, yet starts with '/**'. I suggest that it should start with '/*' instead.

...

#2 lore raw

Hi Simon,

On 9/11/24 16:18, Simon Horman wrote:

[...]

Quoted 19 lines
Quoted 6 lines
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +0 -0
new file mode 100644
index 000000000000..bcb36a2d2767

tools/testing/selftests/bpf/prog_tests/xdp_features.c line 10

Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +10 -0
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/**
+ * Test XDP features
+ *
+ * Sets up a veth pair, and for each xdp feature under test:
+ * - asks the tested interface its xdp capabilities through bpf_xdp_query
+ * - attach and run some specific programs on both interfaces to check if
+ *   announced capability is respected
+ */

Hi Alexis,

Quoted 3 lines

This is neither a full review nor an issue that needs to block progress. But, FWIIW, the comment above is not a Kernel doc, yet starts with '/**'. I suggest that it should start with '/*' instead.

ACK. I'll wait for more comments on the series, and add the fix to the corresponding revision, if any.

Thanks,

Alexis

Signature · 3 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
reviewer
#3 lore raw
Quoted 25 lines · Alexis Lothoré

Hi Simon,

On 9/11/24 16:18, Simon Horman wrote:

[...]

Quoted 19 lines
Quoted 6 lines
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +0 -0
new file mode 100644
index 000000000000..bcb36a2d2767

tools/testing/selftests/bpf/prog_tests/xdp_features.c line 10

Quoted 10 lines
tools/testing/selftests/bpf/prog_tests/xdp_features.c new file +10 -0
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/**
+ * Test XDP features
+ *
+ * Sets up a veth pair, and for each xdp feature under test:
+ * - asks the tested interface its xdp capabilities through bpf_xdp_query
+ * - attach and run some specific programs on both interfaces to check if
+ *   announced capability is respected
+ */

Hi Alexis,

Quoted 6 lines
Quoted 3 lines

This is neither a full review nor an issue that needs to block progress. But, FWIIW, the comment above is not a Kernel doc, yet starts with '/**'. I suggest that it should start with '/*' instead.

ACK. I'll wait for more comments on the series, and add the fix to the corresponding revision, if any.

Thanks, much appreciated.

#4 lore raw
In reply to Alexis Lothoré (eBPF Foundation)
Quoted 49 lines · Alexis Lothoré (eBPF Foundation)

test_xdp_features.sh is a shell script allowing to test that xdp features advertised by an interface are indeed delivered. The test works by starting two instance of the same program, both attaching specific xdp programs to each side of a veth link, and then make those programs manage packets and collect stats to check whether tested XDP feature is indeed delivered or not. However this test is not integrated in test_progs framework and so can not run automatically in CI.

Rewrite test_xdp_features to integrate it in test_progs so it can run automatically in CI. The main changes brought by the rewrite are the following:
- instead of running to separated processes (each one managing either the tester veth or the DUT vet), run a single process
- slightly change testing direction (v0 is the tester in local namespace, v1 is the Device Under Test in remote namespace)
- group all tests previously managed by test_xdp_features as subtests (one per tested XDP feature). As a consequence, run only once some steps instead of once per subtest (eg: starting/stopping the udp server). On the contrary, make sure that each subtest properly cleans up its state (ie detach xdp programs, reset test stats, etc)
- since there is now a single process, get rid of the "control" tcp channel used to configure DUT. Configuring the DUT now only consists in switching to DUT network namespace and run the relevant commands
- since there is no more control channel, get rid of TLVs, keep only the CMD_ECHO packet type, and set it as a magic
- simplify network setup: use only ipv6 instead of both ipv4 and ipv6, force static neighbours instead of waiting for autoconfiguration, do not force gro (fetch xdp features only once xdp programs are loaded instead)

The existing XDP programs are reused, with some minor changes:
- tester and dut stats maps are converted to global variables for easier usage
- programs do not use TLV struct anymore but the magic replacing the echo command
- avoid to accidentally make tests pass: drop packets instead of forwarding them to userspace when they do not match the expected payload
- make sure to perform host <-> network endianness conversion on constants rather than packet parts

---
Changes in v2:
- fix endianness management in userspace packet parsing (call htonl on constant rather than packet part)

The xdp_features rewrite has been tested in a x86_64 qemu environment on my machine and in CI. In my environment, the test takes a bit less than 2s to execute.

Quoted 16 lines
   # ./test_progs -a xdp_features
   #561/1   xdp_features/XDP_PASS:OK
   #561/2   xdp_features/XDP_DROP:OK
   #561/3   xdp_features/XDP_ABORTED:OK
   #561/4   xdp_features/XDP_TX:OK
   #561/5   xdp_features/XDP_REDIRECT:OK
   #561/6   xdp_features/XDP_NDO_XMIT:OK
   #561     xdp_features:OK
   Summary: 1/6 PASSED, 0 SKIPPED, 0 FAILED
---
  tools/testing/selftests/bpf/.gitignore             |   1 -
  tools/testing/selftests/bpf/Makefile               |  10 +-
  .../selftests/bpf/prog_tests/xdp_features.c        | 446 +++++++++++++
  tools/testing/selftests/bpf/progs/xdp_features.c   |  49 +-
  tools/testing/selftests/bpf/test_xdp_features.sh   | 107 ---
  tools/testing/selftests/bpf/xdp_features.c         | 718 ---------------------

From the initial commit message of xdp_features.c, its primary usage is to test a physical network device that supports a certain XDP features.

iiuc, test_xdp_features.sh only uses the veth and veth will also be the only device tested after moving to prog_tests/xdp_features.c? It is a reasonable addition to test_progs for an end-to-end xdp test by using veth. However, test_progs will not be able to test the physical network device.

Lorenzo, is the xdp_features.c still used for device testing?

#5 lore raw
Quoted 50 lines · Martin KaFai Lau
Quoted 49 lines · Alexis Lothoré (eBPF Foundation)

test_xdp_features.sh is a shell script allowing to test that xdp features advertised by an interface are indeed delivered. The test works by starting two instance of the same program, both attaching specific xdp programs to each side of a veth link, and then make those programs manage packets and collect stats to check whether tested XDP feature is indeed delivered or not. However this test is not integrated in test_progs framework and so can not run automatically in CI.

Rewrite test_xdp_features to integrate it in test_progs so it can run automatically in CI. The main changes brought by the rewrite are the following:
- instead of running to separated processes (each one managing either the tester veth or the DUT vet), run a single process
- slightly change testing direction (v0 is the tester in local namespace, v1 is the Device Under Test in remote namespace)
- group all tests previously managed by test_xdp_features as subtests (one per tested XDP feature). As a consequence, run only once some steps instead of once per subtest (eg: starting/stopping the udp server). On the contrary, make sure that each subtest properly cleans up its state (ie detach xdp programs, reset test stats, etc)
- since there is now a single process, get rid of the "control" tcp channel used to configure DUT. Configuring the DUT now only consists in switching to DUT network namespace and run the relevant commands
- since there is no more control channel, get rid of TLVs, keep only the CMD_ECHO packet type, and set it as a magic
- simplify network setup: use only ipv6 instead of both ipv4 and ipv6, force static neighbours instead of waiting for autoconfiguration, do not force gro (fetch xdp features only once xdp programs are loaded instead)

The existing XDP programs are reused, with some minor changes:
- tester and dut stats maps are converted to global variables for easier usage
- programs do not use TLV struct anymore but the magic replacing the echo command
- avoid to accidentally make tests pass: drop packets instead of forwarding them to userspace when they do not match the expected payload
- make sure to perform host <-> network endianness conversion on constants rather than packet parts

---
Changes in v2:
- fix endianness management in userspace packet parsing (call htonl on constant rather than packet part)

The xdp_features rewrite has been tested in a x86_64 qemu environment on my machine and in CI. In my environment, the test takes a bit less than 2s to execute.

Quoted 16 lines
Quoted 8 lines
   # ./test_progs -a xdp_features
   #561/1   xdp_features/XDP_PASS:OK
   #561/2   xdp_features/XDP_DROP:OK
   #561/3   xdp_features/XDP_ABORTED:OK
   #561/4   xdp_features/XDP_TX:OK
   #561/5   xdp_features/XDP_REDIRECT:OK
   #561/6   xdp_features/XDP_NDO_XMIT:OK
   #561     xdp_features:OK
Quoted 8 lines
   Summary: 1/6 PASSED, 0 SKIPPED, 0 FAILED
---
  tools/testing/selftests/bpf/.gitignore             |   1 -
  tools/testing/selftests/bpf/Makefile               |  10 +-
  .../selftests/bpf/prog_tests/xdp_features.c        | 446 +++++++++++++
  tools/testing/selftests/bpf/progs/xdp_features.c   |  49 +-
  tools/testing/selftests/bpf/test_xdp_features.sh   | 107 ---
  tools/testing/selftests/bpf/xdp_features.c         | 718 ---------------------

Hi Alexis.

sorry for the late reply.

Quoted 11 lines

From the initial commit message of xdp_features.c, its primary usage is to test a physical network device that supports a certain XDP features.

iiuc, test_xdp_features.sh only uses the veth and veth will also be the only device tested after moving to prog_tests/xdp_features.c? It is a reasonable addition to test_progs for an end-to-end xdp test by using veth. However, test_progs will not be able to test the physical network device.

Lorenzo, is the xdp_features.c still used for device testing?

correct, xdp_features.c is intended to test the real xdp features supported by the NIC under test (DUT), not just the advertised ones (iirc that was a requisite to add xdp kernel feature support). For this reason we need two separated processes running on the tester device and on the DUT (they are usually two different devices). test_xdp_features.sh was just a simple test script used to develop xdp_features.c.
What about extending xdp_features.c to integrate it in the CI?

Regards,
Lorenzo

maintainer
#6 lore raw
Quoted 10 lines · On Sat, 14 Sep 2024 11:25:47 +0200 Lorenzo Bianconi wrote:
Quoted 8 lines · Martin KaFai Lau

test a physical network device that supports a certain XDP features.

iiuc, test_xdp_features.sh only uses the veth and veth will also be the only device tested after moving to prog_tests/xdp_features.c? It is a reasonable addition to test_progs for an end-to-end xdp test by using veth. However, test_progs will not be able to test the physical network device.

Lorenzo, is the xdp_features.c still used for device testing?

Quoted 7 lines

correct, xdp_features.c is intended to test the real xdp features supported by the NIC under test (DUT), not just the advertised ones (iirc that was a requisite to add xdp kernel feature support). For this reason we need two separated processes running on the tester device and on the DUT (they are usually two different devices). test_xdp_features.sh was just a simple test script used to develop xdp_features.c.
What about extending xdp_features.c to integrate it in the CI?

No preference but just to raise awareness - drivers/net's NetDrvEpEnv class provides the setup for running tests with an endpoint. XDP tests intended for HW would fit there pretty well.

#7 lore raw

Hello all, sorry for the slow feedback, I have been off last week.

Quoted 11 lines · Jakub Kicinski
Quoted 10 lines · On Sat, 14 Sep 2024 11:25:47 +0200 Lorenzo Bianconi wrote:
Quoted 8 lines · Martin KaFai Lau

test a physical network device that supports a certain XDP features.

iiuc, test_xdp_features.sh only uses the veth and veth will also be the only device tested after moving to prog_tests/xdp_features.c? It is a reasonable addition to test_progs for an end-to-end xdp test by using veth. However, test_progs will not be able to test the physical network device.

Lorenzo, is the xdp_features.c still used for device testing?

Quoted 7 lines
Quoted 7 lines

correct, xdp_features.c is intended to test the real xdp features supported by the NIC under test (DUT), not just the advertised ones (iirc that was a requisite to add xdp kernel feature support). For this reason we need two separated processes running on the tester device and on the DUT (they are usually two different devices). test_xdp_features.sh was just a simple test script used to develop xdp_features.c.
What about extending xdp_features.c to integrate it in the CI?

So IIUC Lorenzo's answer, we _need_ to keep the possibility to run this test on real hardware, and so we _need_ to still be able to run two processes, possibly on two different machines. If that's so, indeed my rework breaks this. I have then multiple questions/doubts before being able to rework this:
- the main goal of this rework is to be able to automatically run this test in CI, and the resulting constraint is that it must integrate in a standalone, already-existing c program (test_progs). I guess I can preserve the standalone xdp_features program as it is, and make test_progs just start it twice (on two different veths). It would involve the following changes:
- keep a dedicated build step for this small, standalone xdp_features.c, and
add a "controller" part in test_progs (instead of fully migrating xdp_features program into test_progs, which is what the current series revision does)
- simply make the controller part create the testing network in CI, fork/start
the xdp_features program on both veths, and check return codes.
My main concern is about the possible flakiness of this whole setup (multiple processes and tcp/udp channels involved), but if keeping the standalone version is really needed, I can give a try. Does it sound reasonable ?
- one part of my overall goal is to clean up the tools/testing/selftests/bpf directory from anything that is not tested automatically. What should we do with the wrapping shell script (test_xdp_features.sh) ? Since test_progs will automate the test with veths, I guess it is still ok to just remove it ?

Quoted 3 lines

No preference but just to raise awareness - drivers/net's NetDrvEpEnv class provides the setup for running tests with an endpoint. XDP tests intended for HW would fit there pretty well.

Thanks for the hint. If we want to keep some tooling for real hw xdp features testing, maybe we could add a small part in tools/testing/selftests/drivers/net and make it use this NetDrvEpEnv ? Or it is a bigger hint that the whole test about xdp features could be moved there (and then tested by net kselftests rather than by ebpf ci specifically) ? @Lorenzo and eBPF tests maintainers, any opinion ?

Thanks,

Alexis

Signature · 3 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#8 lore raw
Quoted 22 lines · Alexis Lothoré

Hello all, sorry for the slow feedback, I have been off last week.

Quoted 11 lines · Jakub Kicinski
Quoted 10 lines · On Sat, 14 Sep 2024 11:25:47 +0200 Lorenzo Bianconi wrote:
Quoted 8 lines · Martin KaFai Lau

test a physical network device that supports a certain XDP features.

iiuc, test_xdp_features.sh only uses the veth and veth will also be the only device tested after moving to prog_tests/xdp_features.c? It is a reasonable addition to test_progs for an end-to-end xdp test by using veth. However, test_progs will not be able to test the physical network device.

Lorenzo, is the xdp_features.c still used for device testing?

Quoted 7 lines
Quoted 7 lines

correct, xdp_features.c is intended to test the real xdp features supported by the NIC under test (DUT), not just the advertised ones (iirc that was a requisite to add xdp kernel feature support). For this reason we need two separated processes running on the tester device and on the DUT (they are usually two different devices). test_xdp_features.sh was just a simple test script used to develop xdp_features.c.
What about extending xdp_features.c to integrate it in the CI?

Quoted 15 lines

So IIUC Lorenzo's answer, we _need_ to keep the possibility to run this test on real hardware, and so we _need_ to still be able to run two processes, possibly on two different machines. If that's so, indeed my rework breaks this. I have then multiple questions/doubts before being able to rework this:
- the main goal of this rework is to be able to automatically run this test in CI, and the resulting constraint is that it must integrate in a standalone, already-existing c program (test_progs). I guess I can preserve the standalone xdp_features program as it is, and make test_progs just start it twice (on two different veths). It would involve the following changes:
- keep a dedicated build step for this small, standalone xdp_features.c, and
add a "controller" part in test_progs (instead of fully migrating xdp_features program into test_progs, which is what the current series revision does)
- simply make the controller part create the testing network in CI, fork/start
the xdp_features program on both veths, and check return codes.
My main concern is about the possible flakiness of this whole setup (multiple

The test could be simpler if it does not need to run in two separate machines.

Also, there are bpf_prog_test_run_opts() style tests that provide a device agnostic way to test the xdp helpers/features which should have covered most of the cases exercised in progs/xdp_features.c?

I am not sure which case in xdp_features.c does not have existing coverage in test_progs. From a quick look, it seems only BPF_MAP_TYPE_CPUMAP is missing (please check)? If that is the case, it may be more straight forward to add this one test case to the test_progs. Check if it can borrow a similar setup from prog_tests/test_xdp_veth.c, and then leave xdp_features.* as-is.

There are other .sh tests that could better use the test_progs migration. In particular the ones without existing test coverage. For non XDP related, test_tcp_check_syncookie.sh, test_flow_dissector.sh, and test_tc_edt.sh should be the good ones.

For XDP, test_xdp_meta.sh should be useful also. You may also want to check the test_xdp_redirect_*.sh.

Quoted 22 lines

processes and tcp/udp channels involved), but if keeping the standalone version is really needed, I can give a try. Does it sound reasonable ?
- one part of my overall goal is to clean up the tools/testing/selftests/bpf directory from anything that is not tested automatically. What should we do with the wrapping shell script (test_xdp_features.sh) ? Since test_progs will automate the test with veths, I guess it is still ok to just remove it ?

Quoted 3 lines

No preference but just to raise awareness - drivers/net's NetDrvEpEnv class provides the setup for running tests with an endpoint. XDP tests intended for HW would fit there pretty well.

Thanks for the hint. If we want to keep some tooling for real hw xdp features testing, maybe we could add a small part in tools/testing/selftests/drivers/net and make it use this NetDrvEpEnv ? Or it is a bigger hint that the whole test about xdp features could be moved there (and then tested by net kselftests rather than by ebpf ci specifically) ? @Lorenzo and eBPF tests maintainers, any opinion ?

Thanks,

Alexis

#9 lore raw
Quoted 1 line · Martin KaFai Lau

I am not sure which case in xdp_features.c does not have existing coverage in test_progs. From a quick look, it seems only BPF_MAP_TYPE_CPUMAP is missing (please check)?

Re: CPUMAP, I noticed there is a xdp_(cpu)map_attach.c test but it only does attach test. May be something similar can be done like https://lore.kernel.org/bpf/20240911-devel-koalo-fix-ingress-ifindex-v4-2-5c643ae10258@linutronix.de/ to exercise the xdp prog that does cpumap redirect.

#10 lore raw

Hi Martin,

Quoted 8 lines · Martin KaFai Lau
Quoted 3 lines · Martin KaFai Lau

I am not sure which case in xdp_features.c does not have existing coverage in test_progs. From a quick look, it seems only BPF_MAP_TYPE_CPUMAP is missing (please check)?

Re: CPUMAP, I noticed there is a xdp_(cpu)map_attach.c test but it only does
attach test. May be something similar can be done like
https://lore.kernel.org/bpf/20240911-devel-koalo-fix-ingress-ifindex-v4-2-5c643ae10258@linutronix.de/ to exercise the xdp prog that does cpumap redirect.

Thanks for the guidance, I was not aware of the possibility to perform those tests with BPF_PROG_RUN.
Indeed, the basic return values from XDP programs seem to be covered with this method in other tests under prog_tests. For BPF_MAP_TYPE_CPUMAP, I can check and try to apply the same logic as the series in progress you have pointed.

Once done, test_xdp_features.sh could be let as-is. Let me know if we should stillmove it elsewhere instead of keeping it in selftests (tools/bpf/xdp_features/ maybe ?)

And noted for the most relevant tests to convert after that, thanks :)

Alexis

Signature · 3 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#11 lore raw
In reply to Martin KaFai Lau
Quoted 1 line · Martin KaFai Lau

There are other .sh tests that could better use the test_progs migration. In particular the ones without existing test coverage. For non XDP related, test_tcp_check_syncookie.sh, test_flow_dissector.sh, and test_tc_edt.sh should be the good ones.

I just took a closer look at the test_tc_edt.* for another reason. It seems doing some bandwidth test which may not be a good fit (e.g. too flaky) for test_progs. I would leave it to the bottom of the todo list for now.

Quoted 27 lines

For XDP, test_xdp_meta.sh should be useful also. You may also want to check the test_xdp_redirect_*.sh.

Quoted 22 lines

processes and tcp/udp channels involved), but if keeping the standalone version is really needed, I can give a try. Does it sound reasonable ?
- one part of my overall goal is to clean up the tools/testing/selftests/bpf directory from anything that is not tested automatically. What should we do with the wrapping shell script (test_xdp_features.sh) ? Since test_progs will automate the test with veths, I guess it is still ok to just remove it ?

Quoted 3 lines

No preference but just to raise awareness - drivers/net's NetDrvEpEnv class provides the setup for running tests with an endpoint. XDP tests intended for HW would fit there pretty well.

Thanks for the hint. If we want to keep some tooling for real hw xdp features testing, maybe we could add a small part in tools/testing/selftests/drivers/net and make it use this NetDrvEpEnv ? Or it is a bigger hint that the whole test about xdp features could be moved there (and then tested by net kselftests rather than by ebpf ci specifically) ? @Lorenzo and eBPF tests maintainers, any opinion ?

Thanks,

Alexis

#12 lore raw
Quoted 9 lines · Martin KaFai Lau
Quoted 4 lines · Martin KaFai Lau

There are other .sh tests that could better use the test_progs migration. In particular the ones without existing test coverage. For non XDP related, test_tcp_check_syncookie.sh, test_flow_dissector.sh, and test_tc_edt.sh should be the good ones.

I just took a closer look at the test_tc_edt.* for another reason. It seems doing some bandwidth test which may not be a good fit (e.g. too flaky) for test_progs. I would leave it to the bottom of the todo list for now.

ACK, thanks

Signature · 3 lines
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com