From 241ce7bb21e4d9258a1c156779934f7bd8851bce Mon Sep 17 00:00:00 2001 From: Christian Deacon Date: Sun, 28 Dec 2025 15:54:03 -0500 Subject: [PATCH] Add options and functionality for running with other XDP programs via xdp-loader. --- src/common/config.h | 11 ++++++++++- src/loader/utils/xdp.c | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/common/config.h b/src/common/config.h index ac1fb5a..03c4803 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -36,4 +36,13 @@ // If enabled, uses a newer bpf_loop() function when choosing a source port for a new connection. // This allows for a much higher source port range. However, it requires a more recent kernel. -#define USE_NEW_LOOP \ No newline at end of file +#define USE_NEW_LOOP + +// Whether to enable chaining multiple XDP programs with this tool (1 = enable. 0 = disable). +#define XDP_MULTIPROG_ENABLED 1 + +// The XDP program's run priority (used for running multiple XDP programs together). +#define XDP_MULTIPROG_PRIORITY 20 + +// The action that indicates it should go onto the next program (default XDP_PASS). +#define XDP_MULTIPROG_ACTION XDP_PASS \ No newline at end of file diff --git a/src/loader/utils/xdp.c b/src/loader/utils/xdp.c index e713cfb..75665be 100644 --- a/src/loader/utils/xdp.c +++ b/src/loader/utils/xdp.c @@ -113,6 +113,10 @@ int attach_xdp(struct xdp_program *prog, char** mode, int ifidx, int detach, int { int err; + // Before attaching, set chaining options. + xdp_program__set_run_prio(prog, XDP_MULTIPROG_PRIORITY); + xdp_program__set_chain_call_enabled(prog, XDP_MULTIPROG_ACTION, XDP_MULTIPROG_ENABLED); + u32 attach_mode = XDP_MODE_NATIVE; *mode = "DRV/native";