From 8ade76e79b78bffd6eb055db35de0b3ad4475804 Mon Sep 17 00:00:00 2001 From: Doug Rabson Date: Fri, 26 Aug 2022 15:26:57 +0100 Subject: libpod: Move networkDisable to container_linux.go This moves platform-specific details of the network implementation out of the generic file so that we can add the FreeBSD equivalent. [NO NEW TESTS NEEDED] Signed-off-by: Doug Rabson --- libpod/container_linux.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'libpod/container_linux.go') diff --git a/libpod/container_linux.go b/libpod/container_linux.go index 8b517e69f..9c17a1966 100644 --- a/libpod/container_linux.go +++ b/libpod/container_linux.go @@ -5,6 +5,7 @@ package libpod import ( "github.com/containernetworking/plugins/pkg/ns" + spec "github.com/opencontainers/runtime-spec/specs-go" ) type containerPlatformState struct { @@ -13,3 +14,17 @@ type containerPlatformState struct { // told to join another container's network namespace NetNS ns.NetNS `json:"-"` } + +func networkDisabled(c *Container) (bool, error) { + if c.config.CreateNetNS { + return false, nil + } + if !c.config.PostConfigureNetNS { + for _, ns := range c.config.Spec.Linux.Namespaces { + if ns.Type == spec.NetworkNamespace { + return ns.Path == "", nil + } + } + } + return false, nil +} -- cgit v1.2.3-54-g00ecf