aboutsummaryrefslogtreecommitdiff
path: root/libpod/container_linux.go
blob: 9c17a1966ee2d4cae4ae1b0d4dca0d4f77352acc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//go:build linux
// +build linux

package libpod

import (
	"github.com/containernetworking/plugins/pkg/ns"
	spec "github.com/opencontainers/runtime-spec/specs-go"
)

type containerPlatformState struct {
	// NetNSPath is the path of the container's network namespace
	// Will only be set if config.CreateNetNS is true, or the container was
	// 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
}