firewall_linux.go 827 B

1234567891011121314151617181920212223242526272829
  1. package libnetwork
  2. import (
  3. "github.com/Sirupsen/logrus"
  4. "github.com/docker/libnetwork/iptables"
  5. )
  6. const userChain = "DOCKER-USER"
  7. // This chain allow users to configure firewall policies in a way that persists
  8. // docker operations/restarts. Docker will not delete or modify any pre-existing
  9. // rules from the DOCKER-USER filter chain.
  10. func arrangeUserFilterRule() {
  11. _, err := iptables.NewChain(userChain, iptables.Filter, false)
  12. if err != nil {
  13. logrus.Warnf("Failed to create %s chain: %v", userChain, err)
  14. return
  15. }
  16. if err = iptables.AddReturnRule(userChain); err != nil {
  17. logrus.Warnf("Failed to add the RETURN rule for %s: %v", userChain, err)
  18. return
  19. }
  20. err = iptables.EnsureJumpRule("FORWARD", userChain)
  21. if err != nil {
  22. logrus.Warnf("Failed to ensure the jump rule for %s: %v", userChain, err)
  23. }
  24. }