Skip to content

bpf: fine-tune work-around for bpf_redirect_neigh() from overlay programs#42052

Merged
julianwiedmann merged 3 commits intomainfrom
pr/jwi/main/bpf-fib-overlay
Oct 10, 2025
Merged

bpf: fine-tune work-around for bpf_redirect_neigh() from overlay programs#42052
julianwiedmann merged 3 commits intomainfrom
pr/jwi/main/bpf-fib-overlay

Conversation

@julianwiedmann
Copy link
Copy Markdown
Member

@julianwiedmann julianwiedmann commented Oct 7, 2025

#42000 limited the usage of bpf_redirect_neigh() from overlay programs, to work-around a kernel bug that causes a memory leak.

This bug only manifests when bpf_redirect_neigh() is called without next-hop information - or in Cilium terms, without a preceding FIB lookup. By annotating such specific usage of bpf_redirect_neigh() with a fine-grained capability check, we can otherwise allow the use of bpf_redirect_neigh() from overlay context.

Fixes: #42086.

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 7, 2025
@julianwiedmann julianwiedmann added area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/misc This PR makes changes that have no direct user impact. labels Oct 7, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Oct 7, 2025
@julianwiedmann julianwiedmann changed the title Pr/jwi/main/bpf fib overlay bpf: fine-tune work-around for bpf_redirect_neigh() from overlay programs Oct 7, 2025
@julianwiedmann
Copy link
Copy Markdown
Member Author

/test

@julianwiedmann julianwiedmann added the dont-merge/preview-only Only for preview or testing, don't merge it. label Oct 7, 2025
@julianwiedmann julianwiedmann marked this pull request as ready for review October 7, 2025 07:29
@julianwiedmann julianwiedmann requested review from a team as code owners October 7, 2025 07:29
@julianwiedmann
Copy link
Copy Markdown
Member Author

I'll want to give this a bit more testing, but think it's good enough for a first round of feedback. This should get us back on track to use bpf_redirect_neigh() again for more cases in bpf_overlay.

#42000 limited the usage of
bpf_redirect_neigh() from overlay programs, to work-around a kernel bug
that causes a memory leak.

This bug only manifests when bpf_redirect_neigh() is called without
next-hop information - or in Cilium terms, without a preceding FIB lookup.
By annotating such specific usage of bpf_redirect_neigh() with a
fine-grained capability check, we can otherwise allow the use of
bpf_redirect_neigh() from overlay context.

Start by introducing the neigh_resolver_without_nh_available() check in all
relevant places.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
Currently fib_redirect_*() only performs a FIB lookup if used from XDP
context, since there we don't have access to bpf_redirect_neigh().

Extend this case to also cover the usage from overlay programs, so that we
provide next-hop information to fib_do_redirect() and can therefore use
bpf_redirect_neigh().

While at it switch the code paths to positive logic ("under what
conditions can we do a redirect without next-hop").

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
With the previous patches the code-base is now smart enough to avoid the
problematic usage of bpf_redirect_neigh() without next-hop information.

Remove the opt-out from the generic neigh_resolver_available() check, so
that overlay programs can use the neighbour redirect - as long as they
provide next-hop information.

Also remove the fallback checks in the EGW helpers, these helpers are now
again always used from a context where neigh_resolver_available() is true.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann julianwiedmann force-pushed the pr/jwi/main/bpf-fib-overlay branch from a80d0c9 to 5af724f Compare October 7, 2025 11:38
@julianwiedmann
Copy link
Copy Markdown
Member Author

/test

@julianwiedmann julianwiedmann removed the dont-merge/preview-only Only for preview or testing, don't merge it. label Oct 7, 2025
Copy link
Copy Markdown
Member

@ysksuzuki ysksuzuki left a comment

Choose a reason for hiding this comment

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

LGTM

@julianwiedmann julianwiedmann added this pull request to the merge queue Oct 10, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Oct 10, 2025
Merged via the queue into main with commit 1ded914 Oct 10, 2025
490 of 500 checks passed
@julianwiedmann julianwiedmann deleted the pr/jwi/main/bpf-fib-overlay branch October 10, 2025 07:44
@cilium-release-bot cilium-release-bot bot moved this to Released in cilium v1.19.0 Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

No open projects
Status: Released

Development

Successfully merging this pull request may close these issues.

CI: [main][ci-e2e-upgrade] ping tests fail for v4 and v6 in seq-egress-gateway-multigateway and seq-egress-gateway

3 participants