summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-11-01 16:02:14 +0100
committerPaul Holzinger <pholzing@redhat.com>2021-11-11 16:26:47 +0100
commit1c88f741a7a15a7c8ff666c080a325ef0056af02 (patch)
treed5870e19fc3ddd8ef3839d03dd8f3f28e8101b23
parent3fe0c49174e2fba6695dcedff449ba73d15943c8 (diff)
downloadpodman-1c88f741a7a15a7c8ff666c080a325ef0056af02.tar.gz
podman-1c88f741a7a15a7c8ff666c080a325ef0056af02.tar.bz2
podman-1c88f741a7a15a7c8ff666c080a325ef0056af02.zip
select network backend based on config
You can change the network backendend in containers.conf supported values are "cni" and "netavark". Signed-off-by: Paul Holzinger <pholzing@redhat.com>
-rw-r--r--libpod/network/netavark/network.go4
-rw-r--r--libpod/runtime.go46
2 files changed, 40 insertions, 10 deletions
diff --git a/libpod/network/netavark/network.go b/libpod/network/netavark/network.go
index cd6db4f58..cc6fb423c 100644
--- a/libpod/network/netavark/network.go
+++ b/libpod/network/netavark/network.go
@@ -110,6 +110,10 @@ func NewNetworkInterface(conf InitConfig) (types.ContainerNetwork, error) {
ipamdbPath = filepath.Join(ipamdbPath, "ipam.db")
}
+ if err := os.MkdirAll(conf.NetworkConfigDir, 0755); err != nil {
+ return nil, err
+ }
+
n := &netavarkNetwork{
networkConfigDir: conf.NetworkConfigDir,
netavarkBinary: conf.NetavarkBinary,
diff --git a/libpod/runtime.go b/libpod/runtime.go
index b01f8dd13..71bfaff9a 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -28,6 +28,7 @@ import (
"github.com/containers/podman/v3/libpod/events"
"github.com/containers/podman/v3/libpod/lock"
"github.com/containers/podman/v3/libpod/network/cni"
+ "github.com/containers/podman/v3/libpod/network/netavark"
nettypes "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/libpod/plugin"
"github.com/containers/podman/v3/libpod/shutdown"
@@ -483,16 +484,41 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
}
}
- netInterface, err := cni.NewCNINetworkInterface(cni.InitConfig{
- CNIConfigDir: runtime.config.Network.NetworkConfigDir,
- CNIPluginDirs: runtime.config.Network.CNIPluginDirs,
- DefaultNetwork: runtime.config.Network.DefaultNetwork,
- DefaultSubnet: runtime.config.Network.DefaultSubnet,
- IsMachine: runtime.config.Engine.MachineEnabled,
- LockFile: filepath.Join(runtime.config.Network.NetworkConfigDir, "cni.lock"),
- })
- if err != nil {
- return errors.Wrapf(err, "could not create network interface")
+ var netInterface nettypes.ContainerNetwork
+
+ switch runtime.config.Network.NetworkBackend {
+ case "", "cni":
+ netInterface, err = cni.NewCNINetworkInterface(cni.InitConfig{
+ CNIConfigDir: runtime.config.Network.NetworkConfigDir,
+ CNIPluginDirs: runtime.config.Network.CNIPluginDirs,
+ DefaultNetwork: runtime.config.Network.DefaultNetwork,
+ DefaultSubnet: runtime.config.Network.DefaultSubnet,
+ IsMachine: runtime.config.Engine.MachineEnabled,
+ LockFile: filepath.Join(runtime.config.Network.NetworkConfigDir, "cni.lock"),
+ })
+ if err != nil {
+ return errors.Wrapf(err, "could not create network interface")
+ }
+
+ case "netavark":
+ netavarkBin, err := runtime.config.FindHelperBinary("netavark", false)
+ if err != nil {
+ return err
+ }
+
+ netInterface, err = netavark.NewNetworkInterface(netavark.InitConfig{
+ NetavarkBinary: netavarkBin,
+ NetworkConfigDir: filepath.Join(runtime.config.Engine.StaticDir, "networks"),
+ DefaultNetwork: runtime.config.Network.DefaultNetwork,
+ DefaultSubnet: runtime.config.Network.DefaultSubnet,
+ IsMachine: runtime.config.Engine.MachineEnabled,
+ LockFile: filepath.Join(runtime.config.Network.NetworkConfigDir, "netavark.lock"),
+ })
+ if err != nil {
+ return errors.Wrapf(err, "could not create network interface")
+ }
+ default:
+ return errors.Errorf("unsupported network backend %q, check network_backend in containers.conf", runtime.config.Network.NetworkBackend)
}
runtime.network = netInterface