summaryrefslogtreecommitdiff
path: root/libpod/network/create.go
diff options
context:
space:
mode:
authorAnders F Björklund <anders.f.bjorklund@gmail.com>2020-11-26 17:38:38 +0100
committerAnders F Björklund <anders.f.bjorklund@gmail.com>2020-12-01 22:33:16 +0100
commit7f1be76b5c388efe34cb658fb8eebb2bcec2a004 (patch)
treebdee234db45a815650b2f5ef8d2d849b1e23dca5 /libpod/network/create.go
parentb1b35707aae57d299933f029eb0adc0a9000f97f (diff)
downloadpodman-7f1be76b5c388efe34cb658fb8eebb2bcec2a004.tar.gz
podman-7f1be76b5c388efe34cb658fb8eebb2bcec2a004.tar.bz2
podman-7f1be76b5c388efe34cb658fb8eebb2bcec2a004.zip
Add podman network create option for bridge vlan
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.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/libpod/network/create.go b/libpod/network/create.go
index 50337013d..e9ab93262 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -92,6 +92,14 @@ func parseMTU(mtu string) (int, error) {
return m, nil
}
+// parseVlan parses the vlan option
+func parseVlan(vlan string) (int, error) {
+ if vlan == "" {
+ return 0, nil // default
+ }
+ return strconv.Atoi(vlan)
+}
+
// createBridge creates a CNI network
func createBridge(name string, options entities.NetworkCreateOptions, runtimeConfig *config.Config) (string, error) {
var (
@@ -170,6 +178,11 @@ func createBridge(name string, options entities.NetworkCreateOptions, runtimeCon
return "", err
}
+ vlan, err := parseVlan(options.Options["vlan"])
+ if err != nil {
+ return "", err
+ }
+
// obtain host bridge name
bridgeDeviceName, err := GetFreeDeviceName(runtimeConfig)
if err != nil {
@@ -193,7 +206,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, mtu, ipamConfig)
+ bridge := NewHostLocalBridge(bridgeDeviceName, isGateway, false, ipMasq, mtu, vlan, ipamConfig)
plugins = append(plugins, bridge)
plugins = append(plugins, NewPortMapPlugin())
plugins = append(plugins, NewFirewallPlugin())