Skip to content

Commit

Permalink
Add a filter chain to allow persistent rules
Browse files Browse the repository at this point in the history
Allow users to configure firewall policies in way that persists
docker operations/restarts. Docker will not delete or modify any
pre-existing rules from the DOCKER-FORWARD-TOP filter chain. This
allows the user to create in advance any rules required to further
restrict access from/to the containers.

Fixes moby/moby/issues/29184
Fixes moby/moby/issues/23987
Related to moby/moby/issues/24848

Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
  • Loading branch information
Jacob Wen committed Mar 8, 2017
1 parent 03b6683 commit 3f20f3a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/bridge/setup_ip_tables.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
const (
DockerChain = "DOCKER"
IsolationChain = "DOCKER-ISOLATION"
fwdTopChain = "DOCKER-FORWARD-TOP"
)

func setupIPChains(config *configuration) (*iptables.ChainInfo, *iptables.ChainInfo, *iptables.ChainInfo, error) {
Expand Down Expand Up @@ -56,6 +57,15 @@ func setupIPChains(config *configuration) (*iptables.ChainInfo, *iptables.ChainI
return nil, nil, nil, err
}

_, err = iptables.NewChain(fwdTopChain, iptables.Filter, false)
if err != nil {
return nil, nil, nil, fmt.Errorf("failed to create FILTER isolation chain: %v", err)
}

if err := addReturnRule(fwdTopChain); err != nil {
return nil, nil, nil, err
}

return natChain, filterChain, isolationChain, nil
}

Expand Down Expand Up @@ -122,6 +132,13 @@ func (n *bridgeNetwork) setupIPTables(config *networkConfiguration, i *bridgeInt
return err
}

d.Lock()
err = ensureJumpRule("FORWARD", fwdTopChain)
d.Unlock()
if err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 3f20f3a

Please sign in to comment.