-
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.
Add a filter chain to allow persistent rules
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. This allows the user to create in advance any rules required to further restrict access from/to the containers. Fixes moby/moby#29184 Fixes moby/moby#23987 Related to moby/moby#24848 Signed-off-by: Jacob Wen <jian.w.wen@oracle.com>
- Loading branch information
Jacob Wen
committed
May 16, 2017
1 parent
37e20af
commit 0067b3a
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