Skip to content

Commit

Permalink
Merge pull request #2592 from yankay/support-enable_ip_masquerade
Browse files Browse the repository at this point in the history
Support create network with `com.docker.network.bridge.enable_ip_masquerade` option
  • Loading branch information
AkihiroSuda authored Oct 26, 2023
2 parents 16384fa + 3596684 commit 5486dd7
Showing 1 changed file with 8 additions and 1 deletion.
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

0 comments on commit 5486dd7

Please sign in to comment.