diff options
author | Doug Rabson <dfr@rabson.org> | 2022-08-26 15:26:57 +0100 |
---|---|---|
committer | Doug Rabson <dfr@rabson.org> | 2022-09-05 10:12:12 +0100 |
commit | 8ade76e79b78bffd6eb055db35de0b3ad4475804 (patch) | |
tree | 6cd23a5638dbaa34795316a71e0db7e686e53810 /libpod | |
parent | 098c0714e5c2c461c175753eef3dc9d900699be5 (diff) | |
download | podman-8ade76e79b78bffd6eb055db35de0b3ad4475804.tar.gz podman-8ade76e79b78bffd6eb055db35de0b3ad4475804.tar.bz2 podman-8ade76e79b78bffd6eb055db35de0b3ad4475804.zip |
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 <dfr@rabson.org>
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 14 | ||||
-rw-r--r-- | libpod/container_freebsd.go | 10 | ||||
-rw-r--r-- | libpod/container_linux.go | 15 |
3 files changed, 25 insertions, 14 deletions
diff --git a/libpod/container.go b/libpod/container.go index 44a8669fd..1891b124f 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -1133,20 +1133,6 @@ func (c *Container) NetworkDisabled() (bool, error) { return networkDisabled(c) } -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 -} - func (c *Container) HostNetwork() bool { if c.config.CreateNetNS || c.config.NetNsCtr != "" { return false diff --git a/libpod/container_freebsd.go b/libpod/container_freebsd.go index f9fbc4daa..7292ba37a 100644 --- a/libpod/container_freebsd.go +++ b/libpod/container_freebsd.go @@ -10,3 +10,13 @@ type containerPlatformState struct { // namespace. NetworkJail string `json:"-"` } + +func networkDisabled(c *Container) (bool, error) { + if c.config.CreateNetNS { + return false, nil + } + if !c.config.PostConfigureNetNS { + return c.state.NetworkJail == "", nil + } + return false, nil +} 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 +} |