Browse Source

Reload DOCKER-USER chain on frewalld reload.

Relates to moby/moby#35043

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Brian Goff 7 years ago
parent
commit
d5fef4ca1c
3 changed files with 13 additions and 4 deletions
  1. 1 3
      libnetwork/controller.go
  2. 11 0
      libnetwork/firewall_linux.go
  3. 1 1
      libnetwork/firewall_others.go

+ 1 - 3
libnetwork/controller.go

@@ -882,9 +882,7 @@ addToStore:
 		c.Unlock()
 	}
 
-	c.Lock()
-	arrangeUserFilterRule()
-	c.Unlock()
+	c.arrangeUserFilterRule()
 
 	return network, nil
 }

+ 11 - 0
libnetwork/firewall_linux.go

@@ -7,6 +7,17 @@ import (
 
 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.

+ 1 - 1
libnetwork/firewall_others.go

@@ -2,5 +2,5 @@
 
 package libnetwork
 
-func arrangeUserFilterRule() {
+func (c *controller) arrangeUserFilterRule() {
 }