Skip to content

Conversation

@tohojo
Copy link
Member

@tohojo tohojo commented Dec 2, 2025

This WiP PR imports the code from the xdpsock utility in the bpf_examples
repository and incorporates the functionality into xdp-bench (drop and l2fwd)
and xdp-trafficgen (tx).

The xdpsock code is transformed into library functions that can be called from
both the xdp-bench and xdp-trafficgen binaries, and the options are converted
into the xdp-tools parameter framework.

Some invocations of usage() didn't use the program name buffer that
includes the command name, leading to confusing output.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Error out if the configured options contain duplicate short options, to
aid with commands that take a lot of options.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Add a .hex value in the options definition that enables parsing integers
as hexadecimal if set.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
@tohojo tohojo force-pushed the xdb-bench-xsk branch 2 times, most recently from 6411183 to 89be6b4 Compare December 15, 2025 23:00
Add an 'xsk' command to xdp-bench which will be used to run the
AF_XDP-based benchmarks from the xdpsock utility.

This commit only adds the command and option parsing, in preparation for
porting over the xdpsock code.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Update if_xdp.h to a newer version that includes the definitions for
fragments in AF_XDP.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
This includes the xdpsock code from the bpf_examples repository into
lib/util. The code is included as-is, with only a couple of small
changes to make the code compile (fixing "mixed-sign compare" compiler
warnings). The following commits will refactor the code into a library
to be re-used by xdp-bench and xdp-trafficgen.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Instead of typedefs, use __u8/__u16/__u32/__u64 directly everywhere.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
The options should be part of the library so they can be re-used.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Instead of relying on global variables to keep state while running
xdpsock, move all state variables into a context object, and remove the
global variables for the options in favour of an embedded options struct.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Restructure the setup code of xdpsock to get rid of the main() function
and instead introduce a new xsk_ctx__create() function that creates the
previously introduced context object and sets everything up.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Wire up the xdpsock library code to implement the xsk-drop and xsk-tx
commands in xdp-bench.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Swap the threads so that packet processing is started in a background
thread and stats output is in the foreground. This makes it possible to
incorporate signal processing as part of the stats output loop, adopting
the signalfd/timerfd approach used by xdp_sample.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Make the stats output more condensed (by default) and better aligned
with the output of xdp_sample used elsewhere.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Use the immediate exit logic from xdp_sample in xdpsock as
well (exporting the function that checks the envvar), so we can use it
in tests.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
The main thread will handle signals and set ctx->benchmark_done if one
is received. Make sure to check this in every loop iteration; otherwise,
when using poll mode, the poller thread won't react to the exit signal
because of the 'continue' inside the poll logic.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Exercise the different options with immediate exit in both xsk-drop and
xsk-tk modes.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Add a test that exercises the different XSK options for xdp-trafficgen.

Signed-off-by: Toke Høiland-Jørgensen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants