summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorbitstrings <pino.silvaggio@gmail.com>2021-01-29 23:37:14 -0500
committerMatthew Heon <matthew.heon@pm.me>2021-02-04 14:19:00 -0500
commit6d9217228b87e5ea5b0e215701d8e001c44e1917 (patch)
tree3f707badef40577d69bfb9ffc7210f920ebea573 /libpod
parent3b712d96157b718e76ea7fe5b5bb91a5ddd9f2a4 (diff)
downloadpodman-6d9217228b87e5ea5b0e215701d8e001c44e1917.tar.gz
podman-6d9217228b87e5ea5b0e215701d8e001c44e1917.tar.bz2
podman-6d9217228b87e5ea5b0e215701d8e001c44e1917.zip
Make slirp MTU configurable (network_cmd_options)
The mtu default value is currently forced to 65520. This let the user control it using the config key network_cmd_options, i.e.: network_cmd_options=["mtu=9000"] Signed-off-by: bitstrings <pino.silvaggio@gmail.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/networking_linux.go14
1 files changed, 12 insertions, 2 deletions
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index ffd39dfa9..2eabec634 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")