netns

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package netns defines and implements basic functions used to create and configure new network namespaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddNeigh added in v0.4.0

func AddNeigh(addr net.IP, lladdr net.HardwareAddr, dev *net.Interface) (bool, error)

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, 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 ConfigureVethNeigh added in v0.5.0

func ConfigureVethNeigh(veth *net.Interface, gatewayIP string, gatewayMAC net.HardwareAddr, netNS ns.NetNS) error

ConfigureVethNeigh configures an entry in the ARP table, according to the specified parameters.

func CreateNetns

func CreateNetns(name string) (ns.NetNS, error)

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

func DelNeigh(addr net.IP, lladdr net.HardwareAddr, dev *net.Interface) (bool, error)

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

func DeleteNetns(name string) error

DeleteNetns removes a given network namespace by name. If the namespace does not exist does nothing, in case of error returns it.

func RegisterOnVethHwAddrChangeHandler added in v0.5.0

func RegisterOnVethHwAddrChangeHandler(namespace ns.NetNS, vethName string, handler func(net.HardwareAddr) error) error

RegisterOnVethHwAddrChangeHandler registers a handler to be executed whenever an attribute of the given veth interface changes. The handler is always executed once upon registration.

Types

This section is empty.

Jump to

Keyboard shortcuts

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