aboutsummaryrefslogtreecommitdiff
path: root/pkg/namespaces
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2019-03-28 17:39:56 -0400
committerMatthew Heon <mheon@redhat.com>2019-03-28 17:39:56 -0400
commitbeb263554efdb849291caf5dba4a74966564b78d (patch)
treecc701d33503fbc012cb03ef417dca916a91fac27 /pkg/namespaces
parent9085898ce2d42bf872c137e981202820066736c7 (diff)
downloadpodman-beb263554efdb849291caf5dba4a74966564b78d.tar.gz
podman-beb263554efdb849291caf5dba4a74966564b78d.tar.bz2
podman-beb263554efdb849291caf5dba4a74966564b78d.zip
Ensure that we make a netns for CNI non-default nets
We accidentally patched this out trying to enable ns:/path/to/ns This should restore the ability to configure nondefault CNI networks with Podman, by ensuring that they request creation of a network namespace. Completely remove the WithNetNS() call when we do use an explicit namespace from a path. We use that call to indicate that a netns is going to be created - there should not be any question about whether it actually does. Fixes #2795 Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg/namespaces')
-rw-r--r--pkg/namespaces/namespaces.go21
1 files changed, 20 insertions, 1 deletions
diff --git a/pkg/namespaces/namespaces.go b/pkg/namespaces/namespaces.go
index 11b47fec4..950818fc7 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()
}