From dcb2e7447b9f193f2393cbdbe630b1ca8ca3c6b3 Mon Sep 17 00:00:00 2001 From: Henry Wang Date: Wed, 20 Sep 2023 17:00:33 +0000 Subject: [PATCH] Improve doc of func NewNetNS Signed-off-by: Henry Wang --- pkg/netns/netns_linux.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/netns/netns_linux.go b/pkg/netns/netns_linux.go index 67449ddd5..f72433bd7 100644 --- a/pkg/netns/netns_linux.go +++ b/pkg/netns/netns_linux.go @@ -177,11 +177,17 @@ type NetNS struct { } // NewNetNS creates a network namespace. +// The name of the network namespace is randomly generated. +// The returned netns is created under baseDir, with its path +// following the pattern "baseDir/". func NewNetNS(baseDir string) (*NetNS, error) { return NewNetNSFromPID(baseDir, 0) } -// NewNetNS returns the netns from pid or a new netns if pid is 0. +// NewNetNSFromPID returns the netns from pid or a new netns if pid is 0. +// The name of the network namespace is randomly generated. +// The returned netns is created under baseDir, with its path +// following the pattern "baseDir/". func NewNetNSFromPID(baseDir string, pid uint32) (*NetNS, error) { path, err := newNS(baseDir, pid) if err != nil {