Skip to content

Commit

Permalink
controller: Check if IPTables is enabled for arrangeUserFilterRule
Browse files Browse the repository at this point in the history
This allows the `--iptables=false` argument to the `dockerd` to actually
work.

Signed-off-by: David O'Rourke <david@scalefactory.com>
  • Loading branch information
phyber committed Apr 29, 2019
1 parent 9ff9b57 commit 5e34060
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,29 @@ func (c *controller) isAgent() bool {
return c.cfg.Daemon.ClusterProvider.IsAgent()
}

func (c *controller) hasIPTablesEnabled() bool {
c.Lock()
defer c.Unlock()

if c.cfg == nil || c.cfg.Daemon.DriverCfg[netlabel.GenericData] == nil {
return false
}

genericData, ok := c.cfg.Daemon.DriverCfg[netlabel.GenericData]
if !ok {
return false
}

optMap := genericData.(map[string]interface{})

enabled, ok := optMap["EnableIPTables"].(bool)
if !ok {
return false
}

return enabled
}

func (c *controller) isDistributedControl() bool {
return !c.isManager() && !c.isAgent()
}
Expand Down Expand Up @@ -902,7 +925,9 @@ addToStore:
c.Unlock()
}

c.arrangeUserFilterRule()
if c.hasIPTablesEnabled() {
c.arrangeUserFilterRule()
}

return network, nil
}
Expand Down

0 comments on commit 5e34060

Please sign in to comment.