Documentation ¶
Overview ¶
Package linuxcalls contains wrappers over Netlink APIs related to Linux VETH interfaces or to Linux interfaces in general.
Index ¶
- func AddInterfaceIP(ifName string, addr *net.IPNet) error
- func AddVethInterface(ifName, peerIfName string) error
- func CompareNamespaces(ns1 *intf.LinuxInterfaces_Interface_Namespace, ...) int
- func CreateNamedNetNs(namespace string) (netns.NsHandle, error)
- func DelInterfaceIP(ifName string, addr *net.IPNet) error
- func DelVethInterface(ifName, peerIfName string) error
- func DeleteNamedNetNs(namespace string) error
- func GetDefaultNamespace() *intf.LinuxInterfaces_Interface_Namespace
- func GetInterfaceType(ifName string) (string, error)
- func GetOrCreateNs(namespace *intf.LinuxInterfaces_Interface_Namespace) (netns.NsHandle, error)
- func GetVethPeerName(ifName string) (string, error)
- func InterfaceAdminDown(ifName string) error
- func InterfaceAdminUp(ifName string) error
- func InterfaceExists(ifName string) (bool, error)
- func NamespaceToStr(namespace *intf.LinuxInterfaces_Interface_Namespace) string
- func SetInterfaceMTU(ifName string, mtu int) error
- func SetInterfaceMac(ifName string, macAddress string) error
- func SetInterfaceNamespace(ctx *NamespaceMgmtCtx, ifName string, ...) error
- func SwitchNamespace(ctx *NamespaceMgmtCtx, namespace *intf.LinuxInterfaces_Interface_Namespace) (revert func(), err error)
- type NamespaceMgmtCtx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddInterfaceIP ¶
AddInterfaceIP calls AddrAdd Netlink API
func AddVethInterface ¶
AddVethInterface calls LinkAdd Netlink API for the Netlink.Veth interface type.
func CompareNamespaces ¶
func CompareNamespaces(ns1 *intf.LinuxInterfaces_Interface_Namespace, ns2 *intf.LinuxInterfaces_Interface_Namespace) int
CompareNamespaces is a comparison function for "intf.Interfaces_Interface_Namespace" type.
func CreateNamedNetNs ¶
CreateNamedNetNs creates a new named Linux network namespace. It does exactly the same thing as the command "ip netns add NAMESPACE" .
func DelInterfaceIP ¶
DelInterfaceIP calls AddrDel Netlink API
func DelVethInterface ¶
DelVethInterface calls LinkDel Netlink API for the Netlink.Veth interface type.
func DeleteNamedNetNs ¶
DeleteNamedNetNs deletes an existing named Linux network namespace. It does exactly the same thing as the command "ip netns del NAMESPACE" .
func GetDefaultNamespace ¶
func GetDefaultNamespace() *intf.LinuxInterfaces_Interface_Namespace
GetDefaultNamespace returns an instance of the proto message referencing default namespace.
func GetInterfaceType ¶
GetInterfaceType returns the type (string representation) of a given interface.
func GetOrCreateNs ¶
func GetOrCreateNs(namespace *intf.LinuxInterfaces_Interface_Namespace) (netns.NsHandle, error)
GetOrCreateNs returns an existing Linux network namespace or creates a new one if it doesn't exist yet. It is, however, only possible to create "named" namespaces. For PID-based namespaces, process with the given PID must exists, otherwise the function returns an error.
func GetVethPeerName ¶
GetVethPeerName return the peer name for a given VETH interface.
func InterfaceAdminDown ¶
InterfaceAdminDown calls Netlink API LinkSetDown
func InterfaceAdminUp ¶
InterfaceAdminUp calls Netlink API LinkSetUp
func InterfaceExists ¶
InterfaceExists checks if interface with a given name exists.
func NamespaceToStr ¶
func NamespaceToStr(namespace *intf.LinuxInterfaces_Interface_Namespace) string
NamespaceToStr returns a string representation of a namespace suitable for logging purposes.
func SetInterfaceMTU ¶
SetInterfaceMTU calls LinkSetMTU Netlink API
func SetInterfaceMac ¶
SetInterfaceMac calls LinkSetHardwareAddr netlink API
func SetInterfaceNamespace ¶
func SetInterfaceNamespace(ctx *NamespaceMgmtCtx, ifName string, namespace *intf.LinuxInterfaces_Interface_Namespace) error
SetInterfaceNamespace moves a given Linux interface into a specified namespace.
func SwitchNamespace ¶
func SwitchNamespace(ctx *NamespaceMgmtCtx, namespace *intf.LinuxInterfaces_Interface_Namespace) (revert func(), err error)
SwitchNamespace switches the network namespace of the current thread. Caller should eventually call the returned "revert" function in order to get back to the original network namespace (for example using "defer revert()").
Types ¶
type NamespaceMgmtCtx ¶
type NamespaceMgmtCtx struct {
// contains filtered or unexported fields
}
NamespaceMgmtCtx represents context of an ongoing management of Linux namespaces. The same context should not be used concurrently.
func NewNamespaceMgmtCtx ¶
func NewNamespaceMgmtCtx() *NamespaceMgmtCtx
NewNamespaceMgmtCtx creates and returns a new context for management of Linux namespaces.