selftests: move the AF_XDP test suite from bpf to net
Subsystems (8)
Maciej Fijalkowski
maintainerv2 cover selftests: move the AF_XDP test suite from bpf to net
v1:
https://lore.kernel.org/netdev/[email protected]/v1->v2:
* Patch 4: add xdp_hw_metadata to TEST_GEN_FILES via COND_GEN_FILES, as net/lib/Makefile does for xskxceiver, so that net/Makefile passes NIPA's check_selftest.
* Add Stanislav's tag.
Hi,
As the maintainers asked, this series is the first step of moving the AF_XDP selftests from selftests/bpf to selftests/net: the code moves and builds from its new location, without changing what the tests do. The rework [0] posted as "selftests: net: migrate AF_XDP test suite over to net" (v4) will follow on top of this move.
Patch 1 drops the test_progs wrapper of the AF_XDP tests, patch 2 adds a generic BPF skeleton rule to net/bpf.mk, patch 3 moves xskxceiver, its library and test_xsk.sh to selftests/net, and patch 4 (new, not covered at [0]) moves xdp_hw_metadata, which is built from the same library.
The xdp_metadata test stays in test_progs: it covers BPF core behaviour, and moving it would mean rewriting it for the kselftest harness. It keeps using xsk.c from net/lib/xsk.
xskxceiver and xdp_hw_metadata are the first users of bpftool at build time in selftests/net. NIPA has bpftool, but 0-day and KernelCI build net without it, so both tools are skipped with a warning when bpftool is missing or does not run.
test_xsk.sh is installed but not run by run_tests, so NIPA does not pick it up: it runs every case, including flaky ones, and some cases leak page_pool pages after skb_pp_cow_data() in generic XDP mode on veth-based runs. Until a later step makes the suite fit for NIPA, no CI runs the AF_XDP tests. test_xsk.sh is being removed by [0] but it is kept here as there is no other feasible way to run the test suite (if needed) until we come up with an upstreamable Python runner.
Thanks,
Maciej
[0]: https://lore.kernel.org/bpf/[email protected]/
Maciej Fijalkowski (4):
selftests/bpf: drop the test_progs AF_XDP wrapper
selftests: net: add a generic rule for BPF skeletons
selftests: xsk: move the AF_XDP test suite to selftests/net
selftests: net: move xdp_hw_metadata from selftests/bpf
Documentation/networking/af_xdp.rst | 6 +-
Documentation/networking/xsk-tx-metadata.rst | 2 +-
MAINTAINERS | 4 +-
tools/testing/selftests/bpf/.gitignore | 2 -
tools/testing/selftests/bpf/Makefile | 29 +--
.../testing/selftests/bpf/Makefile.buildvars | 6 +-
tools/testing/selftests/bpf/network_helpers.c | 48 -----
tools/testing/selftests/bpf/network_helpers.h | 2 -
tools/testing/selftests/bpf/prog_tests/xsk.c | 170 ------------------
tools/testing/selftests/net/.gitignore | 2 +
tools/testing/selftests/net/Makefile | 22 +++
tools/testing/selftests/net/bpf.mk | 13 +-
tools/testing/selftests/net/config | 1 +
tools/testing/selftests/net/lib/.gitignore | 2 +
tools/testing/selftests/net/lib/Makefile | 25 +++
.../prog_tests => net/lib/xsk}/test_xsk.c | 2 +-
.../prog_tests => net/lib/xsk}/test_xsk.h | 5 +-
.../selftests/{bpf => net/lib/xsk}/xsk.c | 49 ++++-
.../selftests/{bpf => net/lib/xsk}/xsk.h | 4 +
.../{bpf => net/lib/xsk}/xsk_xdp_common.h | 0
.../lib/xsk/xsk_xdp_progs.bpf.c} | 2 +-
.../{bpf => net/lib/xsk}/xskxceiver.c | 17 +-
.../{bpf => net/lib/xsk}/xskxceiver.h | 0
.../selftests/{bpf => net}/test_xsk.sh | 5 +
.../xdp_hw_metadata.bpf.c} | 35 +++-
.../selftests/{bpf => net}/xdp_hw_metadata.c | 81 ++++++++-
tools/testing/selftests/net/xdp_metadata.h | 67 +++++++
.../selftests/{bpf => net}/xsk_prereqs.sh | 2 +-
28 files changed, 309 insertions(+), 294 deletions(-)
delete mode 100644 tools/testing/selftests/bpf/prog_tests/xsk.c
rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.c (99%)
rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.h (99%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.c (95%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.h (97%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk_xdp_common.h (100%)
rename tools/testing/selftests/{bpf/progs/xsk_xdp_progs.c => net/lib/xsk/xsk_xdp_progs.bpf.c} (98%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.c (96%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.h (100%)
rename tools/testing/selftests/{bpf => net}/test_xsk.sh (98%)
rename tools/testing/selftests/{bpf/progs/xdp_hw_metadata.c => net/xdp_hw_metadata.bpf.c} (75%)
rename tools/testing/selftests/{bpf => net}/xdp_hw_metadata.c (92%)
create mode 100644 tools/testing/selftests/net/xdp_metadata.h
rename tools/testing/selftests/{bpf => net}/xsk_prereqs.sh (98%)base-commit: fa5196392691051963726787944db872420dfa75
Signature · 1 line
2.43.0
Maciej Fijalkowski
maintainerPATCH v2 1/4 selftests/bpf: drop the test_progs AF_XDP wrapper
prog_tests/xsk.c runs the xskxceiver cases inside test_progs. With the AF_XDP test suite moving to selftests/net in a following patch, the wrapper would make test_progs build the engine and its XDP program from there, so drop it.
BPF CI loses ns_xsk_skb and ns_xsk_drv. test_xsk.sh still covers the same cases over veth, but no CI runs it until the suite is ready for NIPA.
ci_skip_tests[] only held the cases that the wrapper left out, so fold it into tests[]. The test IDs do not change.
--- .../selftests/bpf/prog_tests/test_xsk.h | 3 - tools/testing/selftests/bpf/prog_tests/xsk.c | 170 ------------------ tools/testing/selftests/bpf/xskxceiver.c | 10 +- 3 files changed, 2 insertions(+), 181 deletions(-) delete mode 100644 tools/testing/selftests/bpf/prog_tests/xsk.c
tools/testing/selftests/bpf/prog_tests/test_xsk.h +0 -3
@@ -297,9 +297,6 @@ static const struct test_spec tests[] = { {.name = "TOO_MANY_FRAGS", .test_func = testapp_too_many_frags}, {.name = "XDP_ADJUST_TAIL_SHRINK", .test_func = testapp_adjust_tail_shrink}, {.name = "TX_QUEUE_CONSUMER", .test_func = testapp_tx_queue_consumer}, - }; - -static const struct test_spec ci_skip_tests[] = { /* Flaky tests */ {.name = "XDP_ADJUST_TAIL_SHRINK_MULTI_BUFF", .test_func = testapp_adjust_tail_shrink_mb}, {.name = "XDP_ADJUST_TAIL_GROW", .test_func = testapp_adjust_tail_grow},
tools/testing/selftests/bpf/prog_tests/xsk.c deleted +0 -170
170 lines not on this page · raw message
tools/testing/selftests/bpf/xskxceiver.c +2 -8
@@ -327,14 +327,12 @@ static void print_tests(void)printf ("Tests:\n" );for (i =0 ; i <ARRAY_SIZE (tests); i++)printf ("%u: %s\n" , i, tests[i].name); -for (i =ARRAY_SIZE (tests); i <ARRAY_SIZE (tests) +ARRAY_SIZE (ci_skip_tests); i++) -printf ("%u: %s\n" , i, ci_skip_tests[i -ARRAY_SIZE (tests)].name); }int main (int argc,char **argv) { -const size_t total_tests =ARRAY_SIZE (tests) +ARRAY_SIZE (ci_skip_tests);u32 cache_line_size, max_frags, umem_tailroom; +const size_t total_tests =ARRAY_SIZE (tests);struct pkt_stream *rx_pkt_stream_default;struct pkt_stream *tx_pkt_stream_default;struct ifobject *ifobj_tx, *ifobj_rx;
@@ -449,11 +447,7 @@ int main(int argc, char **argv)if (opt_run_test !=RUN_ALL_TESTS && j != opt_run_test)continue ; -if (j <ARRAY_SIZE (tests)) -test_init (&test, ifobj_tx, ifobj_rx, i, &tests[j]); -else -test_init (&test, ifobj_tx, ifobj_rx, i, - &ci_skip_tests[j -ARRAY_SIZE (tests)]); +test_init (&test, ifobj_tx, ifobj_rx, i, &tests[j]);run_pkt_test (&test);usleep (USLEEP_MAX );
Signature · 1 line
2.43.0
Maciej Fijalkowski
maintainerPATCH v2 2/4 selftests: net: add a generic rule for BPF skeletons
In reply to Maciej FijalkowskiTests that load their BPF program through a bpftool skeleton have to bring their own rule for the header. Add a pattern rule to bpf.mk that generates $(OUTPUT)/<name>.skel.h from $(OUTPUT)/<name>.bpf.o with $(BPFTOOL), the bpftool in PATH by default, and removes the partial header if bpftool fails.
Also build the programs in the subdirectories listed in BPF_PROG_DIRS, and have make clean remove all program objects and their skeletons.
xskxceiver, which moves to net/lib/xsk in the next patch, is the first user of both.
--- tools/testing/selftests/net/bpf.mk | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/testing/selftests/net/bpf.mk +11 -2
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Rules to generate bpf objs CLANG ?= clang +BPFTOOL ?= bpftool SCRATCH_DIR := $(OUTPUT)/tools BUILD_DIR := $(SCRATCH_DIR)/build BPFDIR := $(top_srcdir)/tools/lib/bpf
@@ -35,13 +36,21 @@ endif CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) -BPF_PROG_OBJS := $(patsubst %.c,$(OUTPUT)/%.o,$(wildcard *.bpf.c)) +# Programs come from *.bpf.c here and in the subdirectories in BPF_PROG_DIRS. +BPF_PROG_SRCS := $(wildcard *.bpf.c $(addsuffix /*.bpf.c,$(BPF_PROG_DIRS))) +BPF_PROG_OBJS := $(patsubst %.c,$(OUTPUT)/%.o,$(notdir $(BPF_PROG_SRCS))) +vpath %.bpf.c $(BPF_PROG_DIRS) $(BPF_PROG_OBJS): $(OUTPUT)/%.o : %.c $(BPFOBJ) | $(MAKE_DIRS) $(call msg,BPF_PROG,,$@) $(Q)$(CLANG) -O2 -g --target=bpf $(CCINCLUDE) $(CLANG_SYS_INCLUDES) \ -c $< -o $@ +$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o + $(call msg,GEN-SKEL,,$@) + $(Q)$(BPFTOOL) gen skeleton $< name $(notdir $*) > $@ || \ + { rm -f $@; exit 1; } + $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ $(APIDIR)/linux/bpf.h \ | $(BUILD_DIR)/libbpf
@@ -50,4 +59,4 @@ $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ EXTRA_CFLAGS='-g -O0' \ DESTDIR=$(SCRATCH_DIR) prefix= all install_headers -EXTRA_CLEAN += $(SCRATCH_DIR) +EXTRA_CLEAN += $(SCRATCH_DIR) $(BPF_PROG_OBJS) $(BPF_PROG_OBJS:.bpf.o=.skel.h)
Signature · 1 line
2.43.0
Maciej Fijalkowski
maintainerPATCH v2 3/4 selftests: xsk: move the AF_XDP test suite to selftests/net
In reply to Maciej FijalkowskiMove the xskxceiver engine, the AF_XDP userspace library, the test definitions and the XDP program to net/lib/xsk, and test_xsk.sh with xsk_prereqs.sh to selftests/net.
net/lib builds the XDP program and its skeleton with the bpf.mk rules, and skips xskxceiver with a warning when bpftool does not work, in which case test_xsk.sh skips too. List test_xsk.sh in TEST_PROGS_EXTENDED, so that it is installed but NIPA does not run it
yet: it runs every case, flaky ones included.
xskxceiver builds against the uapi headers from make headers, whose linux/netlink.h does not pull in linux/kernel.h, so include it for min_t() directly. Put tools/include ahead of CFLAGS, so that in O= builds a stale usr/include in the source tree does not shadow its linux/kernel.h and linux/types.h. Move the ethtool ring helpers from network_helpers into xsk.c, and cast to void * in the bound check of the XDP program, as bpf.mk does not build with -Wno-compare-distinct-pointer-types.
xdp_hw_metadata and the xdp_metadata test keep using xsk.c from net/lib/xsk: selftests/bpf builds xsk.o from there in place of the find_bit.o rule, which only test_xsk.c needed. Update MAINTAINERS.
---
Documentation/networking/af_xdp.rst | 6 +--
MAINTAINERS | 3 +-
tools/testing/selftests/bpf/.gitignore | 1 -
tools/testing/selftests/bpf/Makefile | 25 +++-------
.../testing/selftests/bpf/Makefile.buildvars | 6 +--
tools/testing/selftests/bpf/network_helpers.c | 48 ------------------
tools/testing/selftests/bpf/network_helpers.h | 2 -
tools/testing/selftests/net/Makefile | 2 +
tools/testing/selftests/net/config | 1 +
tools/testing/selftests/net/lib/.gitignore | 2 +
tools/testing/selftests/net/lib/Makefile | 25 ++++++++++
.../prog_tests => net/lib/xsk}/test_xsk.c | 2 +-
.../prog_tests => net/lib/xsk}/test_xsk.h | 2 +-
.../selftests/{bpf => net/lib/xsk}/xsk.c | 49 ++++++++++++++++++-
.../selftests/{bpf => net/lib/xsk}/xsk.h | 4 ++
.../{bpf => net/lib/xsk}/xsk_xdp_common.h | 0
.../lib/xsk/xsk_xdp_progs.bpf.c} | 2 +-
.../{bpf => net/lib/xsk}/xskxceiver.c | 7 +--
.../{bpf => net/lib/xsk}/xskxceiver.h | 0
.../selftests/{bpf => net}/test_xsk.sh | 5 ++
.../selftests/{bpf => net}/xsk_prereqs.sh | 2 +-
21 files changed, 108 insertions(+), 86 deletions(-)
rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.c (99%)
rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.h (99%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.c (95%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.h (97%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk_xdp_common.h (100%)
rename tools/testing/selftests/{bpf/progs/xsk_xdp_progs.c => net/lib/xsk/xsk_xdp_progs.bpf.c} (98%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.c (99%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.h (100%)
rename tools/testing/selftests/{bpf => net}/test_xsk.sh (98%)
rename tools/testing/selftests/{bpf => net}/xsk_prereqs.sh (98%)Documentation/networking/af_xdp.rst +3 -3
@@ -211,7 +211,7 @@ Libbpf Libbpf is a helper library for eBPF and XDP that makes using these technologies a lot simpler. It also contains specific helper functions -in tools/testing/selftests/bpf/xsk.h for facilitating the use of +in tools/testing/selftests/net/lib/xsk/xsk.h for facilitating the use of AF_XDP. It contains two types of functions: those that can be used to make the setup of AF_XDP socket easier and ones that can be used in the data plane to access the rings safely and quickly.
@@ -751,7 +751,7 @@ return values: returned number signifies the max number of frags supported. For an example on how these are used through libbpf, please take a -look at tools/testing/selftests/bpf/xskxceiver.c. +look at tools/testing/selftests/net/lib/xsk/xskxceiver.c. Multi-Buffer Support for Zero-Copy Drivers ------------------------------------------
@@ -785,7 +785,7 @@ can be displayed with "-h", as usual. This sample application uses libbpf to make the setup and usage of AF_XDP simpler. If you want to know how the raw uapi of AF_XDP is really used to make something more advanced, take a look at the libbpf -code in tools/testing/selftests/bpf/xsk.[ch]. +code in tools/testing/selftests/net/lib/xsk/xsk.[ch]. FAQ =======
MAINTAINERS +2 -1
@@ -30547,7 +30547,8 @@ F: include/net/xsk_buff_pool.h F: include/uapi/linux/if_xdp.h F: include/uapi/linux/xdp_diag.h F: net/xdp/ -F: tools/testing/selftests/bpf/*xsk* +F: tools/testing/selftests/net/*xsk* +F: tools/testing/selftests/net/lib/xsk/ XEN BLOCK SUBSYSTEM M: Roger Pau Monné <[email protected]>
tools/testing/selftests/bpf/.gitignore +0 -1
@@ -36,7 +36,6 @@ test_cpp /uprobe_multi *.ko *.tmp -xskxceiver xdp_redirect_multi xdp_synproxy xdp_hw_metadata
tools/testing/selftests/bpf/Makefile +7 -18
@@ -33,14 +33,13 @@ TEST_GEN_PROGS += test_progs-cpuv4 TEST_INST_SUBDIRS += cpuv4 endif -TEST_FILES = xsk_prereqs.sh $(wildcard progs/btf_dump_test_case_*.c) \ +TEST_FILES = $(wildcard progs/btf_dump_test_case_*.c) \ bpftool_btf_dump_sorted.expected \ bpftool_btf_dump_unsorted.expected # Order correspond to 'make run_tests' order TEST_PROGS := test_bpftool_build.sh \ test_doc_build.sh \ - test_xsk.sh \ test_xdp_features.sh TEST_PROGS_EXTENDED := \
@@ -58,8 +57,7 @@ TEST_GEN_PROGS_EXTENDED = \ veristat \ xdp_features \ xdp_hw_metadata \ - xdp_synproxy \ - xskxceiver + xdp_synproxy TEST_GEN_FILES += $(TEST_KMODS) liburandom_read.so urandom_read sign-file uprobe_multi
@@ -257,9 +255,9 @@ $(RUNNER_OBJS): $(VERIFY_SIG_HDR) $(BPFOBJ) $(TRUNNER_BPFTOOL) $(OUTPUT)/test_progs.o: prog_tests/tests.h $(OUTPUT)/test_maps.o: map_tests/tests.h -# find_bit.c is the only runner source outside this directory, so it -# needs a rule of its own. -$(OUTPUT)/find_bit.o: $(TOOLSDIR)/lib/find_bit.c +# xsk.c is the only runner source outside this directory, so it needs a +# rule of its own. +$(OUTPUT)/xsk.o: ../net/lib/xsk/xsk.c $(call msg,CC,,$@) $(Q)$(CC) $(CFLAGS) -c $< $(LDLIBS) -o $@
@@ -570,18 +568,9 @@ $(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT) $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ -# Keep xskxceiver independent from test_progs object dependencies. -$(OUTPUT)/xskxceiver: xskxceiver.c xsk.c network_helpers.c \ - $(TOOLSDIR)/lib/find_bit.c prog_tests/test_xsk.c \ - xskxceiver.h xsk.h network_helpers.h \ - prog_tests/test_xsk.h test_progs.h bpf_util.h \ - $(OUTPUT)/xsk_xdp_progs.skel.h $(BPFOBJ) | $(OUTPUT) - $(call msg,BINARY,,$@) - $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ - -$(OUTPUT)/xdp_hw_metadata: xdp_hw_metadata.c xsk.c network_helpers.c \ +$(OUTPUT)/xdp_hw_metadata: xdp_hw_metadata.c ../net/lib/xsk/xsk.c network_helpers.c \ $(TOOLSDIR)/lib/find_bit.c xdp_metadata.h \ - xsk.h network_helpers.h test_progs.h bpf_util.h \ + ../net/lib/xsk/xsk.h network_helpers.h test_progs.h bpf_util.h \ $(OUTPUT)/xdp_hw_metadata.skel.h $(BPFOBJ) | $(OUTPUT) $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@
tools/testing/selftests/bpf/Makefile.buildvars +3 -3
@@ -74,7 +74,8 @@ COMMON_CFLAGS = -g $(OPT_FLAGS) -rdynamic -std=gnu11 \ $(GENFLAGS) $(SAN_CFLAGS) $(LIBELF_CFLAGS) \ -I$(CURDIR) -I$(INCLUDE_DIR) -I$(GENDIR) -I$(LIBDIR) \ -I$(TOOLSINCDIR) -I$(TOOLSARCHINCDIR) -I$(APIDIR) -I$(OUTPUT) \ - -I$(CURDIR)/libarena/include + -I$(CURDIR)/libarena/include \ + -I$(CURDIR)/../net/lib/xsk LDLIBS += $(LIBELF_LIBS) -lz -lrt -lpthread PCAP_CFLAGS := $(shell $(PKG_CONFIG) --cflags libpcap 2>/dev/null && echo "-DTRAFFIC_MONITOR=1")
@@ -156,7 +157,6 @@ RUNNER_OBJS-test_progs := $(addprefix $(OUTPUT)/, \ cap_helpers.o unpriv_helpers.o sysctl_helpers.o \ netlink_helpers.o jit_disasm_helpers.o io_helpers.o \ test_loader.o xsk.o disasm.o disasm_helpers.o \ - json_writer.o bpftool_helpers.o usdt_1.o usdt_2.o \ - find_bit.o) + json_writer.o bpftool_helpers.o usdt_1.o usdt_2.o) RUNNER_OBJS-test_maps := $(addprefix $(OUTPUT)/, \ test_maps.o testing_helpers.o)
tools/testing/selftests/bpf/network_helpers.c +0 -48
54 lines not on this page · raw message
tools/testing/selftests/bpf/network_helpers.h +0 -2
@@ -89,8 +89,6 @@ int make_sockaddr(int family, const char *addr_str, __u16 port, struct sockaddr_storage *addr, socklen_t *len);char *ping_command (int family);int get_socket_local_port (int sock_fd); -int get_hw_ring_size (char *ifname,struct ethtool_ringparam *ring_param); -int set_hw_ring_size (char *ifname,struct ethtool_ringparam *ring_param);int open_tuntap (const char *dev_name,bool need_mac);
tools/testing/selftests/net/Makefile +2 -0
@@ -140,6 +140,7 @@ TEST_PROGS := \ # end of TEST_PROGS TEST_PROGS_EXTENDED := \ + test_xsk.sh \ xfrm_policy_add_speed.sh \ # end of TEST_PROGS_EXTENDED
@@ -210,6 +211,7 @@ TEST_FILES := \ in_netns.sh \ lib.sh \ settings \ + xsk_prereqs.sh \ # end of TEST_FILES # YNL files, must be before "include ..lib.mk"
tools/testing/selftests/net/config +1 -0
@@ -143,5 +143,6 @@ CONFIG_USER_NS=y CONFIG_VETH=y CONFIG_VLAN_8021Q=y CONFIG_VXLAN=m +CONFIG_XDP_SOCKETS=y CONFIG_XFRM_INTERFACE=m CONFIG_XFRM_USER=m
tools/testing/selftests/net/lib/.gitignore +2 -0
@@ -2,3 +2,5 @@ csum gro xdp_helper +xsk_xdp_progs.skel.h +xskxceiver
tools/testing/selftests/net/lib/Makefile +25 -0
@@ -5,6 +5,15 @@ CFLAGS += -I../../../../../usr/include/ $(KHDR_INCLUDES) # Additional include paths needed by kselftest.h CFLAGS += -I../../ +# xskxceiver needs a working bpftool to generate its skeleton +BPFTOOL ?= bpftool +HAS_BPFTOOL := $(shell $(BPFTOOL) version >/dev/null 2>&1 && echo y) +ifeq ($(HAS_BPFTOOL),y) +COND_GEN_FILES += xskxceiver +else +$(warning excluding xskxceiver, bpftool not installed or not working) +endif + TEST_FILES := \ ../../../../net/ynl \ ../../../../../Documentation/netlink/specs \
@@ -13,6 +22,7 @@ TEST_FILES := \ TEST_GEN_FILES := \ $(patsubst %.c,%.o,$(wildcard *.bpf.c)) \ + $(COND_GEN_FILES) \ csum \ gro \ xdp_helper \
@@ -22,4 +32,19 @@ TEST_INCLUDES := $(wildcard py/*.py sh/*.sh) include ../../lib.mk +BPF_PROG_DIRS := xsk include ../bpf.mk + +# AF_XDP test engine used by net/test_xsk.sh. +XSK_SRCS := $(filter-out %.bpf.c,$(wildcard xsk/*.c)) \ + $(top_srcdir)/tools/lib/find_bit.c + +$(OUTPUT)/xskxceiver: $(XSK_SRCS) $(wildcard xsk/*.h) \ + $(OUTPUT)/xsk_xdp_progs.skel.h $(BPFOBJ) + $(call msg,CC,,$@) + $(Q)$(CC) -I$(top_srcdir)/tools/include $(CFLAGS) -I$(OUTPUT) \ + -I$(SCRATCH_DIR)/include \ + $(XSK_SRCS) $(BPFOBJ) $(LDLIBS) -lelf -lz -lpthread -o $@ + +# TEST_GEN_FILES lacks xskxceiver when bpftool fails; clean it anyway. +EXTRA_CLEAN += $(OUTPUT)/xskxceiver
tools/testing/selftests/net/lib/xsk/test_xsk.c renamed from tools/testing/selftests/bpf/prog_tests/test_xsk.c +1 -1
@@ -1,4 +1,5 @@// SPDX-License-Identifier: GPL-2.0 +#include <arpa/inet.h> #include <bpf/bpf.h> #include <errno.h> #include <linux/bitmap.h>
@@ -13,7 +14,6 @@#include <sys/time.h> #include <unistd.h> -#include "network_helpers.h" #include "test_xsk.h" #include "xsk_xdp_common.h" #include "xsk_xdp_progs.skel.h"
tools/testing/selftests/net/lib/xsk/test_xsk.h renamed from tools/testing/selftests/bpf/prog_tests/test_xsk.h +1 -1
@@ -5,7 +5,7 @@#include <linux/ethtool.h> #include <linux/if_xdp.h> -#include "../kselftest.h" +#include "kselftest.h" #include "xsk.h" #ifndef SO_PREFER_BUSY_POLL
tools/testing/selftests/net/lib/xsk/xsk.c renamed from tools/testing/selftests/bpf/xsk.c +48 -1
58 lines not on this page · raw message
tools/testing/selftests/net/lib/xsk/xsk.h renamed from tools/testing/selftests/bpf/xsk.h +4 -0
@@ -15,6 +15,7 @@#include <stdio.h> #include <stdint.h> #include <stdbool.h> +#include <linux/ethtool.h> #include <linux/if_xdp.h> #include <bpf/libbpf.h>
@@ -242,6 +243,9 @@ void xsk_socket__delete(struct xsk_socket *xsk);int xsk_set_mtu (int ifindex,int mtu); +int get_hw_ring_size (char *ifname,struct ethtool_ringparam *ring_param); +int set_hw_ring_size (char *ifname,struct ethtool_ringparam *ring_param); + #ifdef __cplusplus }/* extern "C" */ #endif
tools/testing/selftests/net/lib/xsk/xsk_xdp_common.h renamed from tools/testing/selftests/bpf/xsk_xdp_common.h +0 -0
tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c renamed from tools/testing/selftests/bpf/progs/xsk_xdp_progs.c +1 -1
@@ -64,7 +64,7 @@ SEC("xdp") int xsk_xdp_shared_umem(struct xdp_md *xdp)void *data_end = (void *)(long )xdp->data_end;struct ethhdr *eth = data; -if (eth +1 > data_end) +if ((void *)(eth +1 ) > data_end)return XDP_DROP ;/* Redirecting packets based on the destination MAC address */
tools/testing/selftests/net/lib/xsk/xskxceiver.c renamed from tools/testing/selftests/bpf/xskxceiver.c +2 -5
@@ -81,6 +81,7 @@#include <linux/netdev.h> #include <linux/ethtool.h> #include <linux/align.h> +#include <linux/kernel.h> #include <arpa/inet.h> #include <net/if.h> #include <locale.h>
@@ -91,7 +92,7 @@#include <sys/mman.h> #include <sys/types.h> -#include "prog_tests/test_xsk.h" +#include "test_xsk.h" #include "xsk_xdp_progs.skel.h" #include "xsk.h" #include "xskxceiver.h"
@@ -100,14 +101,10 @@#include "kselftest.h" #include "xsk_xdp_common.h" -#include <network_helpers.h> -static bool opt_print_tests;static enum test_mode opt_mode =TEST_MODE_ALL ;static u32 opt_run_test =RUN_ALL_TESTS ; -void test__fail (void ) {/* for network_helpers.c */ } -static void __exit_with_error (int error,const char *file,const char *func,int line) { ksft_test_result_fail("[%s:%s:%i]: ERROR: %d/\"%s\"\n", file, func, line,
tools/testing/selftests/net/lib/xsk/xskxceiver.h renamed from tools/testing/selftests/bpf/xskxceiver.h +0 -0
tools/testing/selftests/net/test_xsk.sh renamed from tools/testing/selftests/bpf/test_xsk.sh +5 -0
@@ -103,6 +103,11 @@ do esac done +if [ ! -x "./${XSKOBJ}" ]; then + echo "xskxceiver was not built; skipping" + exit $ksft_skip +fi + TEST_NAME="PREREQUISITES" URANDOM=/dev/urandom
tools/testing/selftests/net/xsk_prereqs.sh renamed from tools/testing/selftests/bpf/xsk_prereqs.sh +1 -1
@@ -8,7 +8,7 @@ ksft_xfail=2 ksft_xpass=3 ksft_skip=4 -XSKOBJ=xskxceiver +XSKOBJ=lib/xskxceiver validate_root_exec() {
Signature · 1 line
2.43.0
Re: [PATCH v2 net-next 3/4] selftests: xsk: move the AF_XDP test suite to selftests/net
Hi,
Quoted 19 lines · Maciej Fijalkowski
Move the xskxceiver engine, the
AF_XDPuserspace library, the test definitions and the XDP program tonet/lib/xsk, andtest_xsk.shwithxsk_prereqs.shto selftests/net.net/lib builds the XDP program and its skeleton with the bpf.mk rules, and skips xskxceiver with a warning when bpftool does not work, in which case
test_xsk.shskips too. Listtest_xsk.shinTEST_PROGS_EXTENDED, so that it is installed but NIPA does not run it
yet: it runs every case, flaky ones included.xskxceiver builds against the uapi headers from make headers, whose
linux/netlink.hdoes not pull inlinux/kernel.h, so include it formin_t()directly. Puttools/includeahead of CFLAGS, so that in O= builds a stale usr/include in the source tree does not shadow itslinux/kernel.handlinux/types.h. Move the ethtool ring helpers fromnetwork_helpersintoxsk.c, and cast to void * in the bound check of the XDP program, as bpf.mk does not build with -Wno-compare-distinct-pointer-types.
Quoted 7 lines
xdp_hw_metadataand thexdp_metadatatest keep usingxsk.cfromnet/lib/xsk: selftests/bpf builds xsk.o from there in place of the find_bit.o rule, which onlytest_xsk.cneeded. UpdateMAINTAINERS.Reviewed-by Björn Töpel <[email protected]>Signed-off-by Maciej Fijalkowski <[email protected]>
This patch fails to cross-compile when using RiscV as a target, cf the output in :
https://netdevci.bootlin.com/stmmac/outputs/905943-bootlin-stmmac-motorcomm/build
I'm not quite sure this is an infra problem on my end, any chance you can look this up ?
looks like it fails to include <asm/fence.h>
Maxime
Maciej Fijalkowski
maintainerPATCH v2 4/4 selftests: net: move xdp_hw_metadata from selftests/bpf
In reply to Maciej FijalkowskiMove xdp_hw_metadata and its XDP program to selftests/net, next to the AF_XDP library in net/lib/xsk that the tool is built from.
The tool used test_progs and network_helpers only for start_server(), two checksum helpers and strscpy(). Open the UDP socket with a local helper, copy csum_tcpudp_magic() and csum_ipv6_magic(), and fill ifr_name with snprintf(). Build the XDP program against the uapi headers rather than vmlinux.h: mirror struct vlan_hdr and enum xdp_rss_hash_type, and cast to void * in the bound checks.
Build the tool only when bpftool works, and install it without running it, as it needs a NIC and a peer that sends it traffic. Copy xdp_metadata.h rather than move it, as the xdp_metadata test in test_progs still uses it. Update xsk-tx-metadata.rst and the XDP entry of MAINTAINERS.
---
Documentation/networking/xsk-tx-metadata.rst | 2 +-
MAINTAINERS | 1 +
tools/testing/selftests/bpf/.gitignore | 1 -
tools/testing/selftests/bpf/Makefile | 8 --
tools/testing/selftests/net/.gitignore | 2 +
tools/testing/selftests/net/Makefile | 20 +++++
.../xdp_hw_metadata.bpf.c} | 35 +++++---
.../selftests/{bpf => net}/xdp_hw_metadata.c | 81 +++++++++++++++++--
tools/testing/selftests/net/xdp_metadata.h | 67 +++++++++++++++
9 files changed, 190 insertions(+), 27 deletions(-)
rename tools/testing/selftests/{bpf/progs/xdp_hw_metadata.c => net/xdp_hw_metadata.bpf.c} (75%)
rename tools/testing/selftests/{bpf => net}/xdp_hw_metadata.c (92%)
create mode 100644 tools/testing/selftests/net/xdp_metadata.hDocumentation/networking/xsk-tx-metadata.rst +1 -1
@@ -144,6 +144,6 @@ See ``tools/net/ynl/samples/netdev.c`` on how to query this information. Example ======= -See ``tools/testing/selftests/bpf/xdp_hw_metadata.c`` for an example +See ``tools/testing/selftests/net/xdp_hw_metadata.c`` for an example program that handles TX metadata. Also see https://github.com/fomichev/xskgen for a more bare-bones example.
MAINTAINERS +1 -0
@@ -30531,6 +30531,7 @@ F: net/core/xdp.c F: samples/bpf/xdp* F: tools/testing/selftests/bpf/*/*xdp* F: tools/testing/selftests/bpf/*xdp* +F: tools/testing/selftests/net/*xdp* K: (?:\b|_)xdp(?:\b|_) XDP SOCKETS (AF_XDP)
tools/testing/selftests/bpf/.gitignore +0 -1
@@ -38,7 +38,6 @@ test_cpp *.tmp xdp_redirect_multi xdp_synproxy -xdp_hw_metadata xdp_features verification_cert.h *.BTF
tools/testing/selftests/bpf/Makefile +0 -8
@@ -56,7 +56,6 @@ TEST_GEN_PROGS_EXTENDED = \ test_cpp \ veristat \ xdp_features \ - xdp_hw_metadata \ xdp_synproxy TEST_GEN_FILES += $(TEST_KMODS) liburandom_read.so urandom_read sign-file uprobe_multi
@@ -568,13 +567,6 @@ $(OUTPUT)/test_verifier: test_verifier.c verifier/tests.h $(BPFOBJ) | $(OUTPUT) $(call msg,BINARY,,$@) $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ -$(OUTPUT)/xdp_hw_metadata: xdp_hw_metadata.c ../net/lib/xsk/xsk.c network_helpers.c \ - $(TOOLSDIR)/lib/find_bit.c xdp_metadata.h \ - ../net/lib/xsk/xsk.h network_helpers.h test_progs.h bpf_util.h \ - $(OUTPUT)/xdp_hw_metadata.skel.h $(BPFOBJ) | $(OUTPUT) - $(call msg,BINARY,,$@) - $(Q)$(CC) $(CFLAGS) $(filter %.a %.o %.c,$^) $(LDLIBS) -o $@ - $(OUTPUT)/xdp_features: xdp_features.c network_helpers.c xdp_features.h \ network_helpers.h \ test_progs.h bpf_util.h $(OUTPUT)/xdp_features.skel.h \
tools/testing/selftests/net/.gitignore +2 -0
@@ -60,3 +60,5 @@ udp_splice_checksum udpgso udpgso_bench_rx udpgso_bench_tx +xdp_hw_metadata +xdp_hw_metadata.skel.h
tools/testing/selftests/net/Makefile +20 -0
@@ -226,6 +226,17 @@ TEST_GEN_PROGS += $(YNL_GEN_PROGS) TEST_GEN_FILES += $(patsubst %.c,%.o,$(wildcard *.bpf.c)) +# xdp_hw_metadata needs a working bpftool to generate its skeleton +BPFTOOL ?= bpftool +HAS_BPFTOOL := $(shell $(BPFTOOL) version >/dev/null 2>&1 && echo y) +ifeq ($(HAS_BPFTOOL),y) +COND_GEN_FILES += xdp_hw_metadata +else +$(warning excluding xdp_hw_metadata, bpftool not installed or not working) +endif + +TEST_GEN_FILES += $(COND_GEN_FILES) + TEST_INCLUDES := forwarding/lib.sh include ../lib.mk
@@ -249,3 +260,12 @@ $(OUTPUT)/bind_bhash: LDLIBS += -lpthread $(OUTPUT)/io_uring_zerocopy_tx: CFLAGS += -I../../../include/ include bpf.mk + +# Reference tool for checking XDP RX/TX metadata on real HW, built with +# the AF_XDP library of net/lib/xsk. +$(OUTPUT)/xdp_hw_metadata: xdp_hw_metadata.c xdp_metadata.h lib/xsk/xsk.c \ + lib/xsk/xsk.h $(OUTPUT)/xdp_hw_metadata.skel.h $(BPFOBJ) + $(call msg,CC,,$@) + $(Q)$(CC) -I$(top_srcdir)/tools/include $(CFLAGS) -I$(OUTPUT) \ + -I$(SCRATCH_DIR)/include \ + $(filter %.c,$^) $(BPFOBJ) $(LDLIBS) -lelf -lz -o $@
tools/testing/selftests/net/xdp_hw_metadata.bpf.c renamed from tools/testing/selftests/bpf/progs/xdp_hw_metadata.c +26 -9
@@ -1,10 +1,23 @@// SPDX-License-Identifier: GPL-2.0 -#include <vmlinux.h> +#include <linux/bpf.h> +#include <linux/if_ether.h> +#include <linux/in.h> +#include <linux/ip.h> +#include <linux/ipv6.h> +#include <linux/udp.h> #include "xdp_metadata.h" #include <bpf/bpf_helpers.h> #include <bpf/bpf_endian.h> +/* Mirror of struct vlan_hdr from include/linux/if_vlan.h, which is not +* part of the UAPI headers. +*/ +struct vlan_hdr { +__be16 h_vlan_TCI; +__be16 h_vlan_encapsulated_proto; +}; +struct { __uint(type, BPF_MAP_TYPE_XSKMAP); __uint(max_entries, 256);
@@ -39,25 +52,29 @@ int rx(struct xdp_md *ctx) data_end = (void *)(long )ctx->data_end; eth = data; -if (eth +1 < data_end && (eth->h_proto ==bpf_htons (ETH_P_8021AD ) || - eth->h_proto ==bpf_htons (ETH_P_8021Q ))) +if ((void *)(eth +1 ) < data_end && + (eth->h_proto ==bpf_htons (ETH_P_8021AD ) || + eth->h_proto ==bpf_htons (ETH_P_8021Q ))) eth = (void *)eth +sizeof (struct vlan_hdr ); -if (eth +1 < data_end && eth->h_proto ==bpf_htons (ETH_P_8021Q )) +if ((void *)(eth +1 ) < data_end && + eth->h_proto ==bpf_htons (ETH_P_8021Q )) eth = (void *)eth +sizeof (struct vlan_hdr ); -if (eth +1 < data_end) { +if ((void *)(eth +1 ) < data_end) {if (eth->h_proto ==bpf_htons (ETH_P_IP )) { iph = (void *)(eth +1 ); -if (iph +1 < data_end && iph->protocol ==IPPROTO_UDP ) +if ((void *)(iph +1 ) < data_end && + iph->protocol ==IPPROTO_UDP ) udp = (void *)(iph +1 ); }if (eth->h_proto ==bpf_htons (ETH_P_IPV6 )) { ip6h = (void *)(eth +1 ); -if (ip6h +1 < data_end && ip6h->nexthdr ==IPPROTO_UDP ) +if ((void *)(ip6h +1 ) < data_end && + ip6h->nexthdr ==IPPROTO_UDP ) udp = (void *)(ip6h +1 ); } -if (udp && udp +1 > data_end) +if (udp && (void *)(udp +1 ) > data_end) udp =NULL ; }
@@ -82,7 +99,7 @@ int rx(struct xdp_md *ctx) data_meta = (void *)(long )ctx->data_meta; meta = data_meta; -if (meta +1 > data) { +if ((void *)(meta +1 ) > data) {__sync_add_and_fetch (&pkts_fail,1 );return XDP_PASS ; }
tools/testing/selftests/net/xdp_hw_metadata.c renamed from tools/testing/selftests/bpf/xdp_hw_metadata.c +73 -8
120 lines not on this page · raw message
tools/testing/selftests/net/xdp_metadata.h new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.43.0
Jakub Kicinski
maintainerQuoted 5 lines · On Mon, 9 Nov 2026 20:30:44 +0100 Maciej Fijalkowski wrote:
As the maintainers asked, this series is the first step of moving the
AF_XDPselftests from selftests/bpf to selftests/net: the code moves and builds from its new location, without changing what the tests do. The rework [0] posted as "selftests: net: migrateAF_XDPtest suite over to net" (v4) will follow on top of this move.
Close enough, but why did you skip CCing bpf@ :(
BPF folks, I made a tag for both of us to merge / pull to avoid Makefile conflicts in selftests, the original series is here:
https://lore.kernel.org/all/[email protected]/
PR text follows. Please LMK if / how you'd like to proceed.
The following changes since commit 7475ea8b58616b33c04afb976cf0fbaad9dd63fb:
Linux 7.4-rc2 (2026-11-08 16:22:20 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.git tags/bpf-net-xsk-move
for you to fetch changes up to d01fb5c8113055e3d1b7f573261ae6a30abf4e53:
selftests: net: move xdp_hw_metadata from selftests/bpf (2026-11-11 15:50:02 -0800)
----------------------------------------------------------------
Maciej says:
As the maintainers asked, this series is the first step of moving the AF_XDP selftests from selftests/bpf to selftests/net: the code moves and builds from its new location, without changing what the tests do. The rework [0] posted as "selftests: net: migrate AF_XDP test suite over to net" (v4) will follow on top of this move.
Patch 1 drops the test_progs wrapper of the AF_XDP tests, patch 2 adds a generic BPF skeleton rule to net/bpf.mk, patch 3 moves xskxceiver, its library and test_xsk.sh to selftests/net, and patch 4 (new, not covered at [0]) moves xdp_hw_metadata, which is built from the same library.
The xdp_metadata test stays in test_progs: it covers BPF core behaviour, and moving it would mean rewriting it for the kselftest harness. It keeps using xsk.c from net/lib/xsk.
xskxceiver and xdp_hw_metadata are the first users of bpftool at build time in selftests/net. NIPA has bpftool, but 0-day and KernelCI build net without it, so both tools are skipped with a warning when bpftool is missing or does not run.
test_xsk.sh is installed but not run by run_tests, so NIPA does not pick it up: it runs every case, including flaky ones, and some cases leak page_pool pages after skb_pp_cow_data() in generic XDP mode on veth-based runs. Until a later step makes the suite fit for NIPA, no CI runs the AF_XDP tests. test_xsk.sh is being removed by [0] but it is kept here as there is no other feasible way to run the test suite (if needed) until we come up with an upstreamable Python runner.
----------------------------------------------------------------
Maciej Fijalkowski (4):
selftests/bpf: drop the test_progs AF_XDP wrapper
selftests: net: add a generic rule for BPF skeletons
selftests: xsk: move the AF_XDP test suite to selftests/net
selftests: net: move xdp_hw_metadata from selftests/bpf
Documentation/networking/af_xdp.rst | 6 +-
Documentation/networking/xsk-tx-metadata.rst | 2 +-
MAINTAINERS | 4 +-
tools/testing/selftests/bpf/.gitignore | 2 -
tools/testing/selftests/bpf/Makefile | 29 +---
tools/testing/selftests/bpf/Makefile.buildvars | 6 +-
tools/testing/selftests/bpf/network_helpers.c | 48 ------
tools/testing/selftests/bpf/network_helpers.h | 2 -
tools/testing/selftests/bpf/prog_tests/xsk.c | 170 ---------------------
tools/testing/selftests/net/.gitignore | 2 +
tools/testing/selftests/net/Makefile | 22 +++
tools/testing/selftests/net/bpf.mk | 13 +-
tools/testing/selftests/net/config | 1 +
tools/testing/selftests/net/lib/.gitignore | 2 +
tools/testing/selftests/net/lib/Makefile | 25 +++
.../{bpf/prog_tests => net/lib/xsk}/test_xsk.c | 2 +-
.../{bpf/prog_tests => net/lib/xsk}/test_xsk.h | 5 +-
tools/testing/selftests/{bpf => net/lib/xsk}/xsk.c | 49 +++++-
tools/testing/selftests/{bpf => net/lib/xsk}/xsk.h | 4 +
.../{bpf => net/lib/xsk}/xsk_xdp_common.h | 0
.../lib/xsk/xsk_xdp_progs.bpf.c} | 2 +-
.../selftests/{bpf => net/lib/xsk}/xskxceiver.c | 17 +--
.../selftests/{bpf => net/lib/xsk}/xskxceiver.h | 0
tools/testing/selftests/{bpf => net}/test_xsk.sh | 5 +
.../xdp_hw_metadata.bpf.c} | 35 +++--
.../selftests/{bpf => net}/xdp_hw_metadata.c | 81 +++++++++-
tools/testing/selftests/net/xdp_metadata.h | 67 ++++++++
.../testing/selftests/{bpf => net}/xsk_prereqs.sh | 2 +-
28 files changed, 309 insertions(+), 294 deletions(-)
delete mode 100644 tools/testing/selftests/bpf/prog_tests/xsk.c
rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.c (99%)
rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.h (99%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.c (95%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.h (97%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk_xdp_common.h (100%)
rename tools/testing/selftests/{bpf/progs/xsk_xdp_progs.c => net/lib/xsk/xsk_xdp_progs.bpf.c} (98%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.c (96%)
rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.h (100%)
rename tools/testing/selftests/{bpf => net}/test_xsk.sh (98%)
rename tools/testing/selftests/{bpf/progs/xdp_hw_metadata.c => net/xdp_hw_metadata.bpf.c} (75%)
rename tools/testing/selftests/{bpf => net}/xdp_hw_metadata.c (92%)
create mode 100644 tools/testing/selftests/net/xdp_metadata.h
rename tools/testing/selftests/{bpf => net}/xsk_prereqs.sh (98%)Alexei Starovoitov
Acked-byQuoted 4 lines · Jakub Kicinski
BPF folks, I made a tag for both of us to merge / pull to avoid
Makefileconflicts in selftests, the original series is here:
https://lore.kernel.org/all/[email protected]/
PR text follows. Please LMK if / how you'd like to proceed.
Take it into net-next.
We don't need to take them into bpf-nex atm.
There are no conflicts today and we don't plan to touch those files or nearby. If selftests/bpf/Makefile conflicts it should be easy to resolve, if not we'll pull later.
In case you want to add to merge commit:
Quoted 7 lines · Alexei Starovoitov
Quoted 4 lines · Jakub Kicinski
BPF folks, I made a tag for both of us to merge / pull to avoid
Makefileconflicts in selftests, the original series is here:
https://lore.kernel.org/all/[email protected]/
PR text follows. Please LMK if / how you'd like to proceed.
Quoted 5 lines
Take it into net-next.
We don't need to take them into bpf-nex atm.
There are no conflicts today and we don't plan to touch those files or nearby. If selftests/bpf/Makefile conflicts it should be easy to resolve, if not we'll pull later.
"we'll pull later" ... is now.
pulled into bpf-next too.
Just to avoid thinking about possible conflicts.
Thanks!
Maciej Fijalkowski
maintainerQuoted 8 lines · Jakub Kicinski
Quoted 5 lines · On Mon, 9 Nov 2026 20:30:44 +0100 Maciej Fijalkowski wrote:
As the maintainers asked, this series is the first step of moving the
AF_XDPselftests from selftests/bpf to selftests/net: the code moves and builds from its new location, without changing what the tests do. The rework [0] posted as "selftests: net: migrateAF_XDPtest suite over to net" (v4) will follow on top of this move.Close enough, but why did you skip CCing bpf@ :(
I used some previous xsk to/cc setup and given that we transferred to netdev, I missed good old bpf ;(
Do you want me to re-spin with Alexei's ack or will you take it as is?
Quoted 101 lines
BPF folks, I made a tag for both of us to merge / pull to avoid
Makefileconflicts in selftests, the original series is here:
https://lore.kernel.org/all/[email protected]/
PR text follows. Please LMK if / how you'd like to proceed.The following changes since commit
7475ea8b58616b33c04afb976cf0fbaad9dd63fb:Linux 7.4-rc2 (2026-11-08 16:22:20 -0800)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kuba/linux.gittags/bpf-net-xsk-movefor you to fetch changes up to
d01fb5c8113055e3d1b7f573261ae6a30abf4e53:selftests: net: move
xdp_hw_metadatafrom selftests/bpf (2026-11-11 15:50:02 -0800)----------------------------------------------------------------
Maciej says:As the maintainers asked, this series is the first step of moving the
AF_XDPselftests from selftests/bpf to selftests/net: the code moves and builds from its new location, without changing what the tests do. The rework [0] posted as "selftests: net: migrateAF_XDPtest suite over to net" (v4) will follow on top of this move.Patch 1 drops the
test_progswrapper of theAF_XDPtests, patch 2 adds a generic BPF skeleton rule tonet/bpf.mk, patch 3 moves xskxceiver, its library andtest_xsk.shto selftests/net, and patch 4 (new, not covered at [0]) movesxdp_hw_metadata, which is built from the same library.The
xdp_metadatatest stays intest_progs: it covers BPF core behaviour, and moving it would mean rewriting it for the kselftest harness. It keeps usingxsk.cfromnet/lib/xsk.xskxceiver and
xdp_hw_metadataare the first users of bpftool at build time in selftests/net. NIPA has bpftool, but 0-day and KernelCI build net without it, so both tools are skipped with a warning when bpftool is missing or does not run.
test_xsk.shis installed but not run byrun_tests, so NIPA does not pick it up: it runs every case, including flaky ones, and some cases leakpage_poolpages afterskb_pp_cow_data()in generic XDP mode on veth-based runs. Until a later step makes the suite fit for NIPA, no CI runs theAF_XDPtests.test_xsk.shis being removed by [0] but it is kept here as there is no other feasible way to run the test suite (if needed) until we come up with an upstreamable Python runner.Signed-off-by Jakub Kicinski <[email protected]>----------------------------------------------------------------
Maciej Fijalkowski (4):
selftests/bpf: drop thetest_progsAF_XDPwrapper
selftests: net: add a generic rule for BPF skeletons
selftests: xsk: move theAF_XDPtest suite to selftests/net
selftests: net: movexdp_hw_metadatafrom selftests/bpfDocumentation/networking/af_xdp.rst | 6 +- Documentation/networking/xsk-tx-metadata.rst | 2 +- MAINTAINERS | 4 +- tools/testing/selftests/bpf/.gitignore | 2 - tools/testing/selftests/bpf/Makefile | 29 +--- tools/testing/selftests/bpf/Makefile.buildvars | 6 +- tools/testing/selftests/bpf/network_helpers.c | 48 ------ tools/testing/selftests/bpf/network_helpers.h | 2 - tools/testing/selftests/bpf/prog_tests/xsk.c | 170 --------------------- tools/testing/selftests/net/.gitignore | 2 + tools/testing/selftests/net/Makefile | 22 +++ tools/testing/selftests/net/bpf.mk | 13 +- tools/testing/selftests/net/config | 1 + tools/testing/selftests/net/lib/.gitignore | 2 + tools/testing/selftests/net/lib/Makefile | 25 +++ .../{bpf/prog_tests => net/lib/xsk}/test_xsk.c | 2 +- .../{bpf/prog_tests => net/lib/xsk}/test_xsk.h | 5 +- tools/testing/selftests/{bpf => net/lib/xsk}/xsk.c | 49 +++++- tools/testing/selftests/{bpf => net/lib/xsk}/xsk.h | 4 + .../{bpf => net/lib/xsk}/xsk_xdp_common.h | 0 .../lib/xsk/xsk_xdp_progs.bpf.c} | 2 +- .../selftests/{bpf => net/lib/xsk}/xskxceiver.c | 17 +-- .../selftests/{bpf => net/lib/xsk}/xskxceiver.h | 0 tools/testing/selftests/{bpf => net}/test_xsk.sh | 5 + .../xdp_hw_metadata.bpf.c} | 35 +++-- .../selftests/{bpf => net}/xdp_hw_metadata.c | 81 +++++++++- tools/testing/selftests/net/xdp_metadata.h | 67 ++++++++ .../testing/selftests/{bpf => net}/xsk_prereqs.sh | 2 +- 28 files changed, 309 insertions(+), 294 deletions(-) delete mode 100644 tools/testing/selftests/bpf/prog_tests/xsk.c rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.c (99%) rename tools/testing/selftests/{bpf/prog_tests => net/lib/xsk}/test_xsk.h (99%) rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.c (95%) rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk.h (97%) rename tools/testing/selftests/{bpf => net/lib/xsk}/xsk_xdp_common.h (100%) rename tools/testing/selftests/{bpf/progs/xsk_xdp_progs.c => net/lib/xsk/xsk_xdp_progs.bpf.c} (98%) rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.c (96%) rename tools/testing/selftests/{bpf => net/lib/xsk}/xskxceiver.h (100%) rename tools/testing/selftests/{bpf => net}/test_xsk.sh (98%) rename tools/testing/selftests/{bpf/progs/xdp_hw_metadata.c => net/xdp_hw_metadata.bpf.c} (75%) rename tools/testing/selftests/{bpf => net}/xdp_hw_metadata.c (92%) create mode 100644 tools/testing/selftests/net/xdp_metadata.h rename tools/testing/selftests/{bpf => net}/xsk_prereqs.sh (98%)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Mon, 9 Nov 2026 20:30:44 +0100 you wrote:
v1:
https://lore.kernel.org/netdev/[email protected]/v1->v2:* Patch 4: add
xdp_hw_metadatatoTEST_GEN_FILESviaCOND_GEN_FILES, asnet/lib/Makefiledoes for xskxceiver, so that net/Makefile passes NIPA'scheck_selftest.
* Add Stanislav's tag.[...]
Here is the summary with links:
- [v2,net-next,1/4] selftests/bpf: drop the test_progs AF_XDP wrapper
https://git.kernel.org/netdev/net-next/c/f34d7544eddc - [v2,net-next,2/4] selftests: net: add a generic rule for BPF skeletons https://git.kernel.org/netdev/net-next/c/8698de5e7146 - [v2,net-next,3/4] selftests: xsk: move the AF_XDP test suite to selftests/net https://git.kernel.org/netdev/net-next/c/e8f9d8237988 - [v2,net-next,4/4] selftests: net: move xdp_hw_metadata from selftests/bpf https://git.kernel.org/netdev/net-next/c/d01fb5c81130
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html