Skip to content
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

Add WireGuard host2host and LB encryption #19401

Merged
merged 13 commits into from Jan 24, 2023

Conversation

brb
Copy link
Member

@brb brb commented Apr 11, 2022

This PR adds support for node-to-node encryption to WireGuard. To achieve this, we've completely changed the WireGuard integration in the datapath. Previously, WireGuard support was implemented by marking packets to be encrypted in "from-container" and redirecting it to the WireGuard tunnel via a hostns IP rule. This worked fine for traffic originating in pods - but for node-to-node traffic, we need to redirect the packets on the outgoing network interface. Thus, the new implementation attaches bpf_host to the outgoing device and redirects packets to the WireGuard tunnel from there. See commit descriptions for more details.

On the agent side, there are also changes to the implementation. Previously, the datapath assumed that any IPCache entry with an associated tunnel endpoint would need encryption. To determine if we need to encryption traffic to a remote endpoint, we now rely on the encrypt_key field instead. This allows us to more precisely track if traffic to a particular destination needs to be encrypted, and allows certain nodes to opt out of encryption (see below). The agent code has been updated to populate the CiliumEndpoint and CiliumNode CRDs with a static non-zero EncryptKey value if encryption for those resources is enabled.

Additional points worth noting:

ℹ️ Please see commit messages for many more details

Joint work between @gandro and @brb

Follow-ups, to be done in separate PRs:

  • (follow-up) Ability to store private key persistently (as an alternative to opting out of node-to-node encryption for control-plane nodes)

@brb brb added sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages. release-note/major This PR introduces major new functionality to Cilium. area/encryption Impacts encryption support such as IPSec, WireGuard, or kTLS. release-blocker/1.12 This issue will prevent the release of the next version of Cilium. labels Apr 11, 2022
@brb
Copy link
Member Author

brb commented Apr 11, 2022

/test-1.23-net-next

@brb
Copy link
Member Author

brb commented Apr 12, 2022

test-1.23-net-next

@brb brb force-pushed the pr/gandro+brb/wg-host-encryption-v2 branch from f7e67e9 to 6224144 Compare April 14, 2022 09:03
@brb brb changed the title Add WireGuard host2host encryption Add WireGuard host2host and LB encryption Apr 14, 2022
@brb brb removed the release-blocker/1.12 This issue will prevent the release of the next version of Cilium. label Apr 14, 2022
@brb brb mentioned this pull request Apr 14, 2022
@gandro gandro force-pushed the pr/gandro+brb/wg-host-encryption-v2 branch from 6224144 to 1ee8cd2 Compare May 3, 2022 14:27
@github-actions

This comment was marked as resolved.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jun 3, 2022
@brb brb removed the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jun 3, 2022
@github-actions
Copy link

github-actions bot commented Jul 7, 2022

This pull request has been automatically marked as stale because it
has not had recent activity. It will be closed if no further activity
occurs. Thank you for your contributions.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jul 7, 2022
@github-actions github-actions bot removed the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Jul 16, 2022
@github-actions

This comment was marked as resolved.

@github-actions github-actions bot added the stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. label Aug 15, 2022
@brb brb added pinned These issues are not marked stale by our issue bot. and removed stale The stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale. labels Aug 15, 2022
@brb brb added this to the 1.13 milestone Aug 15, 2022
@brb brb force-pushed the pr/gandro+brb/wg-host-encryption-v2 branch 2 times, most recently from 37d5c58 to f321011 Compare September 8, 2022 07:58
@brb
Copy link
Member Author

brb commented Sep 8, 2022

/test

@brb
Copy link
Member Author

brb commented Jan 24, 2023

Got reviews from majority of folks. Marking as ready-to-merge.

@brb brb added the ready-to-merge This PR has passed all tests and received consensus from code owners to merge. label Jan 24, 2023
@ldelossa ldelossa merged commit 481015e into master Jan 24, 2023
@ldelossa ldelossa deleted the pr/gandro+brb/wg-host-encryption-v2 branch January 24, 2023 15:04
giorio94 added a commit to giorio94/cilium that referenced this pull request Feb 20, 2023
Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of cilium#19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
pchaigno pushed a commit that referenced this pull request Feb 20, 2023
Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of #19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
sayboras pushed a commit to sayboras/cilium that referenced this pull request Feb 27, 2023
[upstream commit 5463073]

Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of cilium#19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
sayboras pushed a commit to sayboras/cilium that referenced this pull request Feb 27, 2023
[upstream commit 5463073]

Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of cilium#19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
sayboras pushed a commit that referenced this pull request Feb 28, 2023
[upstream commit 5463073]

Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of #19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
sayboras pushed a commit that referenced this pull request Feb 28, 2023
[upstream commit 5463073]

Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of #19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
YutaroHayakawa pushed a commit to YutaroHayakawa/cilium that referenced this pull request Mar 17, 2023
Currently, wireguard encryption is not performed when the nodes have
ipv6-only addresses, since it relies on the tunnel_endpoint field of
the ipcache map (which is not set in such case). This limitation has
been removed with the reworking performed as part of cilium#19401. As for
previous versions, this commit adds a check to prevent the agent from
starting in this configuration.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
Signed-off-by: Michi Mutsuzaki <michi@isovalent.com>
gandro added a commit to gandro/cilium that referenced this pull request May 30, 2023
This commit fixes an outdated comment in our Helm `values.yaml` file.
Originally, node-to-node encryption was a beta feature only supported
with IPSec. However, since then, we have removed the IPSec support
(cilium#21333), but have added support in WireGuard instead (cilium#19401).

Fixes: 5e98037 ("cmd: Unhide node-encryption flag")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
michi-covalent pushed a commit to michi-covalent/cilium that referenced this pull request May 30, 2023
This commit introduces the following encryption tests which check
whether there is no unencrypted traffic leakage:

* Node to remote pod
* Pod to remote node
* Node to remote node

Also, it refactors the previous encryption test case to make it
reusable by the new test cases.

One important detail is that the tcpdump filter is appended with "and
(tcp or icmp)", as otherwise in the case of the node-to-node test case
the tcpdump would capture encrypted UDP WireGuard traffic.

Tested manually with cilium#19401
(until #merge-cilium-and-cilium-cli).

Signed-off-by: Martynas Pumputis <m@lambda.lt>
julianwiedmann pushed a commit that referenced this pull request May 31, 2023
This commit fixes an outdated comment in our Helm `values.yaml` file.
Originally, node-to-node encryption was a beta feature only supported
with IPSec. However, since then, we have removed the IPSec support
(#21333), but have added support in WireGuard instead (#19401).

Fixes: 5e98037 ("cmd: Unhide node-encryption flag")

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/encryption Impacts encryption support such as IPSec, WireGuard, or kTLS. pinned These issues are not marked stale by our issue bot. ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/major This PR introduces major new functionality to Cilium. sig/datapath Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet