Documentation ¶
Overview ¶
Package linuxcalls contains wrappers over Netlink APIs related to Linux VETH interfaces or Linux interfaces in general.
Index ¶
- type NetLinkHandler
- func (h *NetLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error
- func (h *NetLinkHandler) AddVethInterfacePair(ifName, peerIfName string) error
- func (h *NetLinkHandler) DelInterfaceIP(ifName string, addr *net.IPNet) error
- func (h *NetLinkHandler) DeleteInterface(ifName string) error
- func (h *NetLinkHandler) GetAddressList(ifName string) ([]netlink.Addr, error)
- func (h *NetLinkHandler) GetChecksumOffloading(ifName string) (rxOn, txOn bool, err error)
- func (h *NetLinkHandler) GetInterfaceType(ifName string) (string, error)
- func (h *NetLinkHandler) GetLinkByName(ifName string) (netlink.Link, error)
- func (h *NetLinkHandler) GetLinkList() ([]netlink.Link, error)
- func (h *NetLinkHandler) InterfaceExists(ifName string) (bool, error)
- func (h *NetLinkHandler) IsInterfaceUp(ifName string) (bool, error)
- func (h *NetLinkHandler) LinkSubscribe(ch chan<- netlink.LinkUpdate, done <-chan struct{}) error
- func (h *NetLinkHandler) RenameInterface(ifName string, newName string) error
- func (h *NetLinkHandler) SetChecksumOffloading(ifName string, rxOn, txOn bool) error
- func (h *NetLinkHandler) SetInterfaceAlias(ifName, alias string) error
- func (h *NetLinkHandler) SetInterfaceDown(ifName string) error
- func (h *NetLinkHandler) SetInterfaceMTU(ifName string, mtu int) error
- func (h *NetLinkHandler) SetInterfaceMac(ifName string, macAddress string) error
- func (h *NetLinkHandler) SetInterfaceUp(ifName string) error
- func (h *NetLinkHandler) SetLinkNamespace(link netlink.Link, ns netns.NsHandle) (err error)
- type NetlinkAPI
- type NetlinkAPIRead
- type NetlinkAPIWrite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NetLinkHandler ¶
type NetLinkHandler struct { }
NetLinkHandler is accessor for Netlink methods.
func NewNetLinkHandler ¶
func NewNetLinkHandler() *NetLinkHandler
NewNetLinkHandler creates new instance of Netlink handler.
func (*NetLinkHandler) AddInterfaceIP ¶
func (h *NetLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error
AddInterfaceIP calls AddrAdd Netlink API.
func (*NetLinkHandler) AddVethInterfacePair ¶
func (h *NetLinkHandler) AddVethInterfacePair(ifName, peerIfName string) error
AddVethInterfacePair calls LinkAdd Netlink API for the Netlink.Veth interface type.
func (*NetLinkHandler) DelInterfaceIP ¶
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 ¶
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 ¶
func (h *NetLinkHandler) GetInterfaceType(ifName string) (string, error)
GetInterfaceType returns the type (string representation) of a given interface.
func (*NetLinkHandler) GetLinkByName ¶
func (h *NetLinkHandler) GetLinkByName(ifName string) (netlink.Link, error)
GetLinkByName calls netlink API to get Link type from interface name
func (*NetLinkHandler) GetLinkList ¶
func (h *NetLinkHandler) GetLinkList() ([]netlink.Link, error)
GetLinkList calls netlink API to get all Links in namespace
func (*NetLinkHandler) InterfaceExists ¶
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 ¶
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 ¶
func (h *NetLinkHandler) SetInterfaceDown(ifName string) error
SetInterfaceDown calls Netlink API LinkSetDown.
func (*NetLinkHandler) SetInterfaceMTU ¶
func (h *NetLinkHandler) SetInterfaceMTU(ifName string, mtu int) error
SetInterfaceMTU calls LinkSetMTU Netlink API.
func (*NetLinkHandler) SetInterfaceMac ¶
func (h *NetLinkHandler) SetInterfaceMac(ifName string, macAddress string) error
SetInterfaceMac calls LinkSetHardwareAddr netlink API.
func (*NetLinkHandler) SetInterfaceUp ¶
func (h *NetLinkHandler) SetInterfaceUp(ifName string) error
SetInterfaceUp calls Netlink API LinkSetUp.
type NetlinkAPI ¶
type NetlinkAPI interface { NetlinkAPIWrite NetlinkAPIRead }
NetlinkAPI interface covers all methods inside linux calls package needed to manage linux interfaces.
type NetlinkAPIRead ¶
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 ¶
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.