Skip to content

[v1.17] bpf: nodeport: use hairpin redirect for L7 LB on bridge devices#44709

Merged
julianwiedmann merged 1 commit intov1.17from
pr/smagnani96/fix-l7lb-v1.17
Mar 13, 2026
Merged

[v1.17] bpf: nodeport: use hairpin redirect for L7 LB on bridge devices#44709
julianwiedmann merged 1 commit intov1.17from
pr/smagnani96/fix-l7lb-v1.17

Conversation

@smagnani96
Copy link
Copy Markdown
Contributor

@smagnani96 smagnani96 commented Mar 10, 2026

Once this PR is merged, a GitHub action will update the labels of these PRs:

 44658

@smagnani96 smagnani96 self-assigned this Mar 10, 2026
@smagnani96 smagnani96 added kind/backports This PR provides functionality previously merged into master. backport/1.17 This PR represents a backport for Cilium 1.17.x of a PR that was merged to main. labels Mar 10, 2026
@smagnani96 smagnani96 changed the title bpf: nodeport: use hairpin redirect for L7 LB on bridge devices [v1.17] bpf: nodeport: use hairpin redirect for L7 LB on bridge devices Mar 10, 2026
@smagnani96 smagnani96 force-pushed the pr/smagnani96/fix-l7lb-v1.17 branch from 3920f2f to bdbf5f6 Compare March 10, 2026 09:52
@smagnani96
Copy link
Copy Markdown
Contributor Author

/test

@smagnani96 smagnani96 force-pushed the pr/smagnani96/fix-l7lb-v1.17 branch 4 times, most recently from fb09199 to 981e39d Compare March 12, 2026 11:47
@julianwiedmann julianwiedmann self-requested a review March 12, 2026 14:34
@smagnani96
Copy link
Copy Markdown
Contributor Author

/test

@smagnani96
Copy link
Copy Markdown
Contributor Author

ci-eks and ci-awscni failing due to not being able to create NodeGroup.
I have finished energies, will not fix CI for v1.17.

@smagnani96 smagnani96 marked this pull request as ready for review March 13, 2026 14:35
@smagnani96 smagnani96 requested a review from a team as a code owner March 13, 2026 14:35
[ upstream commit 52f35a9 ]

[ backporter's notes: fixed conflicts:
  * adapting to the old loader implementation, adding changes only to
    the Netdev program attached to network devices.
  * added bits into bpf/tests/pktgen.h without backporting whole unrelated PRs
  * adjusted LB4_SERVICES_MAP_V2, LB4_REVERSE_NAT_MAP, and their respective
    IPv6 versions references, different than in upstream
  * added `ENABLE_SERVICE_PROTOCOL_DIFFERENTIATION` in the new test,
    alongside with some different infra to tail call the ingress program,
    and macros to check redirect interface
  * changed check in bpf/tests/l7_lb_hairpin.c to check for HOST_IFINDEX
    instead of cilium_net, as the latter is not used in this backport
]

Fix L7 proxy traffic disruption (DROP_REASON_NOSOCKET) on nodes where
the BPF program is attached to a Linux bridge device and the
br_netfilter module is loaded with net.bridge.bridge-nf-call-iptables=1.

With #36383, we changed the non-BPF-TPROXY L7 LB redirect path to mark
packets with MARK_MAGIC_TO_PROXY and punt them to the stack, relying on
an iptables TPROXY rule in PREROUTING to deliver the packet to the
proxy. This optimization avoids a hairpin redirect through cilium_net.

However, when br_netfilter is active on a bridge device, the kernel's
ip_sabotage_in() function interferes:

1. Packet arrives on bridge port -> br_netfilter evaluates PREROUTING
   (1st time, BPF hasn't run yet -> TPROXY rule doesn't match)
2. ip_sabotage_in() sets NF_HOOK_STATE_SABOTAGED on the packet
3. tc-ingress BPF runs, sets MARK_MAGIC_TO_PROXY, punts to stack
4. IP stack calls PREROUTING again, but ip_sabotage causes it to be
   SKIPPED entirely
5. TPROXY rule never fires -> no listening socket on VIP ->
   DROP_REASON_NOSOCKET

We therefore add a new datapath config variable that will be set to true
only when compiling the Netdev datapath program (cil_{from,to}_netdev)
and the network device is a bridge. This allows us to fall back to the
pre-#36383 hairpin redirect via cilium_net for L7 LB traffic, bypassing the
ip_sabotage_in() function and allowing the TPROXY rule to match as expected.

Non-bridge devices continue using the optimized punt-to-stack path.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
@julianwiedmann julianwiedmann force-pushed the pr/smagnani96/fix-l7lb-v1.17 branch from 981e39d to b24ded2 Compare March 13, 2026 14:41
@julianwiedmann
Copy link
Copy Markdown
Member

/test

@julianwiedmann julianwiedmann added this pull request to the merge queue Mar 13, 2026
Merged via the queue into v1.17 with commit 06ca092 Mar 13, 2026
285 of 290 checks passed
@julianwiedmann julianwiedmann deleted the pr/smagnani96/fix-l7lb-v1.17 branch March 13, 2026 16:28
@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 Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.17 This PR represents a backport for Cilium 1.17.x of a PR that was merged to main. kind/backports This PR provides functionality previously merged into master. ready-to-merge This PR has passed all tests and received consensus from code owners to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants