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
bpf: Fix host firewall in presence of kube-proxy masquerading #13049
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pchaigno
added
sig/datapath
Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
release-note/minor
This PR changes functionality that users may find relevant to operating Cilium.
area/host-firewall
Impacts the host firewall or the host endpoint.
ci/host-firewall
This label enables the host firewall by default in all CI tests.
labels
Sep 2, 2020
pchaigno
force-pushed
the
pr/pchaigno/fix-hostfw-kube-proxy-masq
branch
2 times, most recently
from
September 2, 2020 19:56
d6c5ac4
to
41e66f1
Compare
pchaigno
added
release-note/bug
This PR fixes an issue in a previous release of Cilium.
and removed
release-note/minor
This PR changes functionality that users may find relevant to operating Cilium.
labels
Sep 2, 2020
pchaigno
changed the title
Fix host firewall in presence of kube-proxy masquerading
[RFC] Fix host firewall in presence of kube-proxy masquerading
Sep 7, 2020
If kube-proxy is in use (no BPF-based masquerading), packets from pods may be SNATed. The response packet will therefore have a host IP as the destination IP. For example, if a pod connects to 1.1.1.1: # Pod sends a SYN. from-lxc: 10.8.0.1 -> 1.1.1.1 # Src IP gets masqueraded to 192.168.33.11. We skip the host firewall # because the packet mark tells us this is not coming from hostns. to-netdev: 192.168.33.11 -> 1.1.1.1 ... # SYN+ACK is sent to 192.168.33.11. This IP belongs to the host # endpoints, so we incorrectly enforce host policy on this packet. from-netdev: 1.1.1.1 -> 192.168.33.11 To avoid enforcing host policies for response packets to pods, we need to create a CT entry for the forward, SNATed packet from the pod. Response packets will thus match this CT entry and bypass host policies. I tested this change by deploying the connectivity checks in the dev. VM with kube-proxy and the lock-down-dev-vms.yaml host policy. A subsequent commit also updates the CIDR+toPorts host policy test to run it when kube-proxy is used. Finally, the pull request has label ci/host-firewall to run all e2e CI tests on Jenkins with the host firewall enabled by default. Fixes: 88bf291 ("bpf: Enforce host policies for IPv4") Signed-off-by: Paul Chaignon <paul@cilium.io>
Previous commit fixed the host firewall to work with kube-proxy. Thus, we can now run the CIDR+toPorts test for the host firewall when kube-proxy is enabled. Signed-off-by: Paul Chaignon <paul@cilium.io>
This includes allowing some services that were not present on the release-channel=rapid GKE clusters. Signed-off-by: Paul Chaignon <paul@cilium.io>
Signed-off-by: Paul Chaignon <paul@cilium.io>
pchaigno
force-pushed
the
pr/pchaigno/fix-hostfw-kube-proxy-masq
branch
from
September 7, 2020 14:48
41e66f1
to
a14ea2d
Compare
test-me-please |
borkmann
reviewed
Sep 9, 2020
nebril
approved these changes
Sep 10, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI bit looks good (yay for not skipping tests!).
borkmann
approved these changes
Sep 14, 2020
pchaigno
changed the title
[RFC] Fix host firewall in presence of kube-proxy masquerading
Fix host firewall in presence of kube-proxy masquerading
Sep 14, 2020
pchaigno
changed the title
Fix host firewall in presence of kube-proxy masquerading
bpf: Fix host firewall in presence of kube-proxy masquerading
Sep 14, 2020
vadorovsky
approved these changes
Sep 14, 2020
maintainer-s-little-helper
bot
moved this from Needs backport from master
to Backport pending to v1.8
in 1.8.4
Sep 16, 2020
maintainer-s-little-helper
bot
moved this from Needs backport from master
to Backport pending to v1.8
in 1.8.4
Sep 16, 2020
maintainer-s-little-helper
bot
moved this from Backport pending to v1.8
to Backport done to v1.8
in 1.8.4
Sep 17, 2020
2 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/host-firewall
Impacts the host firewall or the host endpoint.
ci/host-firewall
This label enables the host firewall by default in all CI tests.
release-note/bug
This PR fixes an issue in a previous release of Cilium.
sig/datapath
Impacts bpf/ or low-level forwarding details, including map management and monitor messages.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If kube-proxy is in use (no BPF-based masquerading), packets from pods may be SNATed. The response packet will therefore have a host IP as the destination IP. For example, if a pod connects to 1.1.1.1:
To avoid enforcing host policies for response packets to pods, we need to create a CT entry for the forward, SNATed packet from the pod. Response packets will thus match this CT entry and bypass host policies.
I tested this change by deploying the connectivity checks in the dev. VM with kube-proxy and the
lock-down-dev-vms.yaml
host policy. The second commit also updates the CIDR+toPorts host policy test to run it when kube-proxy is used. Finally, the pull request has labelci/host-firewall
to run all e2e CI tests on Jenkins with the host firewall enabled by default.RFC. I've marked this pull request as RFC because of the performance concern. With this PR, when the host firewall and kube-proxy are enabled, we will perform a CT lookup (+ some CT updates) for each packet ingressing or egressing on the native devices. The only alternative I found so far is to restrict the host firewall to kube-proxy-free mode☹️
Fixes: #11507