mirror of https://github.com/containers/podman.git
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>
This commit is contained in:
parent
098c0714e5
commit
8ade76e79b
|
@ -1133,20 +1133,6 @@ func (c *Container) NetworkDisabled() (bool, error) {
|
||||||
return networkDisabled(c)
|
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 {
|
func (c *Container) HostNetwork() bool {
|
||||||
if c.config.CreateNetNS || c.config.NetNsCtr != "" {
|
if c.config.CreateNetNS || c.config.NetNsCtr != "" {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -10,3 +10,13 @@ type containerPlatformState struct {
|
||||||
// namespace.
|
// namespace.
|
||||||
NetworkJail string `json:"-"`
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ package libpod
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/containernetworking/plugins/pkg/ns"
|
"github.com/containernetworking/plugins/pkg/ns"
|
||||||
|
spec "github.com/opencontainers/runtime-spec/specs-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
type containerPlatformState struct {
|
type containerPlatformState struct {
|
||||||
|
@ -13,3 +14,17 @@ type containerPlatformState struct {
|
||||||
// told to join another container's network namespace
|
// told to join another container's network namespace
|
||||||
NetNS ns.NetNS `json:"-"`
|
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
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue