diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-02-03 06:51:23 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-03 06:51:23 -0500 |
commit | 8f51d325af7a2af76fb4e6664779bda6eb76d12c (patch) | |
tree | 01b6408440c8dfe4d21ebe211b8e5856a49c5c0b /libpod | |
parent | ec0041ebfff5b6a040a61baa3ffbc2348fe65a0e (diff) | |
parent | 0959196807bb85b1941343a6b984bfd7a08cfd06 (diff) | |
download | podman-8f51d325af7a2af76fb4e6664779bda6eb76d12c.tar.gz podman-8f51d325af7a2af76fb4e6664779bda6eb76d12c.tar.bz2 podman-8f51d325af7a2af76fb4e6664779bda6eb76d12c.zip |
Merge pull request #9174 from bitstrings/master
Make slirp MTU configurable (network_cmd_options)
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/networking_linux.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go index 737dbf935..01e4102d1 100644 --- a/libpod/networking_linux.go +++ b/libpod/networking_linux.go @@ -15,6 +15,7 @@ import ( "path/filepath" "regexp" "sort" + "strconv" "strings" "syscall" "time" @@ -42,6 +43,9 @@ const ( // slirp4netnsDNS is the IP for the built-in DNS server in the slirp network slirp4netnsDNS = "10.0.2.3" + + // slirp4netnsMTU the default MTU override + slirp4netnsMTU = 65520 ) // Get an OCICNI network config @@ -282,6 +286,7 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error { enableIPv6 := false outboundAddr := "" outboundAddr6 := "" + mtu := slirp4netnsMTU if ctr.config.NetworkOptions != nil { slirpOptions = append(slirpOptions, ctr.config.NetworkOptions["slirp4netns"]...) @@ -345,6 +350,11 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error { } } outboundAddr6 = value + case "mtu": + mtu, err = strconv.Atoi(value) + if mtu < 68 || err != nil { + return errors.Errorf("invalid mtu %q", value) + } default: return errors.Errorf("unknown option for slirp4netns: %q", o) } @@ -358,8 +368,8 @@ func (r *Runtime) setupSlirp4netns(ctr *Container) error { if disableHostLoopback && slirpFeatures.HasDisableHostLoopback { cmdArgs = append(cmdArgs, "--disable-host-loopback") } - if slirpFeatures.HasMTU { - cmdArgs = append(cmdArgs, "--mtu", "65520") + if mtu > -1 && slirpFeatures.HasMTU { + cmdArgs = append(cmdArgs, fmt.Sprintf("--mtu=%d", mtu)) } if !noPivotRoot && slirpFeatures.HasEnableSandbox { cmdArgs = append(cmdArgs, "--enable-sandbox") |