netns

package
v0.8.10 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const Loopback = "lo"

Variables

This section is empty.

Functions

func NewLinkPair added in v0.6.0

func NewLinkPair() (netlink.Link, netlink.Link, error)

Types

type Builder

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

func NewNetNSBuilder

func NewNetNSBuilder() *Builder

func (*Builder) Build

func (b *Builder) Build() (*NetNS, error)

func (*Builder) WithBeforeExecFuncs

func (b *Builder) WithBeforeExecFuncs(fns ...func() error) *Builder

func (*Builder) WithIPv6

func (b *Builder) WithIPv6(value bool) *Builder

func (*Builder) WithNameSeed

func (b *Builder) WithNameSeed(seed string) *Builder
func (b *Builder) WithSharedLink(link netlink.Link, linkAddress *netlink.Addr) *Builder

type NetNS

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

func (*NetNS) Cleanup

func (ns *NetNS) Cleanup() error

func (*NetNS) Name

func (ns *NetNS) Name() string

func (*NetNS) Set

func (ns *NetNS) Set() error

func (*NetNS) SharedLinkAddress added in v0.6.0

func (ns *NetNS) SharedLinkAddress() *netlink.Addr

func (*NetNS) UnsafeExec

func (ns *NetNS) UnsafeExec(callback func(), beforeCallbackFuncs ...func() error) <-chan error

UnsafeExec will execute provided callback function in the created network namespace from the *NetNS. It was named UnsafeExec instead of Exec as you have to be very cautious and remember to not spawn new goroutines inside provided callback (more info in warning below)

WARNING!:

Don't spawn new goroutines inside callback functions as the one inside UnsafeExec
function have exclusive access to the current network namespace, and you should
assume, that any new goroutine will be placed in the different namespace

func (*NetNS) UnsafeExecInLoop

func (ns *NetNS) UnsafeExecInLoop(
	numOfIterations uint,
	delay time.Duration,
	callback func(),
	beforeCallbackFuncs ...func() error,
) <-chan error

UnsafeExecInLoop will execute provided callback function inside the created network namespace in a loop. It was named UnsafeExecInLoop instead of ExecInLoop as you have to be very cautious and remember to not spawn new goroutines inside provided callback (more info in warning below)

WARNING!:

Don't spawn new goroutines inside callback functions as the one inside UnsafeExecInLoop
function have exclusive access to the current network namespace, and you should
assume, that any new goroutine will be placed in the different namespace

func (*NetNS) Unset

func (ns *NetNS) Unset() error

func (*NetNS) Veth

func (ns *NetNS) Veth() *Veth

type Veth

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

func (*Veth) Address

func (v *Veth) Address() net.IP

func (*Veth) AddressCIDR

func (v *Veth) AddressCIDR() *net.IPNet

func (*Veth) Name

func (v *Veth) Name() string

func (*Veth) PeerAddress

func (v *Veth) PeerAddress() net.IP

func (*Veth) PeerAddressCIDR

func (v *Veth) PeerAddressCIDR() *net.IPNet

func (*Veth) PeerName

func (v *Veth) PeerName() string

func (*Veth) Veth

func (v *Veth) Veth() *netlink.Veth

Jump to

Keyboard shortcuts

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