Documentation ¶
Overview ¶
Package netns defines and implements basic functions used to create and configure new network namespaces.
Index ¶
- func AddNeigh(addr net.IP, lladdr net.HardwareAddr, dev *net.Interface) (bool, error)
- func ConfigureVeth(veth *net.Interface, gatewayIP string, gatewayMAC net.HardwareAddr, ...) error
- func CreateNetns(name string) (ns.NetNS, error)
- func CreateVethPair(hostVethName, gatewayVethName string, hostNetns, gatewayNetns ns.NetNS, ...) (hostVeth, gatewayVeth net.Interface, err error)
- func DelNeigh(addr net.IP, lladdr net.HardwareAddr, dev *net.Interface) (bool, error)
- func DeleteNetns(name string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddNeigh ¶ added in v0.4.0
AddNeigh adds a permanent neighbor entry for the given neighbor into the given device. It returns an error if something goes wrong, and bool value set to true if it added the entry, otherwise is set to false.
func ConfigureVeth ¶ added in v0.4.0
func ConfigureVeth(veth *net.Interface, gatewayIP string, gatewayMAC net.HardwareAddr, netNS ns.NetNS) error
ConfigureVeth configures the veth interface passed as argument. If the veth interface is the one living the gateway netns then additional actions are carried out.
func CreateNetns ¶
CreateNetns given a name it will check if a namespace exists with the given name and will remove it. Then the namespace will be recreated. To start fresh with a clean network namespace is preferred since we create a veth pair between network namespaces. If the namespace exists it means that our operator has crashed, better clean the namespace, because it's hard to check the existing configuration that spans multiple network namespaces. Returns a handler to the newly created network namespace or an error in case something goes wrong.
func CreateVethPair ¶
func CreateVethPair(hostVethName, gatewayVethName string, hostNetns, gatewayNetns ns.NetNS, linkMTU int) (hostVeth, gatewayVeth net.Interface, err error)
CreateVethPair it will create veth pair in hostNetns and move one of them in gatewayNetns. hostNetns is the host netns and gatewayNetns is the gateway netns. Error is returned if something goes wrong.
func DelNeigh ¶ added in v0.4.0
DelNeigh deletes a fdb entry for the given neighbor from the given device. It return an error if something goes wrong, and bool value set to true if it deleted the entry, if the entry does not exist the bool value is set to false.
func DeleteNetns ¶
DeleteNetns removes a given network namespace by name. If the namespace does not exist does nothing, in case of error returns it.
Types ¶
This section is empty.