2017-03-13 03:46:46 -04:00
|
|
|
package libnetwork
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/docker/libnetwork/iptables"
|
2017-07-26 17:18:31 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2017-03-13 03:46:46 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
const userChain = "DOCKER-USER"
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
}
|
|
|
|
}
|