summaryrefslogtreecommitdiff
path: root/libpod/network/create.go
diff options
context:
space:
mode:
authorAnders F Björklund <anders.f.bjorklund@gmail.com>2020-11-23 22:04:06 +0100
committerAnders F Björklund <anders.f.bjorklund@gmail.com>2020-12-01 22:33:03 +0100
commitb1b35707aae57d299933f029eb0adc0a9000f97f (patch)
tree52c70c05c8cd7374d344d289a35323a8587cce88 /libpod/network/create.go
parentc71ad9a557ee80eccde2608939c81906379fa7ae (diff)
downloadpodman-b1b35707aae57d299933f029eb0adc0a9000f97f.tar.gz
podman-b1b35707aae57d299933f029eb0adc0a9000f97f.tar.bz2
podman-b1b35707aae57d299933f029eb0adc0a9000f97f.zip
Add podman network create option for bridge mtu
Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Diffstat (limited to 'libpod/network/create.go')
-rw-r--r--libpod/network/create.go23
1 files changed, 22 insertions, 1 deletions
diff --git a/libpod/network/create.go b/libpod/network/create.go
index cac438963..50337013d 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -6,6 +6,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
+ "strconv"
"github.com/containernetworking/cni/pkg/version"
"github.com/containers/common/pkg/config"
@@ -76,6 +77,21 @@ func validateBridgeOptions(options entities.NetworkCreateOptions) error {
}
+// parseMTU parses the mtu option
+func parseMTU(mtu string) (int, error) {
+ if mtu == "" {
+ return 0, nil // default
+ }
+ m, err := strconv.Atoi(mtu)
+ if err != nil {
+ return 0, err
+ }
+ if m < 0 {
+ return 0, errors.Errorf("the value %d for mtu is less than zero", m)
+ }
+ return m, nil
+}
+
// createBridge creates a CNI network
func createBridge(name string, options entities.NetworkCreateOptions, runtimeConfig *config.Config) (string, error) {
var (
@@ -149,6 +165,11 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
ipMasq = false
}
+ mtu, err := parseMTU(options.Options["mtu"])
+ if err != nil {
+ return "", err
+ }
+
// obtain host bridge name
bridgeDeviceName, err := GetFreeDeviceName(runtimeConfig)
if err != nil {
@@ -172,7 +193,7 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
ncList := NewNcList(name, version.Current(), options.Labels)
var plugins []CNIPlugins
// TODO need to iron out the role of isDefaultGW and IPMasq
- bridge := NewHostLocalBridge(bridgeDeviceName, isGateway, false, ipMasq, ipamConfig)
+ bridge := NewHostLocalBridge(bridgeDeviceName, isGateway, false, ipMasq, mtu, ipamConfig)
plugins = append(plugins, bridge)
plugins = append(plugins, NewPortMapPlugin())
plugins = append(plugins, NewFirewallPlugin())