summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-02 05:53:15 -0500
committerGitHub <noreply@github.com>2021-02-02 05:53:15 -0500
commit2314af70bdacf75135a11b48b87dba8e461a43ea (patch)
treeb5083d04cb87739a1ff38295fc1fa0b4fadc90e3 /libpod
parent52575db9b40ad141dc5521d7646e8ed636651b54 (diff)
parente11d8f15e8d7559bc70ebef2dd0125be9d692da5 (diff)
downloadpodman-2314af70bdacf75135a11b48b87dba8e461a43ea.tar.gz
podman-2314af70bdacf75135a11b48b87dba8e461a43ea.tar.bz2
podman-2314af70bdacf75135a11b48b87dba8e461a43ea.zip
Merge pull request #9189 from baude/macvlandriver
add macvlan as a supported network driver
Diffstat (limited to 'libpod')
-rw-r--r--libpod/network/create.go18
-rw-r--r--libpod/network/netconflist.go6
-rw-r--r--libpod/network/network.go12
3 files changed, 27 insertions, 9 deletions
diff --git a/libpod/network/create.go b/libpod/network/create.go
index a8f985af9..88310a79c 100644
--- a/libpod/network/create.go
+++ b/libpod/network/create.go
@@ -29,7 +29,7 @@ func Create(name string, options entities.NetworkCreateOptions, runtimeConfig *c
return nil, err
}
defer l.releaseCNILock()
- if len(options.MacVLAN) > 0 {
+ if len(options.MacVLAN) > 0 || options.Driver == MacVLANNetworkDriver {
fileName, err = createMacVLAN(name, options, runtimeConfig)
} else {
fileName, err = createBridge(name, options, runtimeConfig)
@@ -256,9 +256,17 @@ func createMacVLAN(name string, options entities.NetworkCreateOptions, runtimeCo
return "", err
}
- // Make sure the host-device exists
- if !util.StringInSlice(options.MacVLAN, liveNetNames) {
- return "", errors.Errorf("failed to find network interface %q", options.MacVLAN)
+ // The parent can be defined with --macvlan or as an option (-o parent:device)
+ parentNetworkDevice := options.MacVLAN
+ if len(parentNetworkDevice) < 1 {
+ if parent, ok := options.Options["parent"]; ok {
+ parentNetworkDevice = parent
+ }
+ }
+
+ // Make sure the host-device exists if provided
+ if len(parentNetworkDevice) > 0 && !util.StringInSlice(parentNetworkDevice, liveNetNames) {
+ return "", errors.Errorf("failed to find network interface %q", parentNetworkDevice)
}
if len(name) > 0 {
netNames, err := GetNetworkNamesFromFileSystem(runtimeConfig)
@@ -275,7 +283,7 @@ func createMacVLAN(name string, options entities.NetworkCreateOptions, runtimeCo
}
}
ncList := NewNcList(name, version.Current(), options.Labels)
- macvlan := NewMacVLANPlugin(options.MacVLAN)
+ macvlan := NewMacVLANPlugin(parentNetworkDevice)
plugins = append(plugins, macvlan)
ncList["plugins"] = plugins
b, err := json.MarshalIndent(ncList, "", " ")
diff --git a/libpod/network/netconflist.go b/libpod/network/netconflist.go
index 165a9067b..ca6a4a70b 100644
--- a/libpod/network/netconflist.go
+++ b/libpod/network/netconflist.go
@@ -177,9 +177,13 @@ func NewMacVLANPlugin(device string) MacVLANConfig {
m := MacVLANConfig{
PluginType: "macvlan",
- Master: device,
IPAM: i,
}
+ // CNI is supposed to use the default route if a
+ // parent device is not provided
+ if len(device) > 0 {
+ m.Master = device
+ }
return m
}
diff --git a/libpod/network/network.go b/libpod/network/network.go
index 0fb878b18..0ff14c1f7 100644
--- a/libpod/network/network.go
+++ b/libpod/network/network.go
@@ -17,11 +17,17 @@ import (
"github.com/sirupsen/logrus"
)
-// DefaultNetworkDriver is the default network type used
-var DefaultNetworkDriver = "bridge"
+var (
+ // BridgeNetworkDriver defines the bridge cni driver
+ BridgeNetworkDriver = "bridge"
+ // DefaultNetworkDriver is the default network type used
+ DefaultNetworkDriver = BridgeNetworkDriver
+ // MacVLANNetworkDriver defines the macvlan cni driver
+ MacVLANNetworkDriver = "macvlan"
+)
// SupportedNetworkDrivers describes the list of supported drivers
-var SupportedNetworkDrivers = []string{DefaultNetworkDriver}
+var SupportedNetworkDrivers = []string{BridgeNetworkDriver, MacVLANNetworkDriver}
// isSupportedDriver checks if the user provided driver is supported
func isSupportedDriver(driver string) error {