Skip to content

Commit 496bdd0

Browse files
authored
Add options and functionality for running with other XDP programs via xdp-loader. (#86)
1 parent 278ff71 commit 496bdd0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/common/config.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,13 @@
5757

5858
// If enabled, uses a newer bpf_loop() function when choosing a source port for a new connection.
5959
// This allows for a much higher source port range. However, it requires a more recent kernel.
60-
#define USE_NEW_LOOP
60+
#define USE_NEW_LOOP
61+
62+
// Whether to enable chaining multiple XDP programs with this tool (1 = enable. 0 = disable).
63+
#define XDP_MULTIPROG_ENABLED 1
64+
65+
// The XDP program's run priority (used for running multiple XDP programs together).
66+
#define XDP_MULTIPROG_PRIORITY 10
67+
68+
// The action that indicates it should go onto the next program (default XDP_PASS).
69+
#define XDP_MULTIPROG_ACTION XDP_PASS

src/loader/utils/xdp.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ int attach_xdp(struct xdp_program *prog, char** mode, int ifidx, int detach, int
113113
{
114114
int err;
115115

116+
// Before attaching, set chaining options.
117+
xdp_program__set_run_prio(prog, XDP_MULTIPROG_PRIORITY);
118+
xdp_program__set_chain_call_enabled(prog, XDP_MULTIPROG_ACTION, XDP_MULTIPROG_ENABLED);
119+
116120
u32 attach_mode = XDP_MODE_NATIVE;
117121

118122
*mode = "DRV/native";

0 commit comments

Comments
 (0)