From 1ce5e54e998046687f0c1056cefd720126e40e23 Mon Sep 17 00:00:00 2001 From: Avinash Sridharan Date: Wed, 24 Aug 2016 23:49:50 +0000 Subject: [PATCH] pkg/ns: fixed the check for network namespace path. The expectation on older kernels (< 3.19) was to have the network namespace always be a directory. This is not true if the network namespace is bind mounted to a file, and will make the plugin fail erroneously in such cases. The fix is to remove this assumption completely and just do a basic check on the file system types being returned. Fixes #288 --- ns/ns.go | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/ns/ns.go b/ns/ns.go index e29f712c..5c531c04 100644 --- a/ns/ns.go +++ b/ns/ns.go @@ -20,7 +20,6 @@ import ( "os" "path" "runtime" - "strings" "sync" "syscall" @@ -101,19 +100,7 @@ func IsNSorErr(nspath string) error { } switch stat.Type { - case PROCFS_MAGIC: - // Kernel < 3.19 - - validPathContent := "ns/" - validName := strings.Contains(nspath, validPathContent) - if !validName { - return NSPathNotNSErr{msg: fmt.Sprintf("path %q doesn't contain %q", nspath, validPathContent)} - } - - return nil - case NSFS_MAGIC: - // Kernel >= 3.19 - + case PROCFS_MAGIC, NSFS_MAGIC: return nil default: return NSPathNotNSErr{msg: fmt.Sprintf("unknown FS magic on %q: %x", nspath, stat.Type)}