Skip to content

bpf: hostfw: use tailcall buffer for ipv{4,6}_host_policy_{e,in}gress - #47648

Draft
smagnani96 wants to merge 2 commits into
mainfrom
pr/smagnani96/complexity-and-stack-optim
Draft

bpf: hostfw: use tailcall buffer for ipv{4,6}_host_policy_{e,in}gress#47648
smagnani96 wants to merge 2 commits into
mainfrom
pr/smagnani96/complexity-and-stack-optim

Conversation

@smagnani96

@smagnani96 smagnani96 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This pull request performs a similar change as done in #45589, to reduce stack usage and complexity. See commits for details. This will help fix a complexity issue on one of the stable branches.

@smagnani96 smagnani96 self-assigned this Jul 31, 2026
@smagnani96 smagnani96 added area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. kind/cleanup This includes no functional changes. release-note/misc This PR makes changes that have no direct user impact. labels Jul 31, 2026
@smagnani96

This comment was marked as outdated.

@smagnani96
smagnani96 requested a review from pchaigno July 31, 2026 17:47
Similarly to what has been done in commit 524a591 ("bpf: Never
allocate ct_buffers on stack"), let's move the `ct_buffer` to a pointer
in `ipv{4,6}_host_policy_egress`. No additional code changes should be
needed, as we initialize and use fields in subsequent functions as long
as we need them.

This should free us some space in stack and lower complexity.

This requires moving the `cilium_tail_call_buffer{4,6}` map definitions
before we include host_firewall.h. In host_firewall.h we already gate
and protect to use it only when IS_BPF_HOST.

Signed-off-by: Simone Magnani <[email protected]>
Similar to the previous commit and to what has been done in commit
524a591 ("bpf: Never allocate ct_buffers on stack"), let's move
the `ct_buffer` to a pointer in `ipv{4,6}_host_policy_egress`. No
additional code changes should be needed, as we initialize and use
fields in subsequent functions as long as we need them.

This should free us some space in stack and lower complexity.

Signed-off-by: Simone Magnani <[email protected]>
@pchaigno
pchaigno force-pushed the pr/smagnani96/complexity-and-stack-optim branch from 2a90f81 to 9235a51 Compare August 3, 2026 08:36
@pchaigno pchaigno added area/host-firewall Impacts the host firewall or the host endpoint. kind/complexity-issue Relates to BPF complexity or program size issues needs-backport/1.18 This PR / issue needs backporting to the v1.18 branch needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch needs-backport/1.20 This PR / issue needs backporting to the v1.20 branch labels Aug 3, 2026
@pchaigno
pchaigno marked this pull request as ready for review August 3, 2026 08:38
@pchaigno
pchaigno requested a review from a team as a code owner August 3, 2026 08:38
@pchaigno
pchaigno enabled auto-merge August 3, 2026 08:38
@cilium-ariane

cilium-ariane Bot commented Aug 3, 2026

Copy link
Copy Markdown

/test

@pchaigno
pchaigno disabled auto-merge August 3, 2026 09:42
@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 Aug 3, 2026
@pchaigno pchaigno added dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. and removed ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels Aug 3, 2026
@pchaigno

pchaigno commented Aug 3, 2026

Copy link
Copy Markdown
Member

Unfortunately, this fix is causing a significant increase of complexity in main:
image

I'll check if it's different in v1.18 where we need this, but if not, I'll need to find some other fix. We don't need this in v1.18, only in v1.19. We can probably find another way.

@pchaigno
pchaigno marked this pull request as draft August 6, 2026 07:42
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. area/host-firewall Impacts the host firewall or the host endpoint. dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. kind/cleanup This includes no functional changes. kind/complexity-issue Relates to BPF complexity or program size issues needs-backport/1.18 This PR / issue needs backporting to the v1.18 branch needs-backport/1.19 This PR / issue needs backporting to the v1.19 branch needs-backport/1.20 This PR / issue needs backporting to the v1.20 branch release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants