diff --git a/src/common/config.h b/src/common/config.h index 28b07ed..e41e70b 100644 --- a/src/common/config.h +++ b/src/common/config.h @@ -57,4 +57,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 10 + +// 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 3e05fdd..c4afe04 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";