netns

package
v0.0.0-...-2feb83d Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package netns holds netns related files

Package netns holds netns related files

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoNetworkNamespaceHandle is used to indicate that we haven't resolved a handle for the requested network
	// namespace yet.
	ErrNoNetworkNamespaceHandle = fmt.Errorf("no network namespace handle")
)

Functions

This section is empty.

Types

type NetworkDeviceDump

type NetworkDeviceDump struct {
	IfName  string
	IfIndex int
}

NetworkDeviceDump is used to dump a network namespace

type NetworkNamespace

type NetworkNamespace struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

NetworkNamespace is used to hold a handle to a network namespace

func NewNetworkNamespace

func NewNetworkNamespace(nsID uint32) *NetworkNamespace

NewNetworkNamespace returns a new NetworkNamespace instance

func NewNetworkNamespaceWithPath

func NewNetworkNamespaceWithPath(nsID uint32, nsPath *utils.NetNSPath) (*NetworkNamespace, error)

NewNetworkNamespaceWithPath returns a new NetworkNamespace instance from a path.

func (*NetworkNamespace) GetNamespaceHandleDup

func (nn *NetworkNamespace) GetNamespaceHandleDup() (*os.File, error)

GetNamespaceHandleDup duplicates the network namespace handle and returns it. WARNING: it is up to the caller of this function to close the duplicated network namespace handle. Failing to close a network namespace handle may lead to leaking the network namespace.

func (*NetworkNamespace) ID

func (nn *NetworkNamespace) ID() uint32

ID returns the network namespace ID

type NetworkNamespaceDump

type NetworkNamespaceDump struct {
	NsID           uint32
	HandleFD       int
	HandlePath     string
	LonelyTimeout  time.Time
	Devices        []NetworkDeviceDump
	DevicesInQueue []NetworkDeviceDump
}

NetworkNamespaceDump is used to dump a network namespce

type Resolver

type Resolver struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Resolver is used to store namespace handles

func NewResolver

func NewResolver(config *config.Config, manager *manager.Manager, statsdClient statsd.ClientInterface, tcResolver *tc.Resolver) (*Resolver, error)

NewResolver returns a new instance of Resolver

func (*Resolver) DumpNetworkNamespaces

func (nr *Resolver) DumpNetworkNamespaces(params *api.DumpNetworkNamespaceParams) *api.DumpNetworkNamespaceMessage

DumpNetworkNamespaces dumps the network namespaces held by the namespace resolver

func (*Resolver) FlushNetworkNamespace

func (nr *Resolver) FlushNetworkNamespace(netns *NetworkNamespace)

FlushNetworkNamespace flushes the cached entries for the provided network namespace. (WARNING: you probably want to use probe.FlushNetworkNamespace instead)

func (*Resolver) GetState

func (nr *Resolver) GetState() int64

GetState returns the state of the namespace resolver

func (*Resolver) IsLazyDeletionInterface

func (nr *Resolver) IsLazyDeletionInterface(name string) bool

IsLazyDeletionInterface returns true if an interface name is in the list of interfaces that aren't explicitly deleted by the container runtime when a container is deleted.

func (*Resolver) QueueNetworkDevice

func (nr *Resolver) QueueNetworkDevice(device model.NetDevice)

QueueNetworkDevice adds the input device to the map of queued network devices. Once a handle for the network namespace of the device is resolved, a new TC classifier will automatically be added to the device. The queue is cleaned up periodically if a namespace do not own any process.

func (*Resolver) ResolveNetworkNamespace

func (nr *Resolver) ResolveNetworkNamespace(nsID uint32) *NetworkNamespace

ResolveNetworkNamespace returns a file descriptor to the network namespace. WARNING: it is up to the caller to close this file descriptor when it is done using it. Do not forget to close this file descriptor, otherwise we might exhaust the host IPs by keeping all network namespaces alive.

func (*Resolver) SaveNetworkNamespaceHandle

func (nr *Resolver) SaveNetworkNamespaceHandle(nsID uint32, nsPath *utils.NetNSPath) (*NetworkNamespace, bool)

SaveNetworkNamespaceHandle inserts the provided process network namespace in the list of tracked network. Returns true if a new entry was added.

func (*Resolver) SaveNetworkNamespaceHandleLazy

func (nr *Resolver) SaveNetworkNamespaceHandleLazy(nsID uint32, nsPathFunc func() *utils.NetNSPath) (*NetworkNamespace, bool)

SaveNetworkNamespaceHandleLazy inserts the provided process network namespace in the list of tracked network. Returns true if a new entry was added.

func (*Resolver) SendStats

func (nr *Resolver) SendStats() error

SendStats sends metrics about the current state of the namespace resolver

func (*Resolver) SetState

func (nr *Resolver) SetState(state int64)

SetState sets state of the namespace resolver

func (*Resolver) Start

func (nr *Resolver) Start(ctx context.Context) error

Start starts the namespace flush goroutine

func (*Resolver) SyncCache

func (nr *Resolver) SyncCache(pid uint32) bool

SyncCache snapshots /proc for the provided pid. This method returns true if it updated the namespace cache.

Jump to

Keyboard shortcuts

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