Documentation ¶
Overview ¶
Package netns contains various utility functions to work with network namespaces
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNetNSCookie ¶
GetNetNSCookie tries to retrieve the cookie of the host netns.
Types ¶
type NetNS ¶ added in v1.16.0
type NetNS struct {
// contains filtered or unexported fields
}
func Current ¶ added in v1.16.0
Current returns a handle to the network namespace of the calling goroutine's underlying OS thread.
func New ¶ added in v1.16.0
New creates a network namespace and returns a handle to it.
The namespace created by this call is not pinned and will be closed when the last process in the namespace terminates, or when the handle is either Close()d explicitly or garbage collected.
Not calling Close() is an error.
func OpenPinned ¶ added in v1.16.0
OpenPinned opens a handle to the existing, pinned network namespace at the given path. Useful for running code within a netns managed by another process that pinned a network namespace to an nsfs.
Not calling Close() is an error.
func (*NetNS) Close ¶ added in v1.16.0
Close closes the handle to the network namespace. This does not necessarily mean destroying the network namespace itself, which only happens when all references to it are gone and all of its processes have been terminated.
func (*NetNS) Do ¶ added in v1.16.0
Do runs the provided func in the netns without changing the calling thread's netns.
The code in f and any code called by f must NOT call runtime.LockOSThread, as this could leave the goroutine created by Do permanently pinned to an OS thread.