Skip to content

bpf: lxc: split forwarding section from handle_ipv*_from_lxc()#43226

Merged
julianwiedmann merged 2 commits intomainfrom
pr/jwi/main/bpf-lxc-forwarding
Dec 16, 2025
Merged

bpf: lxc: split forwarding section from handle_ipv*_from_lxc()#43226
julianwiedmann merged 2 commits intomainfrom
pr/jwi/main/bpf-lxc-forwarding

Conversation

@julianwiedmann
Copy link
Copy Markdown
Member

@julianwiedmann julianwiedmann commented Dec 9, 2025

(in two patches to keep it manageable, and to make the diff look pretty.)

@antonipp mentioned that sorting out the refactor pre-work for landing #42068 is a bit of a pain. Let's keep it super-straightforward and hopefully merge this quickly, without hitting conflicts.

Even if #42068 then doesn't land immediately, splitting this big function into more reasonable pieces makes sense to me on its own.

@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 Dec 9, 2025
@julianwiedmann
Copy link
Copy Markdown
Member Author

/test

@julianwiedmann julianwiedmann marked this pull request as ready for review December 9, 2025 18:11
@julianwiedmann julianwiedmann requested a review from a team as a code owner December 9, 2025 18:11
Copy link
Copy Markdown
Member

@aditighag aditighag left a comment

Choose a reason for hiding this comment

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

LGTM! I think you need to rebase the PR to trigger the L3L4 and L7 workflows.

julianwiedmann and others added 2 commits December 16, 2025 08:58
Take the whole tail-end of handle_ipv6_from_lxc(), and move it into its
own function. This will allow us to re-use the code from other contexts
which need to forward a packet to its destination.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
Take the whole tail-end of handle_ipv4_from_lxc(), and move it into its
own function. This will allow us to re-use the code from other contexts
which need to forward a packet to its destination.

Co-authored-by: Anton Ippolitov <anton.ippolitov@datadoghq.com>
Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
@julianwiedmann julianwiedmann force-pushed the pr/jwi/main/bpf-lxc-forwarding branch from 74775e3 to c3c7b47 Compare December 16, 2025 06:58
@julianwiedmann
Copy link
Copy Markdown
Member Author

/test

@julianwiedmann julianwiedmann added this pull request to the merge queue Dec 16, 2025
Merged via the queue into main with commit c6944b4 Dec 16, 2025
372 of 379 checks passed
@julianwiedmann julianwiedmann deleted the pr/jwi/main/bpf-lxc-forwarding branch December 16, 2025 09:28
@cilium-release-bot cilium-release-bot bot moved this to Released in cilium v1.19.0 Feb 3, 2026
smagnani96 added a commit that referenced this pull request 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 added a commit that referenced this pull request 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 added a commit that referenced this pull request Mar 16, 2026
[ upstream commit ea17ed8 ]

[ backporter's notes:
  * using macro 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>
github-merge-queue bot pushed a commit that referenced this pull request 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>
github-merge-queue bot pushed a commit that referenced this pull request Mar 16, 2026
[ upstream commit ea17ed8 ]

[ backporter's notes:
  * using macro 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>
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. 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.

3 participants