Skip to content

Conversation

twaapo
Copy link
Contributor

@twaapo twaapo commented Aug 4, 2025

fixes #1841

@twaapo twaapo requested a review from a team as a code owner August 4, 2025 06:22
Copy link
Collaborator

@lmb lmb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to bind an XDP program to lo? If yes, please add a unit test.

@twaapo
Copy link
Contributor Author

twaapo commented Aug 6, 2025

It seems to be possible to bind XDP programs to lo. However with the kfunc I get.
load program: operation not supported

@twaapo twaapo force-pushed the main branch 2 times, most recently from 1776e56 to 5d62ce6 Compare August 6, 2025 20:54
@lmb
Copy link
Collaborator

lmb commented Aug 7, 2025

It seems to be possible to bind XDP programs to lo. However with the kfunc I get.
load program: operation not supported

How about adding a test which just loads a minimal XDP program which is bound to lo, without the kfunc? (There are plenty examples in the code base) I think that is enough to validate that binding works. Kfuncs already have coverage otherwise.

@twaapo
Copy link
Contributor Author

twaapo commented Aug 8, 2025

Theres a caveat:

greybox ebpf (main*) # go test -v --run TestProgramLoadBound.+
=== RUN   TestProgramLoadBoundToDevice
    prog_test.go:36: out:
                0: LdImmDW dst: r0 imm: 2
                2: Exit

    prog_test.go:37: bind on ifi 1
    prog_test.go:52: load program: operation not supported
--- FAIL: TestProgramLoadBoundToDevice (0.00s)
FAIL
exit status 1
FAIL    github.com/cilium/ebpf  0.003s
greybox ebpf (main*) # go test -v --run TestProgramLoadBound.+
=== RUN   TestProgramLoadBoundToDevice
    prog_test.go:36: out:
                0: LdImmDW dst: r0 imm: 2
                2: Exit

    prog_test.go:37: bind on ifi 2
    prog_test.go:52: load program: operation not supported
--- FAIL: TestProgramLoadBoundToDevice (0.00s)
FAIL
exit status 1
FAIL    github.com/cilium/ebpf  0.003s
greybox ebpf (main*) #
greybox ebpf (main*) # go test -v --run TestProgramLoadBound.+
=== RUN   TestProgramLoadBoundToDevice
    prog_test.go:36: out:
                0: LdImmDW dst: r0 imm: 2
                2: Exit

    prog_test.go:37: bind on ifi 3
--- PASS: TestProgramLoadBoundToDevice (0.00s)
PASS
ok      github.com/cilium/ebpf  0.003s
greybox ebpf (main*) # ethtool -i eno1
driver: e1000e
greybox ebpf (main*) # ethtool -i enp1s0f0np0
driver: i40e
greybox ebpf (main) #

Where ifindex=3 is Intel XL710 NIC. Seems not to work with lo nor the other physical NIC at ifi=2.

@lmb
Copy link
Collaborator

lmb commented Aug 11, 2025

Turned the test into a negative check instead.

lmb
lmb previously approved these changes Aug 11, 2025
@lmb lmb force-pushed the main branch 3 times, most recently from 94be5aa to 51c0529 Compare August 11, 2025 13:45
@ti-mo ti-mo force-pushed the main branch 2 times, most recently from 2058fd4 to 4a80553 Compare September 8, 2025 13:16
Signed-off-by: Aapo Poutanen <[email protected]>
Co-authored-by: Timo Beckers <[email protected]>
@ti-mo ti-mo merged commit ae3ab27 into cilium:main Sep 8, 2025
18 checks passed
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.

Cannot load XDP application as device-bound
3 participants