linuxcalls

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 8 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 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 (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.

Jump to

Keyboard shortcuts

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