mirror of
https://github.com/moby/moby.git
synced 2026-07-18 13:30:56 +00:00
full diff: ef149a924d...1a17fb3613
- docker/libnetwork#2538 produce an error with invalid address pool
- addresses docker/docker#40388 dockerd ignores the --default-address-pool option
- docker/libnetwork#2471 DOCKER-USER chain not created when IPTableEnable=false
- docker/libnetwork#2544 Fix NPE due to null value returned by ep.Iface()
- carries docker/libnetwork#2239 Prevent NPE in addServiceInfoToCluster()
- addresses docker/docker#37506 Error initializing docker.server while starting daemon by systemd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package libnetwork
|
|
|
|
import (
|
|
"github.com/docker/libnetwork/iptables"
|
|
"github.com/sirupsen/logrus"
|
|
)
|
|
|
|
const userChain = "DOCKER-USER"
|
|
|
|
var (
|
|
ctrl *controller = nil
|
|
)
|
|
|
|
func setupArrangeUserFilterRule(c *controller) {
|
|
ctrl = c
|
|
iptables.OnReloaded(arrangeUserFilterRule)
|
|
}
|
|
|
|
// 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.
|
|
// Note once DOCKER-USER chain is created, docker engine does not remove it when
|
|
// IPTableForwarding is disabled, because it contains rules configured by user that
|
|
// are beyond docker engine's control.
|
|
func arrangeUserFilterRule() {
|
|
if ctrl == nil || !ctrl.iptablesEnabled() {
|
|
return
|
|
}
|
|
_, 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)
|
|
}
|
|
}
|