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

[WIP] Add DOCKER-USER chain when iptables=true is set ENGCORE-1114 #2464

Closed
wants to merge 3 commits into from

Conversation

arkodg
Copy link
Contributor

@arkodg arkodg commented Oct 9, 2019

This PR fixes the regression introduced by
#2339 to

  1. correctly insert the DOCKER-USER chain if iptables=true is set in the Daemon config
  2. To make sure DOCKER-USER is the first chain and DOCKER-INGRESS is the second chain in forwarding
  3. To make sure we do not create DOCKER-INGRESS and DOCKER-USER if iptables=false

All the logic has been moved to the bridge driver since EnableIPTables is a bridge specific configuration

Addresses : docker/for-linux#810 ENGCORE-1114

Signed-off-by: Arko Dasgupta [email protected]

@arkodg
Copy link
Contributor Author

arkodg commented Oct 9, 2019

PTAL @selansen @mavenugo @joeabbey

@selansen
Copy link
Collaborator

selansen commented Oct 9, 2019

@arkodg , before this change, I noticed arrangeUserFilterRule is getting called white creating NewNetwork(). Now I see we invoke only for bridge driver. Any specific reason why this has been moved from generic code base to inside bridge driver ?

@arkodg
Copy link
Contributor Author

arkodg commented Oct 9, 2019

@selansen because this piece of code correctly deciphers whether enableIPTables is set or not and this is where we take care of fundamental things like enable ip_forwarding

Copy link
Collaborator

@selansen selansen left a comment

Choose a reason for hiding this comment

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

LGTM

@selansen
Copy link
Collaborator

@mavenugo , PTAL .

@@ -357,6 +358,13 @@ func (d *driver) configure(option map[string]interface{}) error {
}
// Make sure on firewall reload, first thing being re-played is chains creation
iptables.OnReloaded(func() { logrus.Debugf("Recreating iptables chains on firewall reload"); setupIPChains(config) })

// Add DOCKER-USER chain
arrangeUserFilterRule()
Copy link
Contributor

Choose a reason for hiding this comment

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

now arrangeUserFIlterRule is called on all systems, linux/windows/bsd etc, is this by intention?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK bridge is for linux only

Copy link
Contributor

Choose a reason for hiding this comment

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

I suppose for any *nix, we expect to create bridge. I see somewhere there are _bsd specific imple. So I am guessing at some point before at least bsd is supported?

@@ -33,6 +33,7 @@ const (
vethLen = 7
defaultContainerVethPrefix = "eth"
maxAllocatePortAttempts = 10
userChain = "DOCKER-USER"
Copy link
Contributor

Choose a reason for hiding this comment

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

I have similar questions as Elango, why move to bridge.go, may be the real problem is that controller.hasIPTableEnabled() isn't the correct value?

Copy link
Contributor

Choose a reason for hiding this comment

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

by moving arrangeUserFilterRule to bridge only network, it means unless a bridge network is created, there won't be DOCKER_USER chain. It will work as dockerd always creates docker9 bridge, but for me the original approach is cleaner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@guillaumerose
Copy link

Is it possible to add an e2e test somewhere that checks that after dockerd startup sequence the output of iptables -L is fine ?

@euanh euanh self-requested a review October 10, 2019 12:58
Copy link
Collaborator

@euanh euanh left a comment

Choose a reason for hiding this comment

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

I'm uncomfortable merging anything else in this area until we have some sort of regression test. It doesn't need to be fancy - just something that checks that the iptables setup looks sane, as @guillaumerose suggested.

@arkodg
Copy link
Contributor Author

arkodg commented Oct 10, 2019

yah, I wanted to decide where to put the code before I added a TC, added one now

@arkodg arkodg requested a review from euanh October 10, 2019 18:50
@arkodg arkodg changed the title Add DOCKER-USER chain when iptables=true is set [DO NOT MERGE] Add DOCKER-USER chain when iptables=true is set Oct 11, 2019
@arkodg arkodg changed the title [DO NOT MERGE] Add DOCKER-USER chain when iptables=true is set [WIP] Add DOCKER-USER chain when iptables=true is set Oct 11, 2019
Arko Dasgupta added 2 commits October 10, 2019 19:57
This PR fixes the regression introduced by
moby#2339 to
correctly insert the DOCKER-USER chain if iptables=true
is set in the Daemon config

Addresses : docker/for-linux#810

Signed-off-by: Arko Dasgupta <[email protected]>
@andrewhsu andrewhsu changed the title [WIP] Add DOCKER-USER chain when iptables=true is set [WIP] Add DOCKER-USER chain when iptables=true is set ENGCORE-1114 Oct 11, 2019
@arkodg arkodg closed this Oct 15, 2019
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.

5 participants