netns

package
v0.0.0-...-2750233 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package netns provides utility functions for network ns handling on linux platform.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCurrentIno

func GetCurrentIno() (uint32, error)

GetCurrentIno returns the ino number for the current network namespace

func GetInoForNs

func GetInoForNs(ns netns.NsHandle) (uint32, error)

GetInoForNs gets the inode number for the given network namespace

func GetNetNamespaceFromPid

func GetNetNamespaceFromPid(procRoot string, pid int) (netns.NsHandle, error)

GetNetNamespaceFromPid gets the network namespace for a given `pid`

func GetNetNamespaces

func GetNetNamespaces(procRoot string) ([]netns.NsHandle, error)

GetNetNamespaces returns a list of network namespaces on the machine. The caller is responsible for calling Close() on each of the returned NsHandle's.

func GetNetNsInoFromPid

func GetNetNsInoFromPid(procRoot string, pid int) (uint32, error)

GetNetNsInoFromPid gets the network namespace inode number for the given `pid`

func GetRootNetNamespace

func GetRootNetNamespace(procRoot string) (netns.NsHandle, error)

GetRootNetNamespace gets the root network namespace

func WithNS

func WithNS(ns netns.NsHandle, fn func() error) error

WithNS executes the given function in the given network namespace, and then switches back to the previous namespace.

func WithRootNS

func WithRootNS(procRoot string, fn func() error) error

WithRootNS executes a function within root network namespace and then switch back to the previous namespace. If the thread is already in the root network namespace, the function is executed without calling SYS_SETNS.

Types

This section is empty.

Jump to

Keyboard shortcuts

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