From a535016f97b3d86b774a4529f7db3ed568f052d5 Mon Sep 17 00:00:00 2001 From: ROKUMATE Date: Thu, 25 Jun 2026 03:21:38 +0530 Subject: [PATCH] pkg/namespaces: fix NetworkMode IsNS and IsUserDefined NetworkMode.IsNS matched any value starting with "ns" (e.g. a network named "nsproxy"), unlike UsernsMode.IsNS which requires the "ns:" prefix; require it. IsUserDefined also did not exclude pod, so a pod network was reported as user-defined; exclude it. Signed-off-by: ROKUMATE --- pkg/namespaces/namespaces.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/namespaces/namespaces.go b/pkg/namespaces/namespaces.go index 8407218e68..07878defbc 100644 --- a/pkg/namespaces/namespaces.go +++ b/pkg/namespaces/namespaces.go @@ -208,7 +208,7 @@ func (n NetworkMode) IsPasta() bool { // IsNS indicates a network namespace passed in by path (ns:) func (n NetworkMode) IsNS() bool { - return strings.HasPrefix(string(n), nsType) + return strings.HasPrefix(string(n), nsType+":") } // NS gets the path associated with a ns: network ns @@ -224,5 +224,5 @@ func (n NetworkMode) IsPod() bool { // IsUserDefined indicates user-created network func (n NetworkMode) IsUserDefined() bool { - return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() && !n.IsPasta() && !n.IsNS() + return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer() && !n.IsPasta() && !n.IsNS() && !n.IsPod() }