Skip to content

Conversation

@murali-reddy
Copy link
Member

@murali-reddy murali-reddy commented May 27, 2020

  • change ACCEPT to RETURN with mark when a netpol is matched so that we run through
    all the applicable network policies for a flow

Fixes #916

@murali-reddy murali-reddy force-pushed the apply-both-ingress-egress-pol branch from 1f59e78 to 129bb94 Compare June 5, 2020 12:25
@murali-reddy murali-reddy changed the base branch from npc-refactor to master June 9, 2020 11:18
… run through

all the applicable network policies for a flow
@murali-reddy murali-reddy force-pushed the apply-both-ingress-egress-pol branch from 129bb94 to b322dd4 Compare June 9, 2020 11:20
@murali-reddy
Copy link
Member Author

This PR fixes specific case where both source pod and destination pod are on the same node. An egress network policy applied on the source pod may permit traffic from the source pod to destination pod, but a seperate network policy applied to destination pod may reject it. So for the flow both the network policies to be applied to permit/deny traffic. Apart from verifying the fix address the above case ensure there are no regression.

Merging the PR based on testing.

@murali-reddy murali-reddy merged commit e858e26 into master Jun 9, 2020
err := iptablesCmdHandler.AppendUnique("filter", policyChainName, args...)

markComment := "rule to mark traffic matching a network policy"
markArgs := append(args, "-j", "MARK", "-m", "comment", "--comment", markComment, "--set-xmark", "0x10000/0x10000")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I take it that you chose this value, because it's above this range:

? Is there anything else in kube-router than deals with marks?

Copy link
Member Author

Choose a reason for hiding this comment

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

No other use of Markings. Just choose random numbers.

@aauren
Copy link
Collaborator

aauren commented Jun 13, 2020

Seems reasonable, and I can't think of a better approach, but it's a bummer that it essentially doubles the amount of iptables rules that we're going to have though. Overall LGTM.

@murali-reddy
Copy link
Member Author

Seems reasonable, and I can't think of a better approach, but it's a bummer that it essentially doubles the amount of iptables rules that we're going to have though. Overall LGTM.

Thanks for the review. Actually its not bad. Or atleast it does not make any worse performance wise.

Since kube-router is stateful firewall, for the established sessions (i.e. "RELATED,ESTABLISHED") we still ACCEPT, its just for the first packet its run through all the chains.

@aauren
Copy link
Collaborator

aauren commented Jun 13, 2020

Sorry I should have been more clear. I was referring to the time that it takes to perform the full sync on iptables, not the performance of the data path. You're correct, this doesn't have a huge impact on the data path.

FabienZouaoui pushed a commit to SirDataFR/kube-router that referenced this pull request Jun 22, 2020
… run through (cloudnativelabs#915)

all the applicable network policies for a flow
@aauren aauren deleted the apply-both-ingress-egress-pol branch September 4, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

network policies not fully enforced in bridged traffic

3 participants