Thread View: linux.kernel.netdev
9 messages
9 total messages
Started by Maciej Fijalkowski
Thu, 05 Nov 2026 13:41
[PATCH net-next 0/4] selftests: move the AF_XDP test suite from bpf to net
Author: Maciej Fijalkowski
Date: Thu, 05 Nov 2026 13:41
Date: Thu, 05 Nov 2026 13:41
90 lines
13629 bytes
13629 bytes
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/20261016174338.787135-1-maciej.fijalkowski@intel.com/
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 | 20 +++
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, 307 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: 7b6ab4dbc156e2f96419715130b3d5738a306c93
--
2.43.0
[PATCH net-next 1/4] selftests/bpf: drop the test_progs AF_XDP wrapper
Author: Maciej Fijalkowski
Date: Thu, 05 Nov 2026 13:41
Date: Thu, 05 Nov 2026 13:41
247 lines
17200 bytes
17200 bytes
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.
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
.../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
diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.h b/tools/testing/selftests/bpf/prog_tests/test_xsk.h
index 03753ddc5dcd..69158b67466c 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_xsk.h
+++ b/tools/testing/selftests/bpf/prog_tests/test_xsk.h
@@ -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},
diff --git a/tools/testing/selftests/bpf/prog_tests/xsk.c b/tools/testing/selftests/bpf/prog_tests/xsk.c
deleted file mode 100644
index 772f3dd7ce64..000000000000
--- a/tools/testing/selftests/bpf/prog_tests/xsk.c
+++ /dev/null
@@ -1,170 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <net/if.h>
-#include <stdarg.h>
-
-#include "network_helpers.h"
-#include "test_progs.h"
-#include "test_xsk.h"
-#include "xsk_xdp_progs.skel.h"
-
-#define VETH_RX "veth0"
-#define VETH_TX "veth1"
-#define MTU 1500
-
-int setup_veth(bool busy_poll)
-{
- SYS(fail,
- "ip link add %s numtxqueues 4 numrxqueues 4 type veth peer name %s numtxqueues 4 numrxqueues 4",
- VETH_RX, VETH_TX);
- SYS(fail, "sysctl -wq net.ipv6.conf.%s.disable_ipv6=1", VETH_RX);
- SYS(fail, "sysctl -wq net.ipv6.conf.%s.disable_ipv6=1", VETH_TX);
-
- if (busy_poll) {
- SYS(fail, "echo 2 > /sys/class/net/%s/napi_defer_hard_irqs", VETH_RX);
- SYS(fail, "echo 200000 > /sys/class/net/%s/gro_flush_timeout", VETH_RX);
- SYS(fail, "echo 2 > /sys/class/net/%s/napi_defer_hard_irqs", VETH_TX);
- SYS(fail, "echo 200000 > /sys/class/net/%s/gro_flush_timeout", VETH_TX);
- }
-
- SYS(fail, "ip link set %s mtu %d", VETH_RX, MTU);
- SYS(fail, "ip link set %s mtu %d", VETH_TX, MTU);
- SYS(fail, "ip link set %s up", VETH_RX);
- SYS(fail, "ip link set %s up", VETH_TX);
-
- return 0;
-
-fail:
- return -1;
-}
-
-void delete_veth(void)
-{
- SYS_NOFAIL("ip link del %s", VETH_RX);
- SYS_NOFAIL("ip link del %s", VETH_TX);
-}
-
-int configure_ifobj(struct ifobject *tx, struct ifobject *rx)
-{
- rx->ifindex = if_nametoindex(VETH_RX);
- if (!ASSERT_OK_FD(rx->ifindex, "get RX ifindex"))
- return -1;
-
- tx->ifindex = if_nametoindex(VETH_TX);
- if (!ASSERT_OK_FD(tx->ifindex, "get TX ifindex"))
- return -1;
-
- tx->shared_umem = false;
- rx->shared_umem = false;
-
-
- return 0;
-}
-
-static void test_xsk(const struct test_spec *test_to_run, enum test_mode mode)
-{
- u32 max_frags, umem_tailroom, cache_line_size;
- struct ifobject *ifobj_tx, *ifobj_rx;
- struct test_spec test;
- int ret;
-
- ifobj_tx = ifobject_create();
- if (!ASSERT_OK_PTR(ifobj_tx, "create ifobj_tx"))
- return;
-
- ifobj_rx = ifobject_create();
- if (!ASSERT_OK_PTR(ifobj_rx, "create ifobj_rx"))
- goto delete_tx;
-
- if (!ASSERT_OK(configure_ifobj(ifobj_tx, ifobj_rx), "configure ifobj"))
- goto delete_rx;
-
- ret = get_hw_ring_size(ifobj_tx->ifname, &ifobj_tx->ring);
- if (!ret) {
- ifobj_tx->hw_ring_size_supp = true;
- ifobj_tx->set_ring.default_tx = ifobj_tx->ring.tx_pending;
- ifobj_tx->set_ring.default_rx = ifobj_tx->ring.rx_pending;
- }
-
- cache_line_size = read_procfs_val(SMP_CACHE_BYTES_PATH);
- if (!cache_line_size)
- cache_line_size = 64;
-
- max_frags = read_procfs_val(MAX_SKB_FRAGS_PATH);
- if (!max_frags)
- max_frags = 17;
-
- ifobj_tx->max_skb_frags = max_frags;
- ifobj_rx->max_skb_frags = max_frags;
-
- /* 48 bytes is a part of skb_shared_info w/o frags array;
- * 16 bytes is sizeof(skb_frag_t)
- */
- umem_tailroom = ALIGN(48 + (max_frags * 16), cache_line_size);
- ifobj_tx->umem_tailroom = umem_tailroom;
- ifobj_rx->umem_tailroom = umem_tailroom;
-
- if (!ASSERT_OK(init_iface(ifobj_rx, worker_testapp_validate_rx), "init RX"))
- goto delete_rx;
- if (!ASSERT_OK(init_iface(ifobj_tx, worker_testapp_validate_tx), "init TX"))
- goto delete_rx;
-
- test_init(&test, ifobj_tx, ifobj_rx, 0, &tests[0]);
-
- test.tx_pkt_stream_default = pkt_stream_generate(DEFAULT_PKT_CNT, MIN_PKT_SIZE);
- if (!ASSERT_OK_PTR(test.tx_pkt_stream_default, "TX pkt generation"))
- goto delete_rx;
- test.rx_pkt_stream_default = pkt_stream_generate(DEFAULT_PKT_CNT, MIN_PKT_SIZE);
- if (!ASSERT_OK_PTR(test.rx_pkt_stream_default, "RX pkt generation"))
- goto delete_rx;
-
-
- test_init(&test, ifobj_tx, ifobj_rx, mode, test_to_run);
- ret = test.test_func(&test);
- if (ret != TEST_SKIP)
- ASSERT_OK(ret, "Run test");
- pkt_stream_restore_default(&test);
-
- if (ifobj_tx->hw_ring_size_supp)
- hw_ring_size_reset(ifobj_tx);
-
- pkt_stream_delete(test.tx_pkt_stream_default);
- pkt_stream_delete(test.rx_pkt_stream_default);
- xsk_xdp_progs__destroy(ifobj_tx->xdp_progs);
- xsk_xdp_progs__destroy(ifobj_rx->xdp_progs);
-
-delete_rx:
- ifobject_delete(ifobj_rx);
-delete_tx:
- ifobject_delete(ifobj_tx);
-}
-
-void test_ns_xsk_skb(void)
-{
- int i;
-
- if (!ASSERT_OK(setup_veth(false), "setup veth"))
- return;
-
- for (i = 0; i < ARRAY_SIZE(tests); i++) {
- if (test__start_subtest(tests[i].name))
- test_xsk(&tests[i], TEST_MODE_SKB);
- }
-
- delete_veth();
-}
-
-void test_ns_xsk_drv(void)
-{
- int i;
-
- if (!ASSERT_OK(setup_veth(false), "setup veth"))
- return;
-
- for (i = 0; i < ARRAY_SIZE(tests); i++) {
- if (test__start_subtest(tests[i].name))
- test_xsk(&tests[i], TEST_MODE_DRV);
- }
-
- delete_veth();
-}
-
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index 7dad8556a722..6cf95a44c8c0 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -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);
--
2.43.0
[PATCH net-next 2/4] selftests: net: add a generic rule for BPF skeletons
Author: Maciej Fijalkowski
Date: Thu, 05 Nov 2026 13:41
Date: Thu, 05 Nov 2026 13:41
61 lines
11463 bytes
11463 bytes
Tests 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.
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
tools/testing/selftests/net/bpf.mk | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/net/bpf.mk b/tools/testing/selftests/net/bpf.mk
index a4f6755dd894..e0e10cf44af3 100644
--- a/tools/testing/selftests/net/bpf.mk
+++ b/tools/testing/selftests/net/bpf.mk
@@ -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)
--
2.43.0
[PATCH net-next 3/4] selftests: xsk: move the AF_XDP test suite to selftests/net
Author: Maciej Fijalkowski
Date: Thu, 05 Nov 2026 13:41
Date: Thu, 05 Nov 2026 13:41
594 lines
30975 bytes
30975 bytes
Move 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.
Reviewed-by: Björn Töpel <bjorn@kernel.org>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
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%)
diff --git a/Documentation/networking/af_xdp.rst b/Documentation/networking/af_xdp.rst
index cc3f0d16b28f..538e71adb759 100644
--- a/Documentation/networking/af_xdp.rst
+++ b/Documentation/networking/af_xdp.rst
@@ -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
=======
diff --git a/MAINTAINERS b/MAINTAINERS
index 09713dc4c6a7..12e444f1f7a6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -30434,7 +30434,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é <roger@xenproject.org>
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore
index b815bf0d8877..cd098c0271ef 100644
--- a/tools/testing/selftests/bpf/.gitignore
+++ b/tools/testing/selftests/bpf/.gitignore
@@ -36,7 +36,6 @@ test_cpp
/uprobe_multi
*.ko
*.tmp
-xskxceiver
xdp_redirect_multi
xdp_synproxy
xdp_hw_metadata
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index c99e0f623e10..203f2cedaf77 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -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 $@
diff --git a/tools/testing/selftests/bpf/Makefile.buildvars b/tools/testing/selftests/bpf/Makefile.buildvars
index d2a0c0031b87..7e0dc8fa67cd 100644
--- a/tools/testing/selftests/bpf/Makefile.buildvars
+++ b/tools/testing/selftests/bpf/Makefile.buildvars
@@ -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)
diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c
index d27dc79475de..70c6e4271ca1 100644
--- a/tools/testing/selftests/bpf/network_helpers.c
+++ b/tools/testing/selftests/bpf/network_helpers.c
@@ -646,54 +646,6 @@ int get_socket_local_port(int sock_fd)
return -1;
}
-int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
-{
- struct ifreq ifr = {0};
- int sockfd, err;
-
- sockfd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sockfd < 0)
- return -errno;
-
- memcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-
- ring_param->cmd = ETHTOOL_GRINGPARAM;
- ifr.ifr_data = (char *)ring_param;
-
- if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) {
- err = errno;
- close(sockfd);
- return -err;
- }
-
- close(sockfd);
- return 0;
-}
-
-int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
-{
- struct ifreq ifr = {0};
- int sockfd, err;
-
- sockfd = socket(AF_INET, SOCK_DGRAM, 0);
- if (sockfd < 0)
- return -errno;
-
- memcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
-
- ring_param->cmd = ETHTOOL_SRINGPARAM;
- ifr.ifr_data = (char *)ring_param;
-
- if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) {
- err = errno;
- close(sockfd);
- return -err;
- }
-
- close(sockfd);
- return 0;
-}
-
struct send_recv_arg {
int fd;
uint32_t bytes;
diff --git a/tools/testing/selftests/bpf/network_helpers.h b/tools/testing/selftests/bpf/network_helpers.h
index 878c9fc5c37c..c7a1fd119e37 100644
--- a/tools/testing/selftests/bpf/network_helpers.h
+++ b/tools/testing/selftests/bpf/network_helpers.h
@@ -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);
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 9180b9bec515..7dba412401ea 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -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"
diff --git a/tools/testing/selftests/net/config b/tools/testing/selftests/net/config
index 7a89e2618d4c..162df07f84e1 100644
--- a/tools/testing/selftests/net/config
+++ b/tools/testing/selftests/net/config
@@ -141,5 +141,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
diff --git a/tools/testing/selftests/net/lib/.gitignore b/tools/testing/selftests/net/lib/.gitignore
index 6cd2b762af5d..1106fef3041f 100644
--- a/tools/testing/selftests/net/lib/.gitignore
+++ b/tools/testing/selftests/net/lib/.gitignore
@@ -2,3 +2,5 @@
csum
gro
xdp_helper
+xsk_xdp_progs.skel.h
+xskxceiver
diff --git a/tools/testing/selftests/net/lib/Makefile b/tools/testing/selftests/net/lib/Makefile
index ff83603397d0..0a6cd733883d 100644
--- a/tools/testing/selftests/net/lib/Makefile
+++ b/tools/testing/selftests/net/lib/Makefile
@@ -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
diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.c b/tools/testing/selftests/net/lib/xsk/test_xsk.c
similarity index 99%
rename from tools/testing/selftests/bpf/prog_tests/test_xsk.c
rename to tools/testing/selftests/net/lib/xsk/test_xsk.c
index 4549358cc8c2..ca161511f1e5 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_xsk.c
+++ b/tools/testing/selftests/net/lib/xsk/test_xsk.c
@@ -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"
diff --git a/tools/testing/selftests/bpf/prog_tests/test_xsk.h b/tools/testing/selftests/net/lib/xsk/test_xsk.h
similarity index 99%
rename from tools/testing/selftests/bpf/prog_tests/test_xsk.h
rename to tools/testing/selftests/net/lib/xsk/test_xsk.h
index 69158b67466c..2506b0dcc6bf 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_xsk.h
+++ b/tools/testing/selftests/net/lib/xsk/test_xsk.h
@@ -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
diff --git a/tools/testing/selftests/bpf/xsk.c b/tools/testing/selftests/net/lib/xsk/xsk.c
similarity index 95%
rename from tools/testing/selftests/bpf/xsk.c
rename to tools/testing/selftests/net/lib/xsk/xsk.c
index 25d568abf0f2..6bd32caf5d08 100644
--- a/tools/testing/selftests/bpf/xsk.c
+++ b/tools/testing/selftests/net/lib/xsk/xsk.c
@@ -35,7 +35,6 @@
#include <bpf/bpf.h>
#include <bpf/libbpf.h>
#include "xsk.h"
-#include "bpf_util.h"
#ifndef SOL_XDP
#define SOL_XDP 283
@@ -779,3 +778,51 @@ void xsk_socket__delete(struct xsk_socket *xsk)
close(xsk->fd);
free(xsk);
}
+
+int get_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
+{
+ struct ifreq ifr = {0};
+ int sockfd, err;
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockfd < 0)
+ return -errno;
+
+ memcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+
+ ring_param->cmd = ETHTOOL_GRINGPARAM;
+ ifr.ifr_data = (char *)ring_param;
+
+ if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) {
+ err = errno;
+ close(sockfd);
+ return -err;
+ }
+
+ close(sockfd);
+ return 0;
+}
+
+int set_hw_ring_size(char *ifname, struct ethtool_ringparam *ring_param)
+{
+ struct ifreq ifr = {0};
+ int sockfd, err;
+
+ sockfd = socket(AF_INET, SOCK_DGRAM, 0);
+ if (sockfd < 0)
+ return -errno;
+
+ memcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
+
+ ring_param->cmd = ETHTOOL_SRINGPARAM;
+ ifr.ifr_data = (char *)ring_param;
+
+ if (ioctl(sockfd, SIOCETHTOOL, &ifr) < 0) {
+ err = errno;
+ close(sockfd);
+ return -err;
+ }
+
+ close(sockfd);
+ return 0;
+}
diff --git a/tools/testing/selftests/bpf/xsk.h b/tools/testing/selftests/net/lib/xsk/xsk.h
similarity index 97%
rename from tools/testing/selftests/bpf/xsk.h
rename to tools/testing/selftests/net/lib/xsk/xsk.h
index 48729da142c2..3f1fea999763 100644
--- a/tools/testing/selftests/bpf/xsk.h
+++ b/tools/testing/selftests/net/lib/xsk/xsk.h
@@ -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
diff --git a/tools/testing/selftests/bpf/xsk_xdp_common.h b/tools/testing/selftests/net/lib/xsk/xsk_xdp_common.h
similarity index 100%
rename from tools/testing/selftests/bpf/xsk_xdp_common.h
rename to tools/testing/selftests/net/lib/xsk/xsk_xdp_common.h
diff --git a/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c b/tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c
similarity index 98%
rename from tools/testing/selftests/bpf/progs/xsk_xdp_progs.c
rename to tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c
index 023d8befd4ca..84e5f4732289 100644
--- a/tools/testing/selftests/bpf/progs/xsk_xdp_progs.c
+++ b/tools/testing/selftests/net/lib/xsk/xsk_xdp_progs.bpf.c
@@ -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 */
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
similarity index 99%
rename from tools/testing/selftests/bpf/xskxceiver.c
rename to tools/testing/selftests/net/lib/xsk/xskxceiver.c
index 6cf95a44c8c0..0a63651434a5 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/net/lib/xsk/xskxceiver.c
@@ -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,
diff --git a/tools/testing/selftests/bpf/xskxceiver.h b/tools/testing/selftests/net/lib/xsk/xskxceiver.h
similarity index 100%
rename from tools/testing/selftests/bpf/xskxceiver.h
rename to tools/testing/selftests/net/lib/xsk/xskxceiver.h
diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/net/test_xsk.sh
similarity index 98%
rename from tools/testing/selftests/bpf/test_xsk.sh
rename to tools/testing/selftests/net/test_xsk.sh
index 62db060298a4..448cd2462278 100755
--- a/tools/testing/selftests/bpf/test_xsk.sh
+++ b/tools/testing/selftests/net/test_xsk.sh
@@ -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
diff --git a/tools/testing/selftests/bpf/xsk_prereqs.sh b/tools/testing/selftests/net/xsk_prereqs.sh
similarity index 98%
rename from tools/testing/selftests/bpf/xsk_prereqs.sh
rename to tools/testing/selftests/net/xsk_prereqs.sh
index 47c7b8064f38..d8fe786e967c 100755
--- a/tools/testing/selftests/bpf/xsk_prereqs.sh
+++ b/tools/testing/selftests/net/xsk_prereqs.sh
@@ -8,7 +8,7 @@ ksft_xfail=2
ksft_xpass=3
ksft_skip=4
-XSKOBJ=xskxceiver
+XSKOBJ=lib/xskxceiver
validate_root_exec()
{
--
2.43.0
[PATCH net-next 4/4] selftests: net: move xdp_hw_metadata from selftests/bpf
Author: Maciej Fijalkowski
Date: Thu, 05 Nov 2026 13:41
Date: Thu, 05 Nov 2026 13:41
424 lines
22862 bytes
22862 bytes
Move 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.
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
---
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 | 18 +++++
.../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, 188 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.h
diff --git a/Documentation/networking/xsk-tx-metadata.rst b/Documentation/networking/xsk-tx-metadata.rst
index f240930ca1df..ac15e5fddc6b 100644
--- a/Documentation/networking/xsk-tx-metadata.rst
+++ b/Documentation/networking/xsk-tx-metadata.rst
@@ -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.
diff --git a/MAINTAINERS b/MAINTAINERS
index 12e444f1f7a6..2123857f3365 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -30418,6 +30418,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)
diff --git a/tools/testing/selftests/bpf/.gitignore b/tools/testing/selftests/bpf/.gitignore
index cd098c0271ef..e318a38035d2 100644
--- a/tools/testing/selftests/bpf/.gitignore
+++ b/tools/testing/selftests/bpf/.gitignore
@@ -38,7 +38,6 @@ test_cpp
*.tmp
xdp_redirect_multi
xdp_synproxy
-xdp_hw_metadata
xdp_features
verification_cert.h
*.BTF
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 203f2cedaf77..2d46e47bab60 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -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 \
diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selftests/net/.gitignore
index 21412510ac26..0bd88b48a53c 100644
--- a/tools/testing/selftests/net/.gitignore
+++ b/tools/testing/selftests/net/.gitignore
@@ -60,3 +60,5 @@ udp_splice_checksum
udpgso
udpgso_bench_rx
udpgso_bench_tx
+xdp_hw_metadata
+xdp_hw_metadata.skel.h
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 7dba412401ea..9925360a9a98 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -226,6 +226,15 @@ 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)
+TEST_GEN_FILES += xdp_hw_metadata
+else
+$(warning excluding xdp_hw_metadata, bpftool not installed or not working)
+endif
+
TEST_INCLUDES := forwarding/lib.sh
include ../lib.mk
@@ -249,3 +258,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 $@
diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/net/xdp_hw_metadata.bpf.c
similarity index 75%
rename from tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
rename to tools/testing/selftests/net/xdp_hw_metadata.bpf.c
index 330ece2eabdb..a183436646b1 100644
--- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
+++ b/tools/testing/selftests/net/xdp_hw_metadata.bpf.c
@@ -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;
}
diff --git a/tools/testing/selftests/bpf/xdp_hw_metadata.c b/tools/testing/selftests/net/xdp_hw_metadata.c
similarity index 92%
rename from tools/testing/selftests/bpf/xdp_hw_metadata.c
rename to tools/testing/selftests/net/xdp_hw_metadata.c
index ab3f5fc56e86..6db928f1ffdc 100644
--- a/tools/testing/selftests/bpf/xdp_hw_metadata.c
+++ b/tools/testing/selftests/net/xdp_hw_metadata.c
@@ -16,11 +16,11 @@
* - TX launch time HW offload is requested for transmission
*/
-#include <test_progs.h>
-#include <network_helpers.h>
#include "xdp_hw_metadata.skel.h"
-#include "xsk.h"
+#include "lib/xsk/xsk.h"
+#include <bpf/bpf.h>
+#include <errno.h>
#include <error.h>
#include <linux/kernel.h>
#include <linux/bits.h>
@@ -47,6 +47,9 @@
#include <linux/ethtool.h>
#include <sys/socket.h>
#include <arpa/inet.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
+#include <signal.h>
#include "xdp_metadata.h"
@@ -87,7 +90,69 @@ int launch_time_queue;
system(command); \
})
-void test__fail(void) { /* for network_helpers.c */ }
+static __u16 csum_fold(__u32 csum)
+{
+ csum = (csum & 0xffff) + (csum >> 16);
+ csum = (csum & 0xffff) + (csum >> 16);
+
+ return (__u16)~csum;
+}
+
+static __sum16 csum_tcpudp_magic(__be32 saddr, __be32 daddr, __u32 len,
+ __u8 proto, __wsum csum)
+{
+ __u64 s = csum;
+
+ s += (__u32)saddr;
+ s += (__u32)daddr;
+ s += htons(proto + len);
+ s = (s & 0xffffffff) + (s >> 32);
+ s = (s & 0xffffffff) + (s >> 32);
+
+ return csum_fold((__u32)s);
+}
+
+static __sum16 csum_ipv6_magic(const struct in6_addr *saddr,
+ const struct in6_addr *daddr, __u32 len,
+ __u8 proto, __wsum csum)
+{
+ __u64 s = csum;
+ int i;
+
+ for (i = 0; i < 4; i++)
+ s += (__u32)saddr->s6_addr32[i];
+ for (i = 0; i < 4; i++)
+ s += (__u32)daddr->s6_addr32[i];
+ s += htons(proto + len);
+ s = (s & 0xffffffff) + (s >> 32);
+ s = (s & 0xffffffff) + (s >> 32);
+
+ return csum_fold((__u32)s);
+}
+
+static int open_udp_server(__u16 port)
+{
+ struct sockaddr_in6 addr = {
+ .sin6_family = AF_INET6,
+ .sin6_port = htons(port),
+ .sin6_addr = IN6ADDR_ANY_INIT,
+ };
+ struct timeval timeo = { .tv_sec = 1 };
+ int fd;
+
+ fd = socket(AF_INET6, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return -1;
+
+ if (setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeo, sizeof(timeo)) ||
+ setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &timeo, sizeof(timeo)) ||
+ bind(fd, (struct sockaddr *)&addr, sizeof(addr))) {
+ close(fd);
+ return -1;
+ }
+
+ return fd;
+}
static int open_xsk(int ifindex, struct xsk *xsk, __u32 queue_id)
{
@@ -550,7 +615,7 @@ static int rxq_num(const char *ifname)
struct ifreq ifr = {
.ifr_data = (void *)&ch,
};
- strscpy(ifr.ifr_name, ifname);
+ snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);
int fd, ret;
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
@@ -571,7 +636,7 @@ static void hwtstamp_ioctl(int op, const char *ifname, struct hwtstamp_config *c
struct ifreq ifr = {
.ifr_data = (void *)cfg,
};
- strscpy(ifr.ifr_name, ifname);
+ snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", ifname);
int fd, ret;
fd = socket(AF_UNIX, SOCK_DGRAM, 0);
@@ -853,9 +918,9 @@ int main(int argc, char *argv[])
error(1, -ret, "xdp_hw_metadata__load");
printf("prepare skb endpoint...\n");
- server_fd = start_server(AF_INET6, SOCK_DGRAM, NULL, 9092, 1000);
+ server_fd = open_udp_server(9092);
if (server_fd < 0)
- error(1, errno, "start_server");
+ error(1, errno, "open_udp_server");
timestamping_enable(server_fd,
SOF_TIMESTAMPING_SOFTWARE |
SOF_TIMESTAMPING_RAW_HARDWARE);
diff --git a/tools/testing/selftests/net/xdp_metadata.h b/tools/testing/selftests/net/xdp_metadata.h
new file mode 100644
index 000000000000..9371889f76d3
--- /dev/null
+++ b/tools/testing/selftests/net/xdp_metadata.h
@@ -0,0 +1,67 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#pragma once
+
+#ifndef ETH_P_IP
+#define ETH_P_IP 0x0800
+#endif
+
+#ifndef ETH_P_IPV6
+#define ETH_P_IPV6 0x86DD
+#endif
+
+#ifndef ETH_P_8021Q
+#define ETH_P_8021Q 0x8100
+#endif
+
+#ifndef ETH_P_8021AD
+#define ETH_P_8021AD 0x88A8
+#endif
+
+#ifndef BIT
+#define BIT(nr) (1 << (nr))
+#endif
+
+/* Non-existent checksum status */
+#define XDP_CHECKSUM_MAGIC BIT(2)
+
+/* Mirror of enum xdp_rss_hash_type from include/net/xdp.h, which is not
+ * part of the UAPI headers.
+ */
+enum xdp_rss_hash_type {
+ XDP_RSS_L3_IPV4 = BIT(0),
+ XDP_RSS_L3_IPV6 = BIT(1),
+ XDP_RSS_L3_DYNHDR = BIT(2),
+ XDP_RSS_L4 = BIT(3),
+ XDP_RSS_L4_TCP = BIT(4),
+ XDP_RSS_L4_UDP = BIT(5),
+ XDP_RSS_L4_SCTP = BIT(6),
+ XDP_RSS_L4_IPSEC = BIT(7),
+ XDP_RSS_L4_ICMP = BIT(8),
+};
+
+enum xdp_meta_field {
+ XDP_META_FIELD_TS = BIT(0),
+ XDP_META_FIELD_RSS = BIT(1),
+ XDP_META_FIELD_VLAN_TAG = BIT(2),
+};
+
+struct xdp_meta {
+ union {
+ __u64 rx_timestamp;
+ __s32 rx_timestamp_err;
+ };
+ __u64 xdp_timestamp;
+ __u32 rx_hash;
+ union {
+ __u32 rx_hash_type;
+ __s32 rx_hash_err;
+ };
+ union {
+ struct {
+ __be16 rx_vlan_proto;
+ __u16 rx_vlan_tci;
+ };
+ __s32 rx_vlan_tag_err;
+ };
+ enum xdp_meta_field hint_valid;
+};
--
2.43.0
Re: [PATCH net-next 0/4] selftests: move the AF_XDP test suite from bpf to net
Author: Stanislav Fomichev
Date: Thu, 05 Nov 2026 20:43
Date: Thu, 05 Nov 2026 20:43
44 lines
12730 bytes
12730 bytes
On 11/05, Maciej Fijalkowski wrote: > 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/20261016174338.787135-1-maciej.fijalkowski@intel.com/ > > 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 Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Re: [PATCH net-next 0/4] selftests: move the AF_XDP test suite from bpf to net
Author: Maciej Fijalkowski
Date: Mon, 09 Nov 2026 12:44
Date: Mon, 09 Nov 2026 12:44
51 lines
18627 bytes
18627 bytes
On Thu, Nov 05, 2026 at 12:43:36PM -0800, Stanislav Fomichev wrote: > On 11/05, Maciej Fijalkowski wrote: > > 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/20261016174338.787135-1-maciej.fijalkowski@intel.com/ > > > > 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 > > Acked-by: Stanislav Fomichev <sdf@fomichev.me> Thanks for acking! However for some reason clashiko missed this set, can someone remind me what could be the case here? I also see in SUIE that check_selftest failed - is it mandatory to repost in this case?
Re: [PATCH net-next 0/4] selftests: move the AF_XDP test suite from bpf to net
Author: Stanislav Fomichev
Date: Mon, 09 Nov 2026 16:52
Date: Mon, 09 Nov 2026 16:52
62 lines
13518 bytes
13518 bytes
On 11/09, Maciej Fijalkowski wrote: > On Thu, Nov 05, 2026 at 12:43:36PM -0800, Stanislav Fomichev wrote: > > On 11/05, Maciej Fijalkowski wrote: > > > 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/20261016174338.787135-1-maciej.fijalkowski@intel.com/ > > > > > > 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 > > > > Acked-by: Stanislav Fomichev <sdf@fomichev.me> > > Thanks for acking! However for some reason clashiko missed this set, can > someone remind me what could be the case here? > > I also see in SUIE that check_selftest failed - is it mandatory to repost > in this case? ``` Bad format: tools/testing/selftests/net/Makefile ``` Not super descriptive :-( Maybe check on your side if this is complaining about something legit? https://github.com/linux-netdev/nipa/blob/main/tests/patch/check_selftest/validate_makefile_format.py
Re: [PATCH net-next 0/4] selftests: move the AF_XDP test suite from bpf to net
Author: Maciej Fijalkowski
Date: Mon, 09 Nov 2026 19:12
Date: Mon, 09 Nov 2026 19:12
66 lines
19406 bytes
19406 bytes
On Mon, Nov 09, 2026 at 08:52:20AM -0800, Stanislav Fomichev wrote: > On 11/09, Maciej Fijalkowski wrote: > > On Thu, Nov 05, 2026 at 12:43:36PM -0800, Stanislav Fomichev wrote: > > > On 11/05, Maciej Fijalkowski wrote: > > > > 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/20261016174338.787135-1-maciej.fijalkowski@intel.com/ > > > > > > > > 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 > > > > > > Acked-by: Stanislav Fomichev <sdf@fomichev.me> > > > > Thanks for acking! However for some reason clashiko missed this set, can > > someone remind me what could be the case here? > > > > I also see in SUIE that check_selftest failed - is it mandatory to repost > > in this case? > > ``` > Bad format: tools/testing/selftests/net/Makefile > ``` > > Not super descriptive :-( > > Maybe check on your side if this is complaining about something legit? > > https://github.com/linux-netdev/nipa/blob/main/tests/patch/check_selftest/validate_makefile_format.py It is upset about redefining TEST_GEN_FILES on patch 4. Will send a v2 that fixes it.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads