diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-29 04:26:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-29 04:26:30 -0700 |
commit | 6ab27c6355a4df228ed6d527162d5251d867b9b3 (patch) | |
tree | 98aff18fca2369cd87219aef0d18db872a67047d /pkg/namespaces/namespaces.go | |
parent | fdf979a7917a497322b23354778bd32bbd9b05f5 (diff) | |
parent | e25924f31c8e9e53490f02073ba69d41e3470712 (diff) | |
download | podman-6ab27c6355a4df228ed6d527162d5251d867b9b3.tar.gz podman-6ab27c6355a4df228ed6d527162d5251d867b9b3.tar.bz2 podman-6ab27c6355a4df228ed6d527162d5251d867b9b3.zip |
Merge pull request #2796 from mheon/fix_cni_multinetwork
Ensure that we make a netns for CNI non-default nets
Diffstat (limited to 'pkg/namespaces/namespaces.go')
-rw-r--r-- | pkg/namespaces/namespaces.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/pkg/namespaces/namespaces.go b/pkg/namespaces/namespaces.go index 11b47fec4..fde6118af 100644 --- a/pkg/namespaces/namespaces.go +++ b/pkg/namespaces/namespaces.go @@ -228,7 +228,26 @@ func (n NetworkMode) IsSlirp4netns() bool { return n == "slirp4netns" } +// IsNS indicates a network namespace passed in by path (ns:<path>) +func (n NetworkMode) IsNS() bool { + return strings.HasPrefix(string(n), "ns:") +} + +// NS gets the path associated with a ns:<path> network ns +func (n NetworkMode) NS() string { + parts := strings.SplitN(string(n), ":", 2) + if len(parts) > 1 { + return parts[1] + } + return "" +} + +// IsPod returns whether the network refers to pod networking +func (n NetworkMode) IsPod() bool { + return n == "pod" +} + // IsUserDefined indicates user-created network func (n NetworkMode) IsUserDefined() bool { - return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() && !n.IsSlirp4netns() + return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() && !n.IsSlirp4netns() && !n.IsNS() } |