Skip to content

bpf:test: extend encrypt_host.h suite and add decrypt_host.h#44339

Merged
julianwiedmann merged 4 commits intomainfrom
pr/smagnani96/wg-test-fix
Apr 1, 2026
Merged

bpf:test: extend encrypt_host.h suite and add decrypt_host.h#44339
julianwiedmann merged 4 commits intomainfrom
pr/smagnani96/wg-test-fix

Conversation

@smagnani96
Copy link
Copy Markdown
Contributor

@smagnani96 smagnani96 commented Feb 13, 2026

Please refer to commit descriptions.

  1. bpf:tests:decrypt_host: create test suite for network encrypted pkts: this is to create the complementary test suite decrypt_host, which is in charge of testing incoming network encrypted packets. While doing that, do some renaming to align files.
  2. move and cleanup encryption tests to encrypt_host suite: this is to move hook-related changes in encrypt_host suite, while leaving all helpers in own files. While doing that, do some renaming to align files.
  3. bpf:tests:encrypt_host: extend suite with IPv6 coverage: this is to expand the encrypt_host test suite with also IPv6 tests. Strict Mode does not support IPv6, we therefore don't expect drops.
  4. bpf:tests:wireguard: use sizeof(struct ethhdr) for L4 offset: this is a small cleanup to prevent misbehaviors.

@smagnani96 smagnani96 self-assigned this Feb 13, 2026
@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. labels Feb 13, 2026
@smagnani96 smagnani96 force-pushed the pr/smagnani96/wg-test-fix branch from a2de837 to be7fe83 Compare February 13, 2026 17:35
@smagnani96 smagnani96 force-pushed the pr/smagnani96/wg-test-fix branch 2 times, most recently from d2b2d11 to e3f820a Compare February 16, 2026 14:23
@smagnani96
Copy link
Copy Markdown
Contributor Author

/test

@smagnani96 smagnani96 marked this pull request as ready for review February 17, 2026 11:10
@smagnani96 smagnani96 requested a review from a team as a code owner February 17, 2026 11:10
@julianwiedmann julianwiedmann added feature/wireguard Relates to Cilium's Wireguard feature release-note/ci This PR makes changes to the CI. and removed release-note/misc This PR makes changes that have no direct user impact. labels Feb 18, 2026
Copy link
Copy Markdown
Member

@julianwiedmann julianwiedmann left a comment

Choose a reason for hiding this comment

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

bpf:test: fix ETH_HLEN naming in wireguard_helpers_tests.c

✔️ (see nit pick)

bpf:test:wireguard: file renaming according to TC hook

✔️

bpf:test:wireguard: remove redundant from-netdev checks

:processing:

bpf:test:wireguard: fix node lookup with ipcache lookup

✔️

bpf:test:wireguard: add to-netdev test plain IPv4/6 pod-to-pod packet
bpf:test:wireguard: add to-netdev test plain IPv4/6 node-to-node packet

see comment

bpf:test:wireguard: add ingress strict mode tests for IPv6

✔️

@julianwiedmann julianwiedmann self-requested a review February 18, 2026 16:09
@julianwiedmann julianwiedmann marked this pull request as draft March 5, 2026 09:07
@julianwiedmann
Copy link
Copy Markdown
Member

julianwiedmann commented Mar 5, 2026

bpf:test:wireguard: remove redundant from-netdev checks

:processing:

✔️ agree with your reasoning! :)

@smagnani96 smagnani96 force-pushed the pr/smagnani96/wg-test-fix branch from e3f820a to 3a8eba6 Compare March 26, 2026 16:25
@smagnani96
Copy link
Copy Markdown
Contributor Author

@julianwiedmann I just updated this following your suggestions and trying to expand the test suite even further.
Updated commits, commits messages, and PR description accordingly.
Could split it in multiple PRs if you want, or pull in other reviewers if too much 🙏🏼

@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 26, 2026

/test

@smagnani96 smagnani96 marked this pull request as ready for review March 27, 2026 11:01
@smagnani96 smagnani96 changed the title bpf:test:wireguard: remove duplicates and add to-netdev and strict mode coverage bpf:test: extend encrypt_host.h suite and add decrypt_host.h Mar 27, 2026
Copy link
Copy Markdown
Member

@julianwiedmann julianwiedmann left a comment

Choose a reason for hiding this comment

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

@julianwiedmann I just updated this following your suggestions and trying to expand the test suite even further. Updated commits, commits messages, and PR description accordingly. Could split it in multiple PRs if you want, or pull in other reviewers if too much 🙏🏼

Thank you! Looks great overall, except that bpf:tests:encrypt_host: extend suite with Overlay coverage rubs me slightly wrong ... but I can't place exactly why right now. Would it be possible to extract that patch into a separate PR for an additional look, and merge the rest? Or are there too many conflicts with patches 4/5 ?

@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 Mar 31, 2026
@julianwiedmann julianwiedmann 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 Mar 31, 2026
@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 Mar 31, 2026
While defining the macro ETH_HLEN back then, I lost an "H" in the name.
Given we don't need to specifically set it to 0 (we're testing wireguard
helpers called from other files, such as bpf_host), let's get rid of
this, and use sizeof(struct ethhdr) for computing L4 offset in tests.
Before this degrades and breaks the tests, let's fix it.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
This commit adds IPv6 coverage to the encrypt_host test suite,
by basically replicating the existing IPv4 tests for IPv6. Differently,
ENCRYPTION_STRICT_MODE_EGRESS does not expect to drop IPv6 packets, therefore
we only check for CTX_ACT_OK.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
* ipsec_encryption_on_egress.c: removed, not testing anything new wrt to
  encrypt_host.h suite, therefore deleted.
* ipsec_redirect_generic.h, ipsec_redirect_native.c, ipsec_redirect_tunnel.c:
  renamed to encryption_helpers_ipsec.h, encryption_helpers_ipsec_native.c,
  encryption_helpers_ipsec_tunnel.c.
* moved redirect iface and flags check in encrypt_host.h suite, and leaving
  the encryption_helpers_ipsec suite only for mere helper tests, no more
  hook tests (netdev_send_packet or netdev_receive_packet).

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
* wireguard_helpers_tests.c: renamed to encryption_helpers_wireguard.c
  and left intact.
* wireguard_from_netdev.c: deleted in favor of new decrypt_host.h suite.
  The positive test case is kept, while the negative ones are removed
  as already tested in encryption_helpers_wireguard.c
* tc_wireguard_from_overlay.c: renamed to decrypt_overlay_wireguard.c and
  left intact.
* decrypt_host.h: new test suite for incoming encrypted pkts, with both
  wireguard and ipsec tests.
* scapy pkt defs: added new ones for ipsec and renamed the ones for
  wireguard, while removing also the unused ones.
* encryption_helpers_ipsec.c/h: added new tests for the mere do_decrypt
  helpers, while leaving all the hook-level tests in the decrypt_host.h suite.
  Added tests for `ctx_is_{en,de}crypt()` helpers for ipsec as well.

Signed-off-by: Simone Magnani <simone.magnani@isovalent.com>
@smagnani96 smagnani96 force-pushed the pr/smagnani96/wg-test-fix branch from 3a8eba6 to dee2581 Compare March 31, 2026 16:21
@smagnani96 smagnani96 added the feature/ipsec Relates to Cilium's IPsec feature label Mar 31, 2026
@smagnani96
Copy link
Copy Markdown
Contributor Author

Overlay removed, follow-up created #45084.
Thanks for the review!

@smagnani96
Copy link
Copy Markdown
Contributor Author

/test

@julianwiedmann julianwiedmann removed the dont-merge/discussion A discussion is ongoing and should be resolved before merging, regardless of reviews & tests status. label Apr 1, 2026
@julianwiedmann julianwiedmann added this pull request to the merge queue Apr 1, 2026
Merged via the queue into main with commit da7e6cc Apr 1, 2026
90 of 91 checks passed
@julianwiedmann julianwiedmann deleted the pr/smagnani96/wg-test-fix branch April 1, 2026 03:23
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. feature/ipsec Relates to Cilium's IPsec feature 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/ci This PR makes changes to the CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants