From: Avinash Sridharan Date: Wed, 24 Aug 2016 23:49:50 +0000 (+0000) Subject: pkg/ns: fixed the check for network namespace path. X-Git-Url: https://git.halfball.org/?a=commitdiff_plain;h=7281d5792a05c537d79d35fc8e9ff7bfdb62d348;p=cni.git 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 --- diff --git a/pkg/ns/ns.go b/pkg/ns/ns.go index e29f712..5c531c0 100644 --- a/pkg/ns/ns.go +++ b/pkg/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)}