Skip to content

[v1.18] l7lb: fix bypassing ingress policies for local backends#44804

Merged
julianwiedmann merged 3 commits intov1.18from
pr/smagnani96/sa-fix-v1.18
Mar 16, 2026
Merged

[v1.18] l7lb: fix bypassing ingress policies for local backends#44804
julianwiedmann merged 3 commits intov1.18from
pr/smagnani96/sa-fix-v1.18

Conversation

@smagnani96
Copy link
Copy Markdown
Contributor

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

 44693

[ upstream commit 42ecbb1 ]

This is to clarify the naming and distinguish with the new tests we are
going to introduce in subsequent commits.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
[ upstream commit ffdede7 ]

[ backporter's notes:
  * changed node_config.h to support definition of CILIUM_NET_IFINDEX and
    CILIUM_HOST_IFINDEX macros, which are needed in the backported test.
    Unfortunately, CONFIG(cilium_host_ifindex) has not been backported,
    and re-defining the macro is not possible, so I hacked it
  * fixed the include of bpf_lxc.c in the test
]

This commits adds IPv4/IPv6 tests for the case in which L7LB is enabled
and opens a connection on behalf of a pod destined to a local backend.
In case per-endpoint routes are not enabled, the packet will be handled
in the cil_from_host program, will tail call to the egress policy program,
and then return to stack.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
@smagnani96 smagnani96 self-assigned this Mar 16, 2026
@smagnani96 smagnani96 added kind/backports This PR provides functionality previously merged into master. backport/1.18 This PR represents a backport for Cilium 1.18.x of a PR that was merged to main. labels Mar 16, 2026
[ upstream commit ea17ed8 ]

[ backporter's notes:
  * using macro CILIUM_HOST_IFINDEX instead of CONFIG(cilium_host_ifindex) as it was not backported.
  * fixed conflicts in bpf_lxc.c, as #43226, #42926 and others haven't been backported.
]

In commit d1d8e7a ("datapath: Add support for re-entering LXC egress path after L7 LB"),
we enabled support for re-entering the LXC egress path after a packet is
processed by a L7 LB. This allows us to correctly apply egress policies to
packets sent by a L7 LB to local backends.

Without per-endpoint routes, the pod policies are checked from the tail
call in bpf_host. We reach this code from cilium_host (ctx->ifindex).

With per-endpoint routes, the packet is handled directly in the
local backend pod `cil_to_container` path, completely skipping ingress
policies. Returning CTX_ACT_OK at this point would bypass policies.
To fix this, we need to hairpin the packet back to cil_to_container
(the ctx->mark is already cleared at the beginning of the codepath).
This would allow us to correctly apply ingress policies on the local
backend ingress path, restoring the expected behavior.

Fixes: d1d8e7a ("datapath: Add support for re-entering LXC egress path after L7 LB")

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
@smagnani96 smagnani96 force-pushed the pr/smagnani96/sa-fix-v1.18 branch from 38080c8 to 8967a8f Compare March 16, 2026 10:21
@smagnani96
Copy link
Copy Markdown
Contributor Author

/test

@smagnani96 smagnani96 marked this pull request as ready for review March 16, 2026 11:29
@smagnani96 smagnani96 requested a review from a team as a code owner March 16, 2026 11:29
@julianwiedmann julianwiedmann added this pull request to the merge queue Mar 16, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot added ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels Mar 16, 2026
Merged via the queue into v1.18 with commit d77647a Mar 16, 2026
353 of 354 checks passed
@julianwiedmann julianwiedmann deleted the pr/smagnani96/sa-fix-v1.18 branch March 16, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/1.18 This PR represents a backport for Cilium 1.18.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