helpers

package
v0.0.0-...-8b8e587 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeVeth      = "veth"
	TypeNetwork   = "network"
	NetNSLocation = "/run/netns"
)

Variables

This section is empty.

Functions

func ExtractInterfaceNamespace

func ExtractInterfaceNamespace(interfaces []*types100.Interface, interfaceName string) (string, error)

ExtractInterfaceNamespace takes an interface name inside the namespace, e.g. "eth0", and searches the list of provided interfaces for that interface name. On success, it returns the name of the namespace of that interface (the content of the Sandbox field).

func ExtractVeth

func ExtractVeth(interfaces []*types100.Interface, netnsID, peerInterfaceIndex int) (string, error)

ExtractVeth iterates over the list of provided interfaces. For each interface, it checks: * That the interface is in the global namespace. * That the ParentIndex (peer index) of the interface equals the peerInterfaceIndex that we are looking for. * That the NetNsID equals the provided netnsID. If these conditions are met, it will return the name of the matching interface.

func FindExecutable

func FindExecutable(name string) ([]string, error)

FindExecutable checks if an executable exists inside the container. If so, it returns that path. Otherwise, it also checks on /host.

func FindNetNSID

func FindNetNSID(netnsPath string) (int, error)

FindNetNSID expects a path to a netns and will return the ID of the corresponding netns.

func GetInterfaceIndex

func GetInterfaceIndex(interfaceName string) (int, error)

GetInterfaceIndex will return the interface index for the provided interface name.

func GetNetNSLocation

func GetNetNSLocation() string

func RunCommand

func RunCommand(c string, parameters ...string) ([]byte, error)

RunCommand runs 'c parameters[0] parameters[1] ...'.'

Types

This section is empty.

Jump to

Keyboard shortcuts

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