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

Support create network with com.docker.network.bridge.enable_ip_masquerade option #2592

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pkg/netutil/netutil_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"net"
"os/exec"
"path/filepath"
"strconv"
"strings"

"github.com/Masterminds/semver/v3"
Expand Down Expand Up @@ -94,13 +95,19 @@ func (e *CNIEnv) generateCNIPlugins(driver string, name string, ipam map[string]
switch driver {
case "bridge":
mtu := 0
iPMasq := true
for opt, v := range opts {
switch opt {
case "mtu", "com.docker.network.driver.mtu":
mtu, err = ParseMTU(v)
if err != nil {
return nil, err
}
case "ip-masq", "com.docker.network.bridge.enable_ip_masquerade":
iPMasq, err = strconv.ParseBool(v)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("unsupported %q network option %q", driver, opt)
}
Expand All @@ -114,7 +121,7 @@ func (e *CNIEnv) generateCNIPlugins(driver string, name string, ipam map[string]
bridge.MTU = mtu
bridge.IPAM = ipam
bridge.IsGW = true
bridge.IPMasq = true
bridge.IPMasq = iPMasq
bridge.HairpinMode = true
plugins = []CNIPlugin{bridge, newPortMapPlugin(), newFirewallPlugin(), newTuningPlugin()}
plugins = fixUpIsolation(e, name, plugins)
Expand Down