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

Deal with auto-egress-ip mark conflicting with kube-proxy's masqueradeBit #18121

Merged

Conversation

danwinship
Copy link
Contributor

@danwinship danwinship commented Jan 16, 2018

auto-egress-ip uses the skb mark (OVS pkt_mark, iptables mark) to communicate information from OVS rules to iptables rules. Normally this works fine, but if the iptables rules get flushed and recreated, it's possible that the OpenShift and kube-proxy rules will get added back in the "wrong" order, and then the kube-proxy rules will start matching some of the auto-egress-ip packets, causing the wrong thing to happen.

Forcibly fixing the iptables rule order is difficult and fragile. Changing the implementation to not use the mark would also not be easy (and would be a lot of code to backport to 3.7). So I fixed it by just changing the code to use mark values that don't conflict with the bit that kube-proxy is using.

This means we only have 31 bits of mark to work with, so we can't reliably use the IP address as the mark value any more. So I switched to using the namespace's VNID instead, since those are only 24 bits. But this required reorganizing the code a bit because previously we were setting up the iptables rules for egress IPs before we knew what namespaces they were associated with.

First commit ("Make sure oc.tunMAC gets set even if AlreadySetUp()") is from #18049

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1527642

@openshift/sig-networking PTAL

@danwinship danwinship added kind/bug Categorizes issue or PR as related to a bug. component/networking sig/networking labels Jan 16, 2018
@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 16, 2018
@danwinship
Copy link
Contributor Author

/retest

Copy link
Contributor

@knobunc knobunc left a comment

Choose a reason for hiding this comment

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

LGTM, thanks Dan

@knobunc
Copy link
Contributor

knobunc commented Jan 17, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 17, 2018
@knobunc
Copy link
Contributor

knobunc commented Jan 17, 2018

@dcbw PTAL

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 18, 2018
@openshift-merge-robot openshift-merge-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 18, 2018
@knobunc
Copy link
Contributor

knobunc commented Jan 19, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 19, 2018
@knobunc
Copy link
Contributor

knobunc commented Jan 19, 2018

/approve

@knobunc
Copy link
Contributor

knobunc commented Jan 19, 2018

/assign @smarterclayton

Clayton, PTAL... we need sign-off for cmd again. Thanks!

@dcbw
Copy link
Contributor

dcbw commented Jan 23, 2018

/lgtm

@knobunc
Copy link
Contributor

knobunc commented Jan 29, 2018

@smarterclayton can you approve us for the /pkg/cmd change please?

@smarterclayton
Copy link
Contributor

/approve

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 30, 2018
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 31, 2018
If the iptables rules get reordered after a flush, then it's possible
that kube-proxy rules that look at MasqueradeBit will accidentally
match a packet that was intended for an auto-egress-ip rule.

To avoid that, change the code to avoid using that bit of pkt_mark.
This means we now only have 31 bits to work with instead of 32, so
make the mark be based on the (24-bit) VNID rather than the (32-bit)
egress IP address.
@openshift-merge-robot openshift-merge-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 31, 2018
@danwinship
Copy link
Contributor Author

/retest

@knobunc
Copy link
Contributor

knobunc commented Feb 1, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danwinship, dcbw, knobunc, smarterclayton

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot
Copy link
Contributor

Automatic merge from submit-queue.

@openshift-merge-robot openshift-merge-robot merged commit ddd1f92 into openshift:master Feb 1, 2018
openshift-merge-robot added a commit that referenced this pull request Feb 2, 2018
Automatic merge from submit-queue.

Drop auto-egress-IP rules when egress IP is removed from NetNamespace

(Previously we were only doing it when the NetNamespace was deleted.)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1540846

(does not conflict with #18121 so it doesn't matter which merges first)
openshift-merge-robot added a commit that referenced this pull request Feb 23, 2018
Automatic merge from submit-queue.

 Fix reassignment of egress IP after removal

When dropping an egress IP from eth0, we weren't updating our internal state to reflect that we had done that, so if you added it back again it wouldn't do everything it needed to do. (Introduced in #18121 but not discoverable until after #18547 was fixed.)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1547899
@danwinship danwinship deleted the egress-ip-mark-conflicts branch March 7, 2018 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/networking kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. sig/networking size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants