Skip to content

Commit

Permalink
Merge pull request moby#2466 from arkodg/revert-iptables-docker-user
Browse files Browse the repository at this point in the history
Revert "Merge pull request moby#2339 from phyber/iptables-check"

(cherry picked from commit 90afbb0)
Signed-off-by: Arko Dasgupta <[email protected]>
  • Loading branch information
selansen authored and Arko Dasgupta committed Oct 11, 2019
1 parent 45c7102 commit d8192a9
Showing 1 changed file with 2 additions and 32 deletions.
34 changes: 2 additions & 32 deletions firewall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,22 @@ package libnetwork

import (
"github.com/docker/libnetwork/iptables"
"github.com/docker/libnetwork/netlabel"
"github.com/sirupsen/logrus"
)

const userChain = "DOCKER-USER"

func (c *controller) arrangeUserFilterRule() {
c.Lock()

if c.hasIPTablesEnabled() {
arrangeUserFilterRule()
}

arrangeUserFilterRule()
c.Unlock()

iptables.OnReloaded(func() {
c.Lock()

if c.hasIPTablesEnabled() {
arrangeUserFilterRule()
}

arrangeUserFilterRule()
c.Unlock()
})
}

func (c *controller) hasIPTablesEnabled() bool {
// Locking c should be handled in the calling method.
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
}

// This chain allow users to configure firewall policies in a way that persists
// docker operations/restarts. Docker will not delete or modify any pre-existing
// rules from the DOCKER-USER filter chain.
Expand Down

0 comments on commit d8192a9

Please sign in to comment.