Skip to content

bpf:wireguard: reuse MARK_MAGIC_ENCRYPT for encrypted packets #39651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2025

Conversation

smagnani96
Copy link
Contributor

@smagnani96 smagnani96 commented May 21, 2025

By protecting previous usages of MARK_MAGIC_ENCRYPT in the IPSec codepaths, we should be able to reuse such mark also to signal WG-encrypted packets. This allows us to save the bit from the k8s mark space and use our host mask.

A backport patch to v1.17 has been submitted #39652 to be able to recognize WG-encrypted packets in the previous version, which still uses MARK_MAGIC_WG_ENCRYPTED, during downgrades. As soon as it gets merged, ci-e2e-upgrade tests should pass.

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 21, 2025
@smagnani96 smagnani96 added kind/enhancement This would improve or streamline existing functionality. area/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. area/encryption Impacts encryption support such as IPSec, WireGuard, or kTLS. release-note/misc This PR makes changes that have no direct user impact. feature/wireguard Relates to Cilium's Wireguard feature labels May 21, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label May 21, 2025
@smagnani96 smagnani96 force-pushed the pr/smagnani96/wg-reuse-ipsec-magic-encrypt branch from be3d7fb to f6dc8c5 Compare May 21, 2025 11:36
@smagnani96
Copy link
Contributor Author

Going to test this. Given the backport hasn't landed yet, I'd expect all upgrades/downgrades tests to fail, while the other ones should be green. Let's see if this meets my expectations.

@smagnani96
Copy link
Contributor Author

/test

@smagnani96
Copy link
Contributor Author

As expected, all tests are passing except downgrade/upgrade from/to the previous Cilium version, as the backport is not merged yet.

This commit protects current usages of MARK_MAGIC_ENCRYPT and
MARK_MAGIC_DECRYPT for only when IPSec is enabled. This should make sure
that in case of further re-using such marks or overlapping marks we do
not hit unexpected codepaths.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
In previous commits we've protected previous usages of MARK_MAGIC_ENCRYPT
in the IPSec codepaths. This means that now we shoudl be able to reuse
such mark also in the WireGuard codepaths, to signal already-encrypted
packets. This helps us simplifying our mark logic, which sometimes needs
to carry 1 bit from the k8s mark space. Hopefully, by protecting all
codepaths, we should be able to use only our space.

A previous backport to v1.17 has been submitted: in v1.17, we still use
MARK_MAGIC_WG_ENCRYPTED. During downgrades from v1.18, we wouldn't be
able to tell that a packet marked with MARK_MAGIC_ENCRYPT has been
WG-encrypted. With the patch being backported, we should support smooth
upgrades/downgrades without disruptions.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
@smagnani96 smagnani96 force-pushed the pr/smagnani96/wg-reuse-ipsec-magic-encrypt branch from f6dc8c5 to 457fc7e Compare May 26, 2025 16:56
@smagnani96 smagnani96 requested a review from pchaigno June 5, 2025 10:27
@smagnani96 smagnani96 self-assigned this Jun 5, 2025
@github-actions github-actions bot added the backport-done/1.17 The backport for Cilium 1.17.x for this PR is done. label Jun 6, 2025
@smagnani96
Copy link
Contributor Author

smagnani96 commented Jun 6, 2025

/test

[Backport Done, expecting e2e-upgrade to work]

[e2e-upgrade 🟢 passed with no conn disruptions, running again to make sure]

[e2e-upgrade 🟢 passed again except an unrelated flake, running again to make sure]

[e2e-upgrade 🟢 passed again, marking as ready-for-review]

@smagnani96 smagnani96 marked this pull request as ready for review June 6, 2025 15:56
@smagnani96 smagnani96 requested a review from a team as a code owner June 6, 2025 15:56
@pchaigno pchaigno added this pull request to the merge queue Jun 10, 2025
@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 Jun 10, 2025
Merged via the queue into main with commit 13b8a32 Jun 10, 2025
405 of 408 checks passed
@pchaigno pchaigno deleted the pr/smagnani96/wg-reuse-ipsec-magic-encrypt branch June 10, 2025 08:57
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/encryption Impacts encryption support such as IPSec, WireGuard, or kTLS. backport-done/1.17 The backport for Cilium 1.17.x for this PR is done. feature/wireguard Relates to Cilium's Wireguard feature kind/enhancement This would improve or streamline existing functionality. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. 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.

4 participants