mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
![Sebastiaan van Stijn](/assets/img/avatar_default.png)
full diff: 0025177e3d...90afbb01e1
includes:
- docker/libnetwork#/2459 Fix Error Check in NewNetwork
- docker/libnetwork#/2466 Revert "Merge pull request #2339 from phyber/iptables-check"
- reverts docker/libnetwork#/2339 controller: Check if IPTables is enabled for arrangeUserFilterRule
- re-opens docker/libnetwork#2158 dockerd when run with --iptables=false modifies iptables by adding DOCKER-USER
- re-opens moby/moby#35777 With iptables=false dockerd still creates DOCKER-USER chain and rules
- re-opens docker/for-linux#136 dockerd --iptables=false adds DOCKER-USER chain and modify FORWARD chain anyway
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
40 lines
1,008 B
Go
40 lines
1,008 B
Go
package libnetwork
|
|
|
|
import (
|
|
"github.com/docker/libnetwork/iptables"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
const userChain = "DOCKER-USER"
|
|
|
|
func (c *controller) arrangeUserFilterRule() {
|
|
c.Lock()
|
|
arrangeUserFilterRule()
|
|
c.Unlock()
|
|
iptables.OnReloaded(func() {
|
|
c.Lock()
|
|
arrangeUserFilterRule()
|
|
c.Unlock()
|
|
})
|
|
}
|
|
|
|
// 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.
|
|
func arrangeUserFilterRule() {
|
|
_, err := iptables.NewChain(userChain, iptables.Filter, false)
|
|
if err != nil {
|
|
logrus.Warnf("Failed to create %s chain: %v", userChain, err)
|
|
return
|
|
}
|
|
|
|
if err = iptables.AddReturnRule(userChain); err != nil {
|
|
logrus.Warnf("Failed to add the RETURN rule for %s: %v", userChain, err)
|
|
return
|
|
}
|
|
|
|
err = iptables.EnsureJumpRule("FORWARD", userChain)
|
|
if err != nil {
|
|
logrus.Warnf("Failed to ensure the jump rule for %s: %v", userChain, err)
|
|
}
|
|
}
|