-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1675 from wenjianhn/forward-top
Add a filter chain to allow persistent rules
- Loading branch information
Showing
5 changed files
with
82 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -844,6 +844,10 @@ addToStore: | |
c.Unlock() | ||
} | ||
|
||
c.Lock() | ||
arrangeUserFilterRule() | ||
c.Unlock() | ||
|
||
return network, nil | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package libnetwork | ||
|
||
import ( | ||
"github.com/Sirupsen/logrus" | ||
"github.com/docker/libnetwork/iptables" | ||
) | ||
|
||
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) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// +build !linux | ||
|
||
package libnetwork | ||
|
||
func arrangeUserFilterRule() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters