aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go49
1 files changed, 7 insertions, 42 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 90cd8ffe0..077fce999 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -19,6 +19,8 @@ import (
"github.com/containers/buildah/pkg/parse"
"github.com/containers/common/libimage"
+ "github.com/containers/common/libnetwork/network"
+ nettypes "github.com/containers/common/libnetwork/types"
"github.com/containers/common/pkg/cgroups"
"github.com/containers/common/pkg/config"
"github.com/containers/common/pkg/secrets"
@@ -28,9 +30,6 @@ import (
"github.com/containers/podman/v3/libpod/define"
"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"
"github.com/containers/podman/v3/pkg/rootless"
@@ -490,50 +489,16 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (retErr error) {
}
}
- 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")
- }
- if runtime.config.Network.NetworkBackend == "" {
- // set backend to cni so that podman info can display it
- runtime.config.Network.NetworkBackend = "cni"
- }
-
- case "netavark":
- netavarkBin, err := runtime.config.FindHelperBinary("netavark", false)
+ // the store is only setup when we are in the userns so we do the same for the network interface
+ if !needsUserns {
+ netBackend, netInterface, err := network.NetworkBackend(runtime.store, runtime.config, runtime.syslog)
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"),
- Syslog: runtime.syslog,
- })
- 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.config.Network.NetworkBackend = string(netBackend)
+ runtime.network = netInterface
}
- runtime.network = netInterface
-
// We now need to see if the system has restarted
// We check for the presence of a file in our tmp directory to verify this
// This check must be locked to prevent races