Skip to content

[v1.18] bpf:wireguard: delivery host packets to bpf_host for ingress policies#43690

Merged
jrajahalme merged 3 commits intov1.18from
pr/smagnani96/wg-local-redirect-v1.18
Jan 12, 2026
Merged

[v1.18] bpf:wireguard: delivery host packets to bpf_host for ingress policies#43690
jrajahalme merged 3 commits intov1.18from
pr/smagnani96/wg-local-redirect-v1.18

Conversation

@smagnani96
Copy link
Copy Markdown
Contributor

@smagnani96 smagnani96 commented Jan 12, 2026

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

 42892

smagnani96 and others added 3 commits January 12, 2026 13:15
[ upstream commit e3f4218 ]

Context is always skbuff, therefore TC_ACT_OK, I just find the code more
readable with the default CTX_ACT_OK, which in this case resolves to
TC_ACT_OK. This is similar to what we do in bpf_overlay and others.
While at it, move some code comments.

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

This revalidation is only required in the IPv4 path, while
ipv6_local_delivery() doesn't take an `ip6` parameter.

Signed-off-by: Julian Wiedmann <jwi@isovalent.com>
[ upstream commit 88e28e1 ]

This effectively restores HostFw for WireGuard.
Prior to this, we were erroneously always returning to the stack all
packets destined for local host, skipping the HostFw policies if enabled.

With this patch, packets for local host will always be delivered to
cilium_net@egress, similarly to what we do in bpf_overlay after decap.
With HostFw enabled, the to-host program in `cilium_host@ingress` will
then enforce policies.

This patch does not affect packets for local endpoint:
* With BPF Host Routing: will be directly delivered to the pod, tail
  calling into its ep->lxc_id function to enforce ingress policies.
* Without BPF Host Routing: will return to stack, which then goes to its
  to-container installed program to match ingress policies.

Trying to pull-in the whole `host_firewall.h` and `policy.h` would require
to set bpf_wireguard similarly as we do for bpf_host, meaning assigning
an endpoint ID, otherwise host policies would block all host related
packets (ep id == 0). For this reason, we decide here to go through cilium_host.

From a bpf test perspective:
* no changes for packet to/from local endpoint INGRESS/EGRESS
* no changes for packet from local host EGRESS
* packet to local host INGRESS: differently than bpf_host, in WireGuard
                                we always redirect to cilium_host@ingress.

While fixing this bits, let's move the superfluous `revalidate_data`
post NodePort inside the NodePort code, as not needed otherwise.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
@smagnani96 smagnani96 self-assigned this Jan 12, 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 Jan 12, 2026
@smagnani96
Copy link
Copy Markdown
Contributor Author

/test

@smagnani96 smagnani96 changed the title [v1.18] bpf:wireguard: always resolve src identity [v1.18] bpf:wireguard: delivery host packets to bpf_host for ingress policies Jan 12, 2026
@smagnani96 smagnani96 marked this pull request as ready for review January 12, 2026 14:48
@smagnani96 smagnani96 requested a review from a team as a code owner January 12, 2026 14:48
@julianwiedmann julianwiedmann self-requested a review January 12, 2026 14:50
@jrajahalme jrajahalme added this pull request to the merge queue Jan 12, 2026
Merged via the queue into v1.18 with commit 8ecc608 Jan 12, 2026
308 of 309 checks passed
@jrajahalme jrajahalme deleted the pr/smagnani96/wg-local-redirect-v1.18 branch January 12, 2026 15:06
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants