]> git.feebdaed.xyz Git - 0xmirror/xdp-tools.git/log
0xmirror/xdp-tools.git
10 days agolibxdp: skip devbind selftests if no kernel support main
Jalal Mostafa [Tue, 16 Sep 2025 12:13:40 +0000 (14:13 +0200)]
libxdp: skip devbind selftests if no kernel support

If no kernel support for `BPF_F_XDP_DEV_BOUND_ONLY`, skip
micro-selftests that has this flag.

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
10 days agolibxdp: add selftest for dispatcher v2 compatibility
Jalal Mostafa [Fri, 12 Sep 2025 13:30:15 +0000 (15:30 +0200)]
libxdp: add selftest for dispatcher v2 compatibility

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
10 days agolibxdp: indent test_dispatcher_versions selftest using tabs
Jalal Mostafa [Fri, 12 Sep 2025 13:29:14 +0000 (15:29 +0200)]
libxdp: indent test_dispatcher_versions selftest using tabs

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
10 days agolibxdp: Add selftest for device binding
Jalal Mostafa [Thu, 3 Apr 2025 16:29:19 +0000 (18:29 +0200)]
libxdp: Add selftest for device binding

Add a selftest program for libxdp device binding, testing the different
permutations of loading a program with and without the flag.

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
10 days agolibxdp: add device binding support
Jalal Mostafa [Thu, 3 Apr 2025 16:20:07 +0000 (18:20 +0200)]
libxdp: add device binding support

Kernel 6.3 supported for some NIC offloads for XDP programs.
The feature in XDP is known to be XDP hints. XDP hints are only
supported if the XDP program is bound to the NIC device using the
BPF_F_XDP_DEV_BOUND_ONLY binding flag.

The device binding flag is represented through `XDP_ATTACH_DEVBIND',
a new attach flag for `xdp_program__attach`. Device binding is
propagated to the dispatcher. Any subsequent programs attachments
are rejected if they are different from the already running dispatcher
on a network interface.

The flag is recored using a new variable in `struct xdp_dispatcher_config`.

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
10 days agoheaders/linux: Update bpf.h to kernel version 6.3
Jalal Mostafa [Sun, 23 Mar 2025 17:14:37 +0000 (18:14 +0100)]
headers/linux: Update bpf.h to kernel version 6.3

Update the bpf.h UAPI header from the Linux to that from kernel version
6.3. We need the definition of BPF_F_XDP_DEV_BOUND_ONLY to support it
in libxdp.

Signed-off-by: Jalal Mostafa <jalal.a.mostapha@gmail.com>
12 days agoxdp-bench: Add drop mode for egress action
Dragos Tatulea [Sun, 16 Nov 2025 14:07:11 +0000 (16:07 +0200)]
xdp-bench: Add drop mode for egress action

Simple XDP_DROP program as egress action.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
12 days agoxdp-bench: Add devmap egress action option
Dragos Tatulea [Sun, 16 Nov 2025 13:58:23 +0000 (15:58 +0200)]
xdp-bench: Add devmap egress action option

Add a new `--egress-action` option for devmap and devmap-multi that
allows selecting different actions for egress.

This change only adds the existing forward action.

egress-action is initialized to DEVMAP_EGRESS_NONE to allow
for checking if the user selected `--egress-action` without
`--load-egress`.

Signed-off-by: Dragos Tatulea <dtatulea@nvidia.com>
2 weeks ago.github/workflows: Add 6.17 and 6.18 kernels to CI matrix
Toke Høiland-Jørgensen [Tue, 9 Dec 2025 10:49:45 +0000 (11:49 +0100)]
.github/workflows: Add 6.17 and 6.18 kernels to CI matrix

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 weeks agoBump version to v1.5.8
Toke Høiland-Jørgensen [Sat, 29 Nov 2025 11:39:53 +0000 (12:39 +0100)]
Bump version to v1.5.8

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 weeks agoconfigure: Avoid populating .rodata in libbpf test
Toke Høiland-Jørgensen [Sat, 29 Nov 2025 11:46:59 +0000 (12:46 +0100)]
configure: Avoid populating .rodata in libbpf test

When checking for a working libbpf, the test includes constant strings
which end up in .rodata. This can cause compilation failures when
LDFLAGS contain values that enforces position-independent code. We don't
really need the string values, so just replace the constants with NULL
values in the test program to avoid the error.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 weeks agoutil/params.c: Fix option help printer definitions
Toke Høiland-Jørgensen [Mon, 24 Nov 2025 12:08:05 +0000 (13:08 +0100)]
util/params.c: Fix option help printer definitions

The helper print definitions were not updated with the addition of a u8
argument type, breaking help output for enums. Add another member to
realign things.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 weeks agolibxdp: Use __noinline__ reserved attribute for XDP dispatcher
Christian Marangi [Wed, 18 Jan 2023 18:00:54 +0000 (19:00 +0100)]
libxdp: Use __noinline__ reserved attribute for XDP dispatcher

The use of noinline can collide with macro definitions. Use the reserved
__noinline__ attribute to avoid this resulting in a compilation error.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
[a.heider: adapt lib/libxdp/protocol.org too]
Signed-off-by: Andre Heider <a.heider@gmail.com>
[Fix up xdp_dispatcher_v1.c as well, reword commit message]
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 weeks agoconfigure: Respect LDFLAGS in test compilations
Daniel Golle [Mon, 24 Nov 2025 11:09:58 +0000 (12:09 +0100)]
configure: Respect LDFLAGS in test compilations

The build environment may set LDFLAGS, but the test compilations in the
configure script doesn't respect this, which can lead to compilation
failures, and thus false negatives for the tested features.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
[Imported the downstream patch from OpenWrt]
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 weeks agoxdp-trafficgen: Add an option to set the hop limit in UDP mode
Toke Høiland-Jørgensen [Fri, 7 Nov 2025 14:41:52 +0000 (15:41 +0100)]
xdp-trafficgen: Add an option to set the hop limit in UDP mode

It can be useful to run tests that forward packets; to allow this, we
need a longer hop count, so add an option to 'xdp-trafficgen udp' to add
this.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agoxdp-loader: Make feature flags printing future-proof
Asbjørn Sloth Tønnesen [Wed, 8 Oct 2025 08:41:37 +0000 (08:41 +0000)]
xdp-loader: Make feature flags printing future-proof

In netdev.h, NETDEV_XDP_ACT_MASK is declared as private, so it should
only be used inside the kernel, and according to Jakub Kicinski then
"user space should not care about it"[1].

  linux$ git grep -B1 NETDEV_XDP_ACT_MASK include/
  include/uapi/linux/netdev.h-    /* private: */
  include/uapi/linux/netdev.h:    NETDEV_XDP_ACT_MASK = 127,

In this specific case, then this code is buggy. If a new feature flag
is added to the uapi header, and hence included in NETDEV_XDP_ACT_MASK,
and xdp-tools is not updated, or an older version is re-build in a
distro, with newer linux headers, then NETDEV_XDP_ACT_MASK can contain
a new feature flag, and if the new flag is observed, then it will neither
be checked nor trigger the unknown feature printing.

This patch moves the flags into a constant array, and while looping over
them in iface_print_xdp_features(), it builds a local mask consisting only
of the tested flags. The local mask is used to replace NETDEV_XDP_ACT_MASK.

[1] https://lore.kernel.org/netdev/20230614211715.01940bbd@kernel.org/

Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
2 months agotest_runner: Wait for background output file to appear before moving it
Toke Høiland-Jørgensen [Mon, 6 Oct 2025 14:59:22 +0000 (16:59 +0200)]
test_runner: Wait for background output file to appear before moving it

On slow test execution systems (vm-in-vm setups), spawning a background
process can take so long that the output file is not created before the
test script tries to move it into place. This in turns leads to lost
output and subsequent test failures.

Fix this by waiting on the temporary file to appear before moving it.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agoBump version to v1.5.7
Toke Høiland-Jørgensen [Fri, 3 Oct 2025 14:10:36 +0000 (16:10 +0200)]
Bump version to v1.5.7

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agoxdp-filter/tests: Use inside address for arping -A
Toke Høiland-Jørgensen [Fri, 3 Oct 2025 10:53:17 +0000 (12:53 +0200)]
xdp-filter/tests: Use inside address for arping -A

When sending ARP replies using arping, we should be suing the inside
IPv4 address, or we'll get a bind error.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Keep trying to unmount bpffs
Toke Høiland-Jørgensen [Fri, 3 Oct 2025 10:30:08 +0000 (12:30 +0200)]
libxdp/tests: Keep trying to unmount bpffs

There can be multiple bpffs instances mounted on top of each other, so
when unmounting them for the test, run in a loop until we succeed (or
get an error).

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Load test BPF programs from TESTS_DIR
Toke Høiland-Jørgensen [Fri, 3 Oct 2025 10:28:39 +0000 (12:28 +0200)]
libxdp/tests: Load test BPF programs from TESTS_DIR

Use open_bpf_file() and the embedded libxdp program search to make sure
we can open the test objects used in the libxdp tests regardless of the
current working directory. This is needed to make the libxdp tests run
after installation.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Import find_bpf_file() function from util
Toke Høiland-Jørgensen [Fri, 3 Oct 2025 10:08:00 +0000 (12:08 +0200)]
libxdp/tests: Import find_bpf_file() function from util

This will make it possible to run the tests with a custom BPF object
path.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Support running tests outside of build environment
Toke Høiland-Jørgensen [Fri, 3 Oct 2025 09:47:37 +0000 (11:47 +0200)]
libxdp/tests: Support running tests outside of build environment

Skip the linker tests if CC is not set, and make sure to consistently
use TESTS_DIR for the path to the test utility.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp: Install selftests as part of 'make install'
Toke Høiland-Jørgensen [Thu, 2 Oct 2025 12:55:00 +0000 (14:55 +0200)]
libxdp: Install selftests as part of 'make install'

Install the libxdp selftests as part of the 'make install' target, so
they are distributed as part of the xdp-tools tests.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Move skip_if_missing_libxdp_compat() function into libxdp_tests
Toke Høiland-Jørgensen [Thu, 2 Oct 2025 12:54:28 +0000 (14:54 +0200)]
libxdp/tests: Move skip_if_missing_libxdp_compat() function into libxdp_tests

Make this local to the libxdp tests so we can run them from the
test_runner.sh script in util/

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/Makefile: Add missing .PHONY designations for clean and install
Toke Høiland-Jørgensen [Thu, 2 Oct 2025 12:53:40 +0000 (14:53 +0200)]
libxdp/Makefile: Add missing .PHONY designations for clean and install

The clean and install rules were missing .PHONY designations; let's add
them.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Always link some test programs statically
Toke Høiland-Jørgensen [Thu, 2 Oct 2025 12:22:40 +0000 (14:22 +0200)]
libxdp/tests: Always link some test programs statically

A few of the libxdp selftests uses hidden libxdp symbols, and so cannot
be linked statically. This causes the test builds to fail if
DYNAMIC_LIBXDP is set. Fix this by always linking these utilities
statically, regardless of the value of DYNAMIC_LIBXDP.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/Makefile: Remove back-dating of generated man page
Toke Høiland-Jørgensen [Thu, 2 Oct 2025 12:13:07 +0000 (14:13 +0200)]
libxdp/Makefile: Remove back-dating of generated man page

Remove the `touch -r` for the generated libxdp man page; it causes
spurious rebuilds and does not seem to serve any purpose.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
2 months agolibxdp/tests: Add libxdp.mk include
Toke Høiland-Jørgensen [Thu, 2 Oct 2025 11:46:20 +0000 (13:46 +0200)]
libxdp/tests: Add libxdp.mk include

The missing include means that the libxdp version was not defined which
caused a build dependency on libxdp.so. (with a trailing dot) that never
existed, which can lead to an infinite build recursion.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-filter: Add selftests for ARP and ICMPv6 neighbour requests
Toke Høiland-Jørgensen [Tue, 23 Sep 2025 15:29:14 +0000 (17:29 +0200)]
xdp-filter: Add selftests for ARP and ICMPv6 neighbour requests

Add tests for correctly filtering ARP and ICMPv6 neighbour packets to
the xdp-filter selftests, using ndisc6 and arping to generate the
packets.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotesting: Add ndisc6 and arping as required test tools
Toke Høiland-Jørgensen [Tue, 23 Sep 2025 15:13:44 +0000 (17:13 +0200)]
testing: Add ndisc6 and arping as required test tools

We will need those for adding selftests to the ARP/ICMP neighbour tests
for xdp-filter. Also re-enable ARP on the test interfaces so arping will
work.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-filter: Parse IPv6 neighbour solicitations
Toke Høiland-Jørgensen [Mon, 10 Feb 2025 11:54:48 +0000 (12:54 +0100)]
xdp-filter: Parse IPv6 neighbour solicitations

Like with ARP packets for IPv4, make sure we pass neighbour
solicitations and advertisements through the filter rules for IPv6, to
avoid connectivity breaking in deny-all mode.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-filter: Parse ARP packets
Toke Høiland-Jørgensen [Mon, 10 Feb 2025 11:16:15 +0000 (12:16 +0100)]
xdp-filter: Parse ARP packets

In deny-all mode xdp-filter breaks connectivity because it ends up
dropping ARP packets. Add parsing of ARP packets and run the src/target
IP of the ARP request/response through the same IP filter rules as the
IP packets themselves.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotest_runner: skip cleanup proc dir in teardown if no STATEDIR
Frank Liang [Mon, 14 Jul 2025 07:32:52 +0000 (15:32 +0800)]
test_runner: skip cleanup proc dir in teardown if no STATEDIR

teardown() tries to cleanup /proc dir and cannot exit normally
when misses required tool.

time /usr/share/xdp-tools/run_tests.sh
Running all tests from /usr/share/xdp-tools/tests
    Executing tests in separate net- and mount namespaces
Missing required tool: socat
^C

real 0m54.757s
user 0m2.434s
sys 0m49.946s

Signed-off-by: Frank Liang <xiliang@redhat.com>
3 months agotest_runner: Support retrying tests
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 13:38:38 +0000 (15:38 +0200)]
test_runner: Support retrying tests

Some of the xdpdump tests can be a bit flaky, so support automatically
retrying failed tests to avoid CI failures every time they fail.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotest-xdpdump: Drop unneeded escape for grep command
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 13:37:29 +0000 (15:37 +0200)]
test-xdpdump: Drop unneeded escape for grep command

Use arg separator instead.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months ago.github/workflows: Update to Ubuntu 24.04 and use system packages
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 07:46:53 +0000 (09:46 +0200)]
.github/workflows: Update to Ubuntu 24.04 and use system packages

Update the Ubuntu version used for the selftests to 24.04, and use the
system libbpf and bpftool packages. This should hopefully cut down on
test runner time.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-dump/tests: Don't assume a particular length of program IDs
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 12:27:07 +0000 (14:27 +0200)]
xdp-dump/tests: Don't assume a particular length of program IDs

The test script was using character-based 'cut' to extract the program
IDs from the xdpdump output, which fails once program IDs become
6-digit. Replace with awk field-based extraction to avoid this.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agolibxdp: Make sure to build the test files as part of the regular compile
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 11:16:42 +0000 (13:16 +0200)]
libxdp: Make sure to build the test files as part of the regular compile

Add a dependency to build the test helpers as part of the normal
compile; otherwise they won't be built until the 'make test' target is
run.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agolibxdp: Add a couple of missing newlines in debug output
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 11:01:04 +0000 (13:01 +0200)]
libxdp: Add a couple of missing newlines in debug output

We were missing newlines in a couple of debug output messages. Add them.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdpdump: Move "listening on" output later
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 11:00:13 +0000 (13:00 +0200)]
xdpdump: Move "listening on" output later

Make sure to output the "listening on" message as the very last thing
before entering the reporting loop; this way the message can be used as
an indicator that setup is complete and the capture is running.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdpdump: Flush stdout after finishing output
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:59:17 +0000 (12:59 +0200)]
xdpdump: Flush stdout after finishing output

Make sure to flush the stdout stream when exiting, before outputting the
end-of-run stats. This avoids output being interleaved because the stats
are written to stderr before stdout has finished flushing.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-dump/tests: Use start_tcpdump() and decrease timeouts
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:58:13 +0000 (12:58 +0200)]
xdp-dump/tests: Use start_tcpdump() and decrease timeouts

Use the newly added start_tcpdump() function and decrease the timeouts
in the xdpdump tests, to make them all run faster.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-forward/tests: Remove sleep and use start_socat function
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:56:23 +0000 (12:56 +0200)]
xdp-forward/tests: Remove sleep and use start_socat function

Remove the sleep after installing nft rules and use the start_socat
function to start the socat listener, while also decreasing the client
timeout to socat in the xdp-forward tests, in an attempt to make things
run faster.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-filter/tests: Use start_tcpdump() and decrease timeouts
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:55:37 +0000 (12:55 +0200)]
xdp-filter/tests: Use start_tcpdump() and decrease timeouts

Use the newly added start_tcpdump() function in the xdp-filter tests,
and decrease the timeouts to make the tests run faster.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotest_runner: Don't sleep after spawning background processes
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:54:03 +0000 (12:54 +0200)]
test_runner: Don't sleep after spawning background processes

Remove the sleep delays after spawning background processes. This delays
tests and is not deterministic. Instead, add a new start_tcpdump()
function which will explicitly wait for the "listening on" output to
appear in the output file, which indicates that the process has started
up successfully.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotest-runner: Monitor process exit instead of sleeping
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:51:20 +0000 (12:51 +0200)]
test-runner: Monitor process exit instead of sleeping

Instead of sleeping and re-issuing a kill unconditionally, loop and wait
for processes to exit; this avoids the wait in most cases, speeding up
test runs.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotest-runner: Disable ARP and multicast on test interfaces
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:50:23 +0000 (12:50 +0200)]
test-runner: Disable ARP and multicast on test interfaces

We still see the occasional multicast listener report on interfaces,
which makes tests fail. Completely disable ARP and multicast on the test
interfaces to avoid this.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotest_runner: Get MAC addresses later
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:49:46 +0000 (12:49 +0200)]
test_runner: Get MAC addresses later

Move the reading of MAC addresses even later in the netns setup phase to
make sure we get the right values.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agotesting/test_runner: Enable realtime output in verbose mode
Toke Høiland-Jørgensen [Thu, 18 Sep 2025 10:47:08 +0000 (12:47 +0200)]
testing/test_runner: Enable realtime output in verbose mode

When running in verbose mode, the test output was still cached until the
end of a test run, which makes it impossible to follow the progress of a
test. Rework the test execution function to enable real-time output in
verbose mode.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months ago.github/workflows: Include LLVM-21 in test matrix
Toke Høiland-Jørgensen [Wed, 17 Sep 2025 10:15:54 +0000 (12:15 +0200)]
.github/workflows: Include LLVM-21 in test matrix

Version 21 of the LLVM suite was released, let's add it to the test
matrix.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months ago.github/workflows: Update kernel versions
Toke Høiland-Jørgensen [Wed, 17 Sep 2025 10:13:30 +0000 (12:13 +0200)]
.github/workflows: Update kernel versions

The 6.14.7 images disappeared from the Fedora mirrors, so bump to
6.14.11, and also add a 6.16 kernel while we're at it.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoDoc: update libxdp README.org and man page with architecture support
Vincent Li [Sun, 27 Jul 2025 19:04:15 +0000 (12:04 -0700)]
Doc: update libxdp README.org and man page with architecture support

XDP multiprog on a single interface generally is supported by
architectures supporting BPF trampoline.

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
[ squash commits, rerun man page export on newer Emacs ]
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agolibxdp/tests: Mount bpffs before compatibility check
Toke Høiland-Jørgensen [Thu, 11 Sep 2025 09:53:11 +0000 (11:53 +0200)]
libxdp/tests: Mount bpffs before compatibility check

The compatibility checks were failing because there was no bpffs, which
means tests were skipped that shouldn't have. Reorder things so the
bpffs is mounted before the compatibility check.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agopackaging/rpm: Re-enable debug packages
Toke Høiland-Jørgensen [Thu, 21 Aug 2025 12:42:16 +0000 (14:42 +0200)]
packaging/rpm: Re-enable debug packages

Turns out the debug package build failure was something that only
occurred on my own machine, because ~/rpmbuild was a symlink. Fixing
this, there is no failure, so let's reinstate the debuginfo package.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoxdp-bench: Fix --extended switch for redirect-cpu mode
Toke Høiland-Jørgensen [Thu, 21 Aug 2025 08:23:22 +0000 (10:23 +0200)]
xdp-bench: Fix --extended switch for redirect-cpu mode

The option parsing for redirect-cpu contained a copy-paste error that
broke the --extended switch for that mode because it referred to the
wrong options struct. Fix this by referring to the right struct.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
3 months agoAdd Dockerfile
Joseph Ligier [Thu, 4 Sep 2025 11:35:29 +0000 (11:35 +0000)]
Add Dockerfile

Signed-off-by: Joseph Ligier <joseph.ligier@gmail.com>
4 months agoBump version to v1.5.6
Toke Høiland-Jørgensen [Fri, 15 Aug 2025 08:31:14 +0000 (10:31 +0200)]
Bump version to v1.5.6

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agotests/xdp-trafficgen: Skip tests if probe fails for any reason
Toke Høiland-Jørgensen [Thu, 14 Aug 2025 17:31:26 +0000 (19:31 +0200)]
tests/xdp-trafficgen: Skip tests if probe fails for any reason

The xdp-trafficgen tests were looking at particular return codes from
xdp-trafficgen; since the return code is not binary 1/0 depending on
probe results, just skip the tests if the probe fails for any reason.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-bench/tests: Don't remove interface until the test ends
Toke Høiland-Jørgensen [Thu, 14 Aug 2025 10:15:24 +0000 (12:15 +0200)]
xdp-bench/tests: Don't remove interface until the test ends

The previous commit mistakenly moved the interface teardown to before
the optional tests were executed, causing those tests to fail.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-bench: Skip incompatible tests if progmap support is unavaliable
Toke Høiland-Jørgensen [Wed, 13 Aug 2025 15:41:24 +0000 (17:41 +0200)]
xdp-bench: Skip incompatible tests if progmap support is unavaliable

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-trafficgen: Fix automatic loading of xdp_pass program
Toke Høiland-Jørgensen [Wed, 13 Aug 2025 15:11:56 +0000 (17:11 +0200)]
xdp-trafficgen: Fix automatic loading of xdp_pass program

The automatic loading of an xdp_pass program in xdp-trafficgen would
fail on systems that don't allow multi-attach of programs, because it's
attaching an already-loaded program. Switch to loading a separate
program from the dispatcher BPF object file. Also check if an XDP
program is already loaded on an interface, and don't try to load a new
one if it is.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-trafficgen: Output helpful suggestions if interface probing fails
Toke Høiland-Jørgensen [Fri, 8 Aug 2025 16:26:50 +0000 (18:26 +0200)]
xdp-trafficgen: Output helpful suggestions if interface probing fails

In some cases we can say something more about why probing for XDP
feature support for an interface fails (because of particular driver
quirks). Add output to the 'probe' command for these cases.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-trafficgen: Drop "the driver is missing support in this kernel version" text
Toke Høiland-Jørgensen [Fri, 8 Aug 2025 16:23:42 +0000 (18:23 +0200)]
xdp-trafficgen: Drop "the driver is missing support in this kernel version" text

The "Most likely the driver is missing support in this kernel version"
may not always be true (for instance because the support is just
disabled), so let's drop it from the check_iface_support() function.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-trafficgen: Exit non-zero if interface probing fails
Toke Høiland-Jørgensen [Fri, 8 Aug 2025 16:13:59 +0000 (18:13 +0200)]
xdp-trafficgen: Exit non-zero if interface probing fails

The per-interface probing in the 'probe' command did not affect the exit
code of the program. Fix this to exit non-zero if any of the probes fail.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-trafficgen: Document the 'probe' command
Toke Høiland-Jørgensen [Fri, 8 Aug 2025 16:00:52 +0000 (18:00 +0200)]
xdp-trafficgen: Document the 'probe' command

The 'probe' command was missing from the top-level help output, and the
man page. Let's add it to both.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agolib/util: Fix build on old versions of libbpf without XDP feature flag support
Toke Høiland-Jørgensen [Thu, 7 Aug 2025 14:52:25 +0000 (16:52 +0200)]
lib/util: Fix build on old versions of libbpf without XDP feature flag support

The build errors out with old libbpf versions because the ifdef'ed
version of iface_get_xdp_feature_flags() doesn't use any of its
arguments. Change the ifdef'ed version to mark the arguments as __unused
to avoid this.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
4 months agoxdp-trafficgen: fix probe_options missing END_OPTIONS
Frank Liang [Thu, 24 Jul 2025 16:21:07 +0000 (00:21 +0800)]
xdp-trafficgen: fix probe_options missing END_OPTIONS

Probe does not work w/o "-i" option.
Fix the error by adding END_OPTIONS to probe_options.

$ sudo xdp-trafficgen probe -i ens5
Missing required option '--interface'

Usage: xdp-trafficgen [options] <hostname>
Use --help (or -h) to see full option list.

Signed-off-by: Frank Liang <xiliang@redhat.com>
6 months agolib/xdp_sample: Remove xdp_redirect_map tracepoints
Toke Høiland-Jørgensen [Mon, 16 Jun 2025 12:40:07 +0000 (14:40 +0200)]
lib/xdp_sample: Remove xdp_redirect_map tracepoints

The xdp_redirect_map and xdp_redirect_map_err tracepoints have been
deprecated since kernel 5.6 (returning no data) and are slated for
removal in kernel 6.16[0]. Remove them from xdp_sample so xdp-bench will
keep working after the tracepoints are removed.

[0] https://lore.kernel.org/r/20250611155615.0c2cf61c@batman.local.home

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-trafficgen: fix description of num-packets option
Yuya Kusakabe [Wed, 28 May 2025 01:18:35 +0000 (10:18 +0900)]
xdp-trafficgen: fix description of num-packets option

Signed-off-by: Yuya Kusakabe <yuya.kusakabe@gmail.com>
7 months agoBump version to v1.5.5
Toke Høiland-Jørgensen [Mon, 26 May 2025 11:25:50 +0000 (13:25 +0200)]
Bump version to v1.5.5

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months ago.github/workflows: Add a 6.14 kernel to the test matrix
Toke Høiland-Jørgensen [Tue, 20 May 2025 11:10:51 +0000 (13:10 +0200)]
.github/workflows: Add a 6.14 kernel to the test matrix

The 6.14 kernel introduced the change that disallows attaching programs
that modify the packet pointer on top of functions that don't, so let's
add that version to the test matrix so we exercise the workaround.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-loader: Add a test for loading a program that modifies the packet pointer
Toke Høiland-Jørgensen [Tue, 20 May 2025 11:08:47 +0000 (13:08 +0200)]
xdp-loader: Add a test for loading a program that modifies the packet pointer

Newer versions of the kernel disallow attaching freplace programs that
modify the packet pointer on top of functions that don't. The libxdp
dispatcher was updated to include a workaround for this, so let's add a
test that exercises this workaround.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agolibxdp: Prevent blocking of programs that modify the packet pointer
Toke Høiland-Jørgensen [Tue, 20 May 2025 11:04:26 +0000 (13:04 +0200)]
libxdp: Prevent blocking of programs that modify the packet pointer

The verifier grew a check for global subprograms that invalidate the
packet pointer:

https://lore.kernel.org/all/20241210041100.1898468-1-eddyz87@gmail.com/

This affects libxdp, because the stub programs that are replaced by the
user programs do not modify the packet pointer. Implement the workaround
suggested in the posting above, by adding a no-op call to
bpf_xdp_adjust_tail() to the stub programs being replaced. This does not
affect performance, nor backwards compatibility of the dispatcher, since
the stub programs are never actually executed when libxdp is used. The
only effect will be that on newer kernels, a version of libxdp that
includes these changes will work with programs that modify the packet
pointer, while older versions of libxdp won't.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdpdump: Adapt the behavior of util.c find_bpf_file() to the libxdp.c variant
Lukas Schreckenberg [Mon, 19 May 2025 14:21:53 +0000 (16:21 +0200)]
xdpdump: Adapt the behavior of util.c find_bpf_file() to the libxdp.c variant

In contrast to the libxdp.c variant, the function find_bpf_file() in the util.c file does not use the environment variable LIBXDP_OBJECT_PATH to overwrite the default path, but always uses the default variable BPF_OBJECT_PATH, which is set at compile time.
To unify the behavior, the behavior of the util.c variant is adapted to that of the libxdp.c variant.

Signed-off-by: Lukas Schreckenberg <lukas.schreckenberg@iosb-ina.fraunhofer.de>
7 months agoxdp-trafficgen: Add missing comma in list of drivers
Toke Høiland-Jørgensen [Sun, 18 May 2025 18:50:25 +0000 (20:50 +0200)]
xdp-trafficgen: Add missing comma in list of drivers

Coverity pointed out that there's a comma missing in the list of
drivers, leading two of the strings to be concatenated instead of being
separate items in the list.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-trafficgen: Add test for error message on missing features
Toke Høiland-Jørgensen [Mon, 31 Mar 2025 11:32:52 +0000 (13:32 +0200)]
xdp-trafficgen: Add test for error message on missing features

Test that a veth without GRO (NAPI mode) enabled doesn't have the
required support.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-trafficgen: Support probing an interface in 'probe' command
Toke Høiland-Jørgensen [Mon, 31 Mar 2025 11:38:18 +0000 (13:38 +0200)]
xdp-trafficgen: Support probing an interface in 'probe' command

Add an -i option to the 'xdp-trafficgen probe' command which will cause
xdp-trafficgen to issue a feature probe of the specified interface. This
can be used to detect if an interface is usable before trying to run on
it.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
squash

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-trafficgen: Error out if interface doesn't support sending packets
Toke Høiland-Jørgensen [Mon, 31 Mar 2025 11:23:32 +0000 (13:23 +0200)]
xdp-trafficgen: Error out if interface doesn't support sending packets

If a device doesn't support sending packets via XDP, xdp-trafficgen will
still happily load and try to send packets, but no packets will actually
be sent. Add a check for the NDO_XMIT XDP feature flag in
xdp-trafficgen, and error out if the flag it not set. This should make
it clearer to users why things don't work.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-trafficgen: Load a dummy XDP program if needed
Toke Høiland-Jørgensen [Mon, 31 Mar 2025 11:22:53 +0000 (13:22 +0200)]
xdp-trafficgen: Load a dummy XDP program if needed

Add logic in xdp-trafficgen to load a dummy XDP program on devices that
need this to be able to send packets via ndo_xdp_xmit(). We use a
hard-coded list of driver names to determine if an interface needs such
an XDP program, and check the XDP feature flags to skip the loading if
the NDO_XMIT feature is already set.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-loader: Move querying for XDP feature flags into a util helper function
Toke Høiland-Jørgensen [Mon, 31 Mar 2025 10:57:51 +0000 (12:57 +0200)]
xdp-loader: Move querying for XDP feature flags into a util helper function

This will make it possible to reuse the query function in xdp-trafficgen
in a subsequent commit.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
7 months agoxdp-filter: Disable Python tests
Toke Høiland-Jørgensen [Mon, 28 Apr 2025 11:22:30 +0000 (13:22 +0200)]
xdp-filter: Disable Python tests

The Python tests are failing due to what appears to be a bug in
pyroute2. Let's disable them for now.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
8 months agoBump version to v1.5.4
Toke Høiland-Jørgensen [Mon, 28 Apr 2025 08:49:54 +0000 (10:49 +0200)]
Bump version to v1.5.4

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
8 months agopackaging/rpm: fix clang location
Yaakov Selkowitz [Tue, 1 Apr 2025 01:40:54 +0000 (21:40 -0400)]
packaging/rpm: fix clang location

Installation path macros cannot be safely used to specify the location of dependencies.
For instance, even when building xdg-tools for flatpaks in /app,
the buildroot llvm/clang may be used from /usr.

https://docs.fedoraproject.org/en-US/packaging-guidelines/#_file_and_directory_dependencies

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
8 months agolib/defines: Propagate include directories to BPF_CFLAGS
Toke Høiland-Jørgensen [Mon, 31 Mar 2025 10:24:03 +0000 (12:24 +0200)]
lib/defines: Propagate include directories to BPF_CFLAGS

The configure script may add extra include directories to CFLAGS, but
these were not propagated to BPF_CFLAGS, which leads to build errors
when libbpf is in an unusual place. Add an explicit propagation of
any CFLAGS starting with -I to BPF_CFLAGS.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-trafficgen: Fix data size when probing for kernel support
Toke Høiland-Jørgensen [Mon, 17 Mar 2025 14:21:32 +0000 (15:21 +0100)]
xdp-trafficgen: Fix data size when probing for kernel support

Kernel commit 6b3d638ca897 ("bpf, test_run: Fix use-after-free issue in
eth_skb_pkt_type()") started returning EINVAL if the data size passed to
BPF_PROG_RUN is < ETH_HLEN, which breaks the feature probing of
xdp-trafficgen. Fix this by making the probe use a full ETH_HLEN worth
of data.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months ago.github/workflows: Update test matrix
Toke Høiland-Jørgensen [Fri, 14 Mar 2025 10:34:03 +0000 (11:34 +0100)]
.github/workflows: Update test matrix

Add LLVM 20 and 6.13 kernels to the test matrix

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoGet rid of llc and use clang to build BPF object files directly
Toke Høiland-Jørgensen [Fri, 14 Mar 2025 10:30:01 +0000 (11:30 +0100)]
Get rid of llc and use clang to build BPF object files directly

It turns out we pass both -S and -c to clang, which has become an error
starting from clang 20. The two-stage build using 'clang -S' followed by
llc was used in the early days of BPF development, but these days, clang
is perfectly happy to produce BPF object files directly.

So use this opportunity to get rid of llc entirely, and simplify the BPF
object build rules while we're add it, by moving all of the -W* defines
to BPF_CFLAGS.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoBump version to v1.5.3
Toke Høiland-Jørgensen [Fri, 7 Mar 2025 13:09:34 +0000 (14:09 +0100)]
Bump version to v1.5.3

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoman pages: Whitespace changes
Toke Høiland-Jørgensen [Fri, 7 Mar 2025 13:07:45 +0000 (14:07 +0100)]
man pages: Whitespace changes

Newer Emacs versions changed the org-mode man page export code, which
results in whitespace changes to all generated man pages. Keep these in
a separate commit to avoid bloating the subsequent version bump commit.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoconfigure: Also capture stderr from emacs output
Toke Høiland-Jørgensen [Fri, 7 Mar 2025 10:55:05 +0000 (11:55 +0100)]
configure: Also capture stderr from emacs output

The emacs major version output can go to stderr, so make sure to capture
that as well when getting the version.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-forward: Add test for attaching to a high ifindex
Toke Høiland-Jørgensen [Wed, 5 Mar 2025 12:26:11 +0000 (13:26 +0100)]
xdp-forward: Add test for attaching to a high ifindex

Add a test that creates an interface with a high ifindex and verify that
xdp-forward can attach to it.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-forward: Add unload to flowtable test
Toke Høiland-Jørgensen [Wed, 5 Mar 2025 12:16:45 +0000 (13:16 +0100)]
xdp-forward: Add unload to flowtable test

The flowtable test for xdp-forward did not unload the programs after
running, which is why it didn't catch the ambiguous program name error.
Add an unload to the text to make sure this keeps working.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-forward: Don't use errno as program exit code
Toke Høiland-Jørgensen [Wed, 5 Mar 2025 12:24:15 +0000 (13:24 +0100)]
xdp-forward: Don't use errno as program exit code

Converting errno returns to program exit status means we may end up
returning SKIPPED_TEST, which messes with the selftests. Change this to
always use EXIT_SUCCESS/EXIT_FAILURE instead.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-forward: Use DEVMAP_HASH map types
Toke Høiland-Jørgensen [Wed, 5 Mar 2025 12:13:04 +0000 (13:13 +0100)]
xdp-forward: Use DEVMAP_HASH map types

The DEVMAP map types used by xdp-forward prevents installing xdp-forward
on ifindexes larger than the map size, because the ifindex is also used
as the lookup key. Change to DEVMAP_HASH to avoid this.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-forward: Don't use ambiguous function names for flowtable mode
Toke Høiland-Jørgensen [Wed, 5 Mar 2025 12:11:40 +0000 (13:11 +0100)]
xdp-forward: Don't use ambiguous function names for flowtable mode

The BPF function names used by xdp-forward in flowtable mode end up
being ambiguous when truncated by the kernel. This causes xdp-forward to
be unable to unload the programs. Fix this by using shorter function
names.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
9 months agoxdp-dump/xdpdump.h: Increase MAX_CPUS to 512
Lucas Crijns [Mon, 3 Mar 2025 13:28:13 +0000 (14:28 +0100)]
xdp-dump/xdpdump.h: Increase MAX_CPUS to 512

Previously, MAX_CPUS was set to 256. This causes the tool to exit with a failure on systems with more than 256 CPUs.
For example, an AMD EPYC server with two AMD EPYC 9684X 96-Core Processors reports 384 CPUs to the kernel due to hyperthreading.
This fix allows such systems to run the xdpdump utility.

Signed-off-by: Lucas Crijns <lucascrijns@gmail.com>
9 months agoSupport building with Emacs 30
K900 [Mon, 3 Mar 2025 07:08:39 +0000 (10:08 +0300)]
Support building with Emacs 30

Extract the major version and compare it as a number to avoid
the messy regexes.

Signed-off-by: K900 <me@0upti.me>
10 months agoutil/xdp_sample: Collect PPS values for stats_get_devmap_xmit_multi()
Toke Høiland-Jørgensen [Tue, 25 Feb 2025 15:54:23 +0000 (16:54 +0100)]
util/xdp_sample: Collect PPS values for stats_get_devmap_xmit_multi()

Also store the PPS values into the output container in
stats_get_devmap_xmit_multi(), since the PPS values are what we are
printing in the summary lines now.

Fixes: 7b3bbe2f6f16 ("util/xdp_sample: Print PPS values in summary line instead of totals")
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
10 months agoExplicitly set PREFIX=/ when installing libbpf headers
Robert Edmonds [Thu, 13 Feb 2025 05:32:48 +0000 (00:32 -0500)]
Explicitly set PREFIX=/ when installing libbpf headers

When xdp-tools builds the embedded copy of libbpf, it invokes the libbpf
build system to installs it headers, and then constructs a path to
those embedded libbpf headers [0] based on the assumption that libbpf
installed its headers into its default PREFIX value of /usr.

However, if PREFIX is passed to the xdp-tools build system, this
variable gets passed down to the invocation of the libbpf build system
as well, and libbpf installs its headers into a different directory
that doesn't match xdp-tools' LIBBPF_INCLUDE_DIR variable, and the build
fails like this:

    $ make PREFIX=/usr/local
    […]
    libbpf support: Submodule 'libbpf' (https://github.com/libbpf/libbpf.git) registered for path 'lib/libbpf'
    Cloning into '/home/edmonds/src/xdp-tools/lib/libbpf'...
    Submodule path 'lib/libbpf': checked out 'fdf402b384cc42ce29bb9e27011633be3cbafe1e'
    submodule v1.4.0
    […]
    lib

      libbpf
        CC       libbpf/src/libbpf.a
        INSTALL  libbpf/src/libbpf.a

      libxdp
        CC       staticobjs/libxdp.o
    libxdp.c:31:10: fatal error: bpf/libbpf.h: No such file or directory
       31 | #include <bpf/libbpf.h>
          |          ^~~~~~~~~~~~~~
    compilation terminated.

This commit explicitly passes PREFIX=/ to the libbpf build system
when installing the embedded libbpf headers, and also updates the
LIBBPF_INCLUDE_DIR variable in the xdp-tools build system to match the
resulting include path, so that the embedded libbpf headers are
installed into a fixed location.

[0]: https://github.com/xdp-project/xdp-tools/blob/7b3bbe2f6f16d658bb09a7b7e5958f4a49825ee6/configure#L382

Signed-off-by: Robert Edmonds <edmonds@users.noreply.github.com>