Documentation ¶
Index ¶
- Constants
- func ConfigureLink(link netlink.Link, info *cnicurrent.Result) error
- func CreateEscapeVethPair(innerNS ns.NetNS, ifName string, mtu int) (outerVeth, innerVeth netlink.Link, err error)
- func CreateTAP(devName string, mtu int) (netlink.Link, error)
- func DetectCalico(link netlink.Link) (bool, bool, error)
- func ExtractLinkInfo(link netlink.Link, nsPath string) (*cnicurrent.Result, error)
- func FindVeth(links []netlink.Link) (netlink.Link, error)
- func FixCalicoNetworking(netConfig *cnicurrent.Result, calicoSubnetSize int, ...) error
- func GenerateMacAddress() (net.HardwareAddr, error)
- func OpenTAP(devName string) (*os.File, error)
- func RandomVethName() (string, error)
- func ReconstructVFs(csn *network.ContainerSideNetwork, netns ns.NetNS, ignoreUnbind bool) error
- func RecoverContainerSideNetwork(csn *network.ContainerSideNetwork, nsPath string, allLinks []netlink.Link, ...) error
- func SetHardwareAddr(link netlink.Link, hwAddr net.HardwareAddr) error
- func SetupBridge(bridgeName string, links []netlink.Link) (*netlink.Bridge, error)
- func SetupContainerSideNetwork(info *cnicurrent.Result, nsPath string, allLinks []netlink.Link, ...) (*network.ContainerSideNetwork, error)
- func SetupVeth(contVethName string, mtu int, hostNS ns.NetNS) (netlink.Link, netlink.Link, error)
- func StripLink(link netlink.Link) error
- func Teardown(csn *network.ContainerSideNetwork) error
- func TeardownBridge(bridge netlink.Link, links []netlink.Link) error
- func ValidateAndFixCNIResult(netConfig *cnicurrent.Result, nsPath string, allLinks []netlink.Link) (*cnicurrent.Result, error)
Constants ¶
const ( FAMILY_ALL = netlink.FAMILY_ALL FAMILY_V4 = netlink.FAMILY_V4 RTPROT_KERNEL = syscall.RTPROT_KERNEL SCOPE_LINK = netlink.SCOPE_LINK SCOPE_UNIVERSE = netlink.SCOPE_UNIVERSE )
these constants are only available on Linux
Variables ¶
This section is empty.
Functions ¶
func ConfigureLink ¶
func ConfigureLink(link netlink.Link, info *cnicurrent.Result) error
ConfigureLink configures a link according to the CNI result
func CreateEscapeVethPair ¶
func CreateEscapeVethPair(innerNS ns.NetNS, ifName string, mtu int) (outerVeth, innerVeth netlink.Link, err error)
CreateEscapeVethPair creates a veth pair with innerVeth residing in the specified network namespace innerNS and outerVeth residing in the 'outer' (current) namespace. TBD: move this to test tools
func DetectCalico ¶
DetectCalico checks if the specified link in the current network namespace is configured by Calico. It returns two boolean values where the first one denotes whether Calico is used for the specified link and the second one denotes whether Calico's default route needs to be used. This approach is needed for multiple CNI use case when the types of individual CNI plugins are not available.
func ExtractLinkInfo ¶
ExtractLinkInfo extracts ip address and netmask from veth interface in the current namespace, together with routes for this interface. There must be exactly one veth interface in the namespace and exactly one address associated with veth. Returns interface info struct and error, if any.
func FindVeth ¶
FindVeth locates single veth link in the list of provided links. There must be exactly one veth interface in the list.
func FixCalicoNetworking ¶
func FixCalicoNetworking(netConfig *cnicurrent.Result, calicoSubnetSize int, getDummyNetwork func() (*cnicurrent.Result, string, error)) error
FixCalicoNetworking updates netConfig to make Calico work with Virtlet's DHCP-server based scheme. It does so by throwing away Calico's gateway and dev route and using a fake gateway instead. The fake gateway provided by getDummyGateway() is just an IP address allocated by Calico IPAM, it's needed for proper ARP responses for VMs. This function must be called from within the container network namespace.
func GenerateMacAddress ¶
func GenerateMacAddress() (net.HardwareAddr, error)
GenerateMacAddress returns a random locally administrated unicast hardware address. Copied from: https://github.com/coreos/rkt/blob/56564bac090b44788684040f2ffd66463f29d5d0/stage1/init/kvm/network.go#L71
func RandomVethName ¶
RandomVethName returns string "veth" with random prefix (hashed from entropy)
func ReconstructVFs ¶
ReconstructVFs iterates over stored PCI addresses, rebinding each corresponding interface to its host driver, changing its MAC address and name to the values stored in csn and then moving it into the container namespace
func RecoverContainerSideNetwork ¶
func RecoverContainerSideNetwork(csn *network.ContainerSideNetwork, nsPath string, allLinks []netlink.Link, hostNS ns.NetNS) error
RecoverContainerSideNetwork tries to populate ContainerSideNetwork structure based on a network namespace that was already adjusted for Virtlet
func SetHardwareAddr ¶
func SetHardwareAddr(link netlink.Link, hwAddr net.HardwareAddr) error
SetHardwareAddr sets hardware address on provided link.
func SetupBridge ¶
SetupBridge creates a bridge and adds specified links to it. It sets bridge's MTU to MTU value of the first link.
func SetupContainerSideNetwork ¶
func SetupContainerSideNetwork(info *cnicurrent.Result, nsPath string, allLinks []netlink.Link, enableSriov bool, hostNS ns.NetNS) (*network.ContainerSideNetwork, error)
SetupContainerSideNetwork sets up networking in container namespace. It does so by preparing the following network interfaces in container ns:
tapX - tap interface for the each interface to pass to VM brX - a bridge that joins above tapX and original CNI interface
with X denoting an link index in info.Interfaces list. Each bridge gets assigned a link-local address to be used for dhcp server. In case of SR-IOV VFs this function only sets up a device to be passed to VM. The function should be called from within container namespace. Returns container network struct and an error, if any.
func SetupVeth ¶
SetupVeth sets up a pair of virtual ethernet devices. Call SetupVeth from inside the container netns. It will create both veth devices and move the host-side veth into the provided hostNS namespace. On success, SetupVeth returns (hostVeth, containerVeth, nil)
func StripLink ¶
StripLink removes addresses from the link along with any routes related to the link, except those created by the kernel
func Teardown ¶
func Teardown(csn *network.ContainerSideNetwork) error
Teardown cleans up container network configuration. It does so by invoking teardown sequence which removes ebtables rules, links and addresses in an order opposite to that of their creation in SetupContainerSideNetwork. The end result is the same network configuration in the container network namespace as it was before SetupContainerSideNetwork() call.
func TeardownBridge ¶
TeardownBridge removes links from bridge and sets it down
func ValidateAndFixCNIResult ¶
func ValidateAndFixCNIResult(netConfig *cnicurrent.Result, nsPath string, allLinks []netlink.Link) (*cnicurrent.Result, error)
ValidateAndFixCNIResult verifies that netConfig contains proper list of ips, routes, interfaces and if something is missing it tries to complement that using patch for Weave or for plugins which return their netConfig in v0.2.0 version of CNI SPEC
Types ¶
This section is empty.