Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.0 backport] libnet/d/bridge: Allow IPv6 ICC from any IP address #46214

Merged
merged 1 commit into from Aug 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 15 additions & 8 deletions libnetwork/drivers/bridge/setup_ip_tables.go
Expand Up @@ -397,15 +397,21 @@ func removeIPChains(version iptables.IPVersion) {
}

func setupInternalNetworkRules(bridgeIface string, addr *net.IPNet, icc, insert bool) error {
var (
inDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{"-i", bridgeIface, "!", "-d", addr.String(), "-j", "DROP"}}
outDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{"-o", bridgeIface, "!", "-s", addr.String(), "-j", "DROP"}}
)

version := iptables.IPv4

if addr.IP.To4() == nil {
var version iptables.IPVersion
var inDropRule, outDropRule iptRule

if addr.IP.To4() != nil {
version = iptables.IPv4
inDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{
"-i", bridgeIface, "!", "-d", addr.String(), "-j", "DROP"}}
outDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{
"-o", bridgeIface, "!", "-s", addr.String(), "-j", "DROP"}}
} else {
version = iptables.IPv6
inDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{
"-i", bridgeIface, "!", "-o", bridgeIface, "!", "-d", addr.String(), "-j", "DROP"}}
outDropRule = iptRule{table: iptables.Filter, chain: IsolationChain1, args: []string{
"!", "-i", bridgeIface, "-o", bridgeIface, "!", "-s", addr.String(), "-j", "DROP"}}
}

if err := programChainRule(version, inDropRule, "DROP INCOMING", insert); err != nil {
Expand All @@ -414,6 +420,7 @@ func setupInternalNetworkRules(bridgeIface string, addr *net.IPNet, icc, insert
if err := programChainRule(version, outDropRule, "DROP OUTGOING", insert); err != nil {
return err
}

// Set Inter Container Communication.
return setIcc(version, bridgeIface, icc, insert)
}
Expand Down