Skip to content

Conversation

tohojo
Copy link
Member

@tohojo tohojo commented May 20, 2025

Newer kernels added checks that disallow replacing functions that don't modify
the packet pointer with ones that do. For libxdp this means that programs that
modify the packet pointer refuses to load. Fix this by adding the recommended
workaround to the dispatcher program.

Fixes #503

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

https://lore.kernel.org/all/[email protected]/

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 <[email protected]>
tohojo added 2 commits May 20, 2025 15:59
… 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 <[email protected]>
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 <[email protected]>
@tohojo tohojo force-pushed the adjust-tail-fixes branch from 4ea5f8d to 3109bd1 Compare May 20, 2025 14:01
@tohojo tohojo merged commit 9d337ac into main May 22, 2025
90 of 91 checks passed
@tohojo tohojo deleted the adjust-tail-fixes branch May 22, 2025 07:40
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.

Loader cant load with bpf_xdp_adjust_tail()
1 participant