netns

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unmount added in v0.2.0

func Unmount(target string, flags int) error

Unmount the provided mount path with the flags

Types

type NetNS

type NetNS struct {
	// contains filtered or unexported fields
}

NetNS holds network namespace.

func LoadNetNS

func LoadNetNS(path string) *NetNS

LoadNetNS loads existing network namespace.

func NewNetNS

func NewNetNS(baseDir, name string) (*NetNS, error)

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/<generated-name>".

func NewNetNSFromPID

func NewNetNSFromPID(baseDir, name string, pid uint32) (*NetNS, error)

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/<generated-name>".

func (*NetNS) Closed

func (n *NetNS) Closed() (bool, error)

Closed checks whether the network namespace has been closed.

func (*NetNS) Do

func (n *NetNS) Do(f func(cnins.NetNS) error) error

Do runs a function in the network namespace.

func (*NetNS) GetPath

func (n *NetNS) GetPath() string

GetPath returns network namespace path for sandbox container

func (*NetNS) Remove

func (n *NetNS) Remove() error

Remove removes network namespace. Remove is idempotent, meaning it might be invoked multiple times and provides consistent result.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL