Documentation ¶
Overview ¶
Package linuxcalls contains wrappers over Netlink APIs related to Linux VETH interfaces or Linux interfaces in general.
Index ¶
- type LinuxInterfaceDetails
- type LinuxInterfaceMeta
- type LinuxInterfaceStatistics
- type NetLinkHandler
- func (handler *NetLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error
- func (handler *NetLinkHandler) AddVethInterfacePair(ifName, peerIfName string) error
- func (handler *NetLinkHandler) DelInterfaceIP(ifName string, addr *net.IPNet) error
- func (handler *NetLinkHandler) DelVethInterfacePair(ifName, peerIfName string) error
- func (h *NetLinkHandler) DumpInterfaceStatistics() ([]*LinuxInterfaceStatistics, error)
- func (h *NetLinkHandler) DumpInterfaces() ([]*LinuxInterfaceDetails, error)
- func (handler *NetLinkHandler) GetAddressList(ifName string) ([]netlink.Addr, error)
- func (handler *NetLinkHandler) GetInterfaceByName(ifName string) (*net.Interface, error)
- func (handler *NetLinkHandler) GetInterfaceType(ifName string) (string, error)
- func (handler *NetLinkHandler) GetLinkByName(ifName string) (netlink.Link, error)
- func (handler *NetLinkHandler) GetLinkList() ([]netlink.Link, error)
- func (handler *NetLinkHandler) GetVethPeerName(ifName string) (string, error)
- func (handler *NetLinkHandler) InterfaceExists(ifName string) (bool, error)
- func (handler *NetLinkHandler) RenameInterface(ifName string, newName string) error
- func (handler *NetLinkHandler) SetInterfaceDown(ifName string) error
- func (handler *NetLinkHandler) SetInterfaceMTU(ifName string, mtu int) error
- func (handler *NetLinkHandler) SetInterfaceMac(ifName string, macAddress string) error
- func (handler *NetLinkHandler) SetInterfaceUp(ifName string) error
- type NetlinkAPI
- type NetlinkAPIRead
- type NetlinkAPIWrite
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LinuxInterfaceDetails ¶ added in v1.8.1
type LinuxInterfaceDetails struct { Interface *interfaces.LinuxInterfaces_Interface `json:"linux_interface"` Meta *LinuxInterfaceMeta `json:"linux_interface_meta"` }
LinuxInterfaceDetails is the wrapper structure for the linux interface northbound API structure.
type LinuxInterfaceMeta ¶ added in v1.8.1
type LinuxInterfaceMeta struct { Index int `json:"index"` Name string `json:"name"` Alias string `json:"alias"` OperState string `json:"oper_state"` Flags string `json:"flags"` MacAddr string `json:"mac_addr"` Mtu int `json:"mtu"` Type string `json:"type"` NetNsID int `json:"net_ns_id"` NumTxQueues int `json:"num_tx_queues"` TxQueueLen int `json:"tx_queue_len"` NumRxQueues int `json:"num_rx_queues"` }
LinuxInterfaceMeta is combination of proto-modelled Interface data and linux provided metadata
type LinuxInterfaceStatistics ¶ added in v1.8.1
type LinuxInterfaceStatistics struct { Name string Index int Statistics *netlink.LinkStatistics }
LinuxInterfaceStatistics returns linux interface name/index with statistics data
type NetLinkHandler ¶ added in v1.8.1
type NetLinkHandler struct {
// contains filtered or unexported fields
}
NetLinkHandler is accessor for netlink methods
func NewNetLinkHandler ¶
func NewNetLinkHandler(nsHandler nsplugin.NamespaceAPI, ifIndexes ifaceidx.LinuxIfIndex, log logging.Logger) *NetLinkHandler
NewNetLinkHandler creates new instance of netlink handler
func (*NetLinkHandler) AddInterfaceIP ¶ added in v1.8.1
func (handler *NetLinkHandler) AddInterfaceIP(ifName string, addr *net.IPNet) error
AddInterfaceIP calls AddrAdd Netlink API.
func (*NetLinkHandler) AddVethInterfacePair ¶ added in v1.8.1
func (handler *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 (handler *NetLinkHandler) DelInterfaceIP(ifName string, addr *net.IPNet) error
DelInterfaceIP calls AddrDel Netlink API.
func (*NetLinkHandler) DelVethInterfacePair ¶ added in v1.8.1
func (handler *NetLinkHandler) DelVethInterfacePair(ifName, peerIfName string) error
DelVethInterfacePair calls LinkDel Netlink API for the Netlink.Veth interface type.
func (*NetLinkHandler) DumpInterfaceStatistics ¶ added in v1.8.1
func (h *NetLinkHandler) DumpInterfaceStatistics() ([]*LinuxInterfaceStatistics, error)
DumpInterfaceStatistics is an implementation of linux interface handler
func (*NetLinkHandler) DumpInterfaces ¶ added in v1.8.1
func (h *NetLinkHandler) DumpInterfaces() ([]*LinuxInterfaceDetails, error)
DumpInterfaces is an implementation of linux interface handler
func (*NetLinkHandler) GetAddressList ¶ added in v1.8.1
func (handler *NetLinkHandler) GetAddressList(ifName string) ([]netlink.Addr, error)
GetAddressList calls AddrList netlink API
func (*NetLinkHandler) GetInterfaceByName ¶ added in v1.8.1
func (handler *NetLinkHandler) GetInterfaceByName(ifName string) (*net.Interface, error)
GetInterfaceByName return *net.Interface type from interface name
func (*NetLinkHandler) GetInterfaceType ¶ added in v1.8.1
func (handler *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 (handler *NetLinkHandler) GetLinkByName(ifName string) (netlink.Link, error)
GetLinkByName calls netlink API to get Link type from interface name
func (*NetLinkHandler) GetLinkList ¶ added in v1.8.1
func (handler *NetLinkHandler) GetLinkList() ([]netlink.Link, error)
GetLinkList calls netlink API to get all Links in namespace
func (*NetLinkHandler) GetVethPeerName ¶ added in v1.8.1
func (handler *NetLinkHandler) GetVethPeerName(ifName string) (string, error)
GetVethPeerName return the peer name for a given VETH interface.
func (*NetLinkHandler) InterfaceExists ¶ added in v1.8.1
func (handler *NetLinkHandler) InterfaceExists(ifName string) (bool, error)
InterfaceExists checks if interface with a given name exists.
func (*NetLinkHandler) RenameInterface ¶ added in v1.8.1
func (handler *NetLinkHandler) RenameInterface(ifName string, newName string) error
RenameInterface changes the name of the interface <ifName> to <newName>.
func (*NetLinkHandler) SetInterfaceDown ¶ added in v1.8.1
func (handler *NetLinkHandler) SetInterfaceDown(ifName string) error
SetInterfaceDown calls Netlink API LinkSetDown.
func (*NetLinkHandler) SetInterfaceMTU ¶ added in v1.8.1
func (handler *NetLinkHandler) SetInterfaceMTU(ifName string, mtu int) error
SetInterfaceMTU calls LinkSetMTU Netlink API.
func (*NetLinkHandler) SetInterfaceMac ¶ added in v1.8.1
func (handler *NetLinkHandler) SetInterfaceMac(ifName string, macAddress string) error
SetInterfaceMac calls LinkSetHardwareAddr netlink API.
func (*NetLinkHandler) SetInterfaceUp ¶ added in v1.8.1
func (handler *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 ¶ 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) // GetAddressList reads all IP addresses GetAddressList(ifName string) ([]netlink.Addr, error) // GetInterfaceType returns linux interface type GetInterfaceType(ifName string) (string, error) // GetVethPeerName returns VETH's peer name GetVethPeerName(ifName string) (string, error) // GetInterfaceByName returns *net.Interface type from name GetInterfaceByName(ifName string) (*net.Interface, error) // DumpInterfaces returns all configured linux interfaces in all namespaces in proto-modelled format with metadata DumpInterfaces() ([]*LinuxInterfaceDetails, error) // DumpInterfaceStatistics returns statistics data for all known interfaces interfaces DumpInterfaceStatistics() ([]*LinuxInterfaceStatistics, error) // InterfaceExists verifies interface existence InterfaceExists(ifName string) (bool, 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 // DelVethInterfacePair removes VETH pair DelVethInterfacePair(ifName, peerIfName 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 }
NetlinkAPIWrite interface covers write methods inside linux calls package needed to manage linux interfaces.