linuxcalls

package
v2.0.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package linuxcalls contains wrappers over Netlink APIs related to Linux VETH interfaces or Linux interfaces in general.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetLinkHandler added in v1.8.1

type NetLinkHandler struct {
}

NetLinkHandler is accessor for Netlink methods.

func NewNetLinkHandler

func NewNetLinkHandler() *NetLinkHandler

NewNetLinkHandler creates new instance of Netlink handler.

func (*NetLinkHandler) AddInterfaceIP added in v1.8.1

func (h *NetLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error

AddInterfaceIP calls AddrAdd Netlink API.

func (*NetLinkHandler) AddVethInterfacePair added in v1.8.1

func (h *NetLinkHandler) AddVethInterfacePair(ifName, peerIfName string) error

AddVethInterfacePair calls LinkAdd Netlink API for the Netlink.Veth interface type.

func (*NetLinkHandler) DelInterfaceIP added in v1.8.1

func (h *NetLinkHandler) DelInterfaceIP(ifName string, addr *net.IPNet) error

DelInterfaceIP calls AddrDel Netlink API.

func (*NetLinkHandler) DeleteInterface

func (h *NetLinkHandler) DeleteInterface(ifName string) error

DeleteInterface removes the given interface.

func (*NetLinkHandler) GetAddressList added in v1.8.1

func (h *NetLinkHandler) GetAddressList(ifName string) ([]netlink.Addr, error)

GetAddressList calls AddrList netlink API

func (*NetLinkHandler) GetChecksumOffloading

func (h *NetLinkHandler) GetChecksumOffloading(ifName string) (rxOn, txOn bool, err error)

GetChecksumOffloading returns the state of Rx/Tx checksum offloading for the given interface.

func (*NetLinkHandler) GetInterfaceType added in v1.8.1

func (h *NetLinkHandler) GetInterfaceType(ifName string) (string, error)

GetInterfaceType returns the type (string representation) of a given interface.

func (*NetLinkHandler) GetLinkByName added in v1.8.1

func (h *NetLinkHandler) GetLinkByName(ifName string) (netlink.Link, error)

GetLinkByName calls netlink API to get Link type from interface name

func (h *NetLinkHandler) GetLinkList() ([]netlink.Link, error)

GetLinkList calls netlink API to get all Links in namespace

func (*NetLinkHandler) InterfaceExists added in v1.8.1

func (h *NetLinkHandler) InterfaceExists(ifName string) (bool, error)

InterfaceExists checks if interface with a given name exists.

func (*NetLinkHandler) IsInterfaceUp

func (h *NetLinkHandler) IsInterfaceUp(ifName string) (bool, error)

IsInterfaceUp checks if the interface is UP.

func (*NetLinkHandler) LinkSubscribe

func (h *NetLinkHandler) LinkSubscribe(ch chan<- netlink.LinkUpdate, done <-chan struct{}) error

LinkSubscribe takes a channel to which notifications will be sent when links change. Close the 'done' chan to stop subscription.

func (*NetLinkHandler) RenameInterface added in v1.8.1

func (h *NetLinkHandler) RenameInterface(ifName string, newName string) error

RenameInterface changes the name of the interface <ifName> to <newName>.

func (*NetLinkHandler) SetChecksumOffloading

func (h *NetLinkHandler) SetChecksumOffloading(ifName string, rxOn, txOn bool) error

SetChecksumOffloading enables/disables Rx/Tx checksum offloading for the given interface.

func (*NetLinkHandler) SetInterfaceAlias

func (h *NetLinkHandler) SetInterfaceAlias(ifName, alias string) error

SetInterfaceAlias sets the alias of the given interface. Equivalent to: `ip link set dev $ifName alias $alias`

func (*NetLinkHandler) SetInterfaceDown added in v1.8.1

func (h *NetLinkHandler) SetInterfaceDown(ifName string) error

SetInterfaceDown calls Netlink API LinkSetDown.

func (*NetLinkHandler) SetInterfaceMTU added in v1.8.1

func (h *NetLinkHandler) SetInterfaceMTU(ifName string, mtu int) error

SetInterfaceMTU calls LinkSetMTU Netlink API.

func (*NetLinkHandler) SetInterfaceMac added in v1.8.1

func (h *NetLinkHandler) SetInterfaceMac(ifName string, macAddress string) error

SetInterfaceMac calls LinkSetHardwareAddr netlink API.

func (*NetLinkHandler) SetInterfaceUp added in v1.8.1

func (h *NetLinkHandler) SetInterfaceUp(ifName string) error

SetInterfaceUp calls Netlink API LinkSetUp.

func (*NetLinkHandler) SetLinkNamespace

func (h *NetLinkHandler) SetLinkNamespace(link netlink.Link, ns netns.NsHandle) (err error)

SetLinkNamespace puts link into a network namespace.

type NetlinkAPI

type NetlinkAPI interface {
	NetlinkAPIWrite
	NetlinkAPIRead
}

NetlinkAPI interface covers all methods inside linux calls package needed to manage linux interfaces.

type NetlinkAPIRead added in v1.8.1

type NetlinkAPIRead interface {
	// GetLinkByName returns netlink interface type
	GetLinkByName(ifName string) (netlink.Link, error)
	// GetLinkList return all links from namespace
	GetLinkList() ([]netlink.Link, error)
	// LinkSubscribe takes a channel to which notifications will be sent
	// when links change. Close the 'done' chan to stop subscription.
	LinkSubscribe(ch chan<- netlink.LinkUpdate, done <-chan struct{}) error
	// GetAddressList reads all IP addresses
	GetAddressList(ifName string) ([]netlink.Addr, error)
	// InterfaceExists verifies interface existence
	InterfaceExists(ifName string) (bool, error)
	// IsInterfaceUp checks if the interface is UP.
	IsInterfaceUp(ifName string) (bool, error)
	// GetInterfaceType returns linux interface type
	GetInterfaceType(ifName string) (string, error)
	// GetChecksumOffloading returns the state of Rx/Tx checksum offloading
	// for the given interface.
	GetChecksumOffloading(ifName string) (rxOn, txOn bool, err error)
}

NetlinkAPIRead interface covers read methods inside linux calls package needed to manage linux interfaces.

type NetlinkAPIWrite added in v1.8.1

type NetlinkAPIWrite interface {
	// AddVethInterfacePair configures two connected VETH interfaces
	AddVethInterfacePair(ifName, peerIfName string) error
	// DeleteInterface removes the given interface.
	DeleteInterface(ifName string) error
	// SetInterfaceUp sets interface state to 'up'
	SetInterfaceUp(ifName string) error
	// SetInterfaceDown sets interface state to 'down'
	SetInterfaceDown(ifName string) error
	// AddInterfaceIP adds new IP address
	AddInterfaceIP(ifName string, addr *net.IPNet) error
	// DelInterfaceIP removes IP address from linux interface
	DelInterfaceIP(ifName string, addr *net.IPNet) error
	// SetInterfaceMac sets MAC address
	SetInterfaceMac(ifName string, macAddress string) error
	// SetInterfaceMTU set maximum transmission unit for interface
	SetInterfaceMTU(ifName string, mtu int) error
	// RenameInterface changes interface host name
	RenameInterface(ifName string, newName string) error
	// SetInterfaceAlias sets the alias of the given interface.
	// Equivalent to: `ip link set dev $ifName alias $alias`
	SetInterfaceAlias(ifName, alias string) error
	// SetLinkNamespace puts link into a network namespace.
	SetLinkNamespace(link netlink.Link, ns netns.NsHandle) error
	// SetChecksumOffloading enables/disables Rx/Tx checksum offloading
	// for the given interface.
	SetChecksumOffloading(ifName string, rxOn, txOn bool) error
}

NetlinkAPIWrite interface covers write methods inside linux calls package needed to manage linux interfaces.

Jump to

Keyboard shortcuts

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