networking

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package networking provides primitives to connect function instances to the network.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NetworkConfig

type NetworkConfig struct {
	// contains filtered or unexported fields
}

NetworkConfig represents the network devices, IPs, namespaces, routes and filter rules to connect a uVM to the network. The network config ID is deterministically mapped to IP addresses to be used for the uVM. Note that due to the current allocation of IPs at most 2^14 VMs can be simultaneously be available on a single host.

func NewNetworkConfig

func NewNetworkConfig(id int, hostIfaceName string) *NetworkConfig

NewNetworkConfig creates a new network config with a given id and default host interface

func (*NetworkConfig) CreateNetwork

func (cfg *NetworkConfig) CreateNetwork() error

CreateNetwork creates the necessary network devices, namespaces, routes and filter rules to connect the uVM to the network. The networking is created as described in the Firecracker documentation on providing networking for clones (https://github.com/firecracker-microvm/firecracker/blob/main/docs/snapshotting/network-for-clones.md)

func (*NetworkConfig) GetCloneIP

func (cfg *NetworkConfig) GetCloneIP() string

GetCloneIP returns the IP address the uVM is reachable at from the host

func (*NetworkConfig) GetContainerCIDR

func (cfg *NetworkConfig) GetContainerCIDR() string

GetContainerCIDR returns the internal IP of the uVM in CIDR notation

func (*NetworkConfig) GetGatewayIP

func (cfg *NetworkConfig) GetGatewayIP() string

GetGatewayIP returns the IP address of the tap device associated with the uVM

func (*NetworkConfig) GetHostDevName

func (cfg *NetworkConfig) GetHostDevName() string

GetHostDevName returns the device connecting the uVM to the host

func (*NetworkConfig) GetMacAddress

func (cfg *NetworkConfig) GetMacAddress() string

GetMacAddress returns the mac address used for the uVM

func (*NetworkConfig) GetNamespacePath

func (cfg *NetworkConfig) GetNamespacePath() string

GetNamespacePath returns the full path to the network namespace for the uVM

func (*NetworkConfig) RemoveNetwork

func (cfg *NetworkConfig) RemoveNetwork() error

CreateNetwork removes the necessary network devices, namespaces, routes and filter rules to connect the function instance to the network

type NetworkManager

type NetworkManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

NetworkManager manages the in use network configurations along with a pool of free network configurations that can be used to connect a function instance to the network.

func NewNetworkManager

func NewNetworkManager(hostIfaceName string, poolSize int) (*NetworkManager, error)

NewNetworkManager creates and returns a new network manager that connects function instances to the network using the supplied interface. If no interface is supplied, the default interface is used. To take the network setup of the critical path of a function creation, the network manager tries to maintain a pool of ready to use network configurations of size at least poolSize.

func (*NetworkManager) Cleanup

func (mgr *NetworkManager) Cleanup() error

Cleanup removes and deallocates all network configurations that are in use or in the network pool. Make sure to first clean up all running functions before removing their network configs.

func (*NetworkManager) CreateNetwork

func (mgr *NetworkManager) CreateNetwork(funcID string) (*NetworkConfig, error)

CreateNetwork creates the networking for a function instance identified by funcID

func (*NetworkManager) GetConfig

func (mgr *NetworkManager) GetConfig(funcID string) *NetworkConfig

GetConfig returns the network config assigned to a function instance identified by funcID

func (*NetworkManager) RemoveNetwork

func (mgr *NetworkManager) RemoveNetwork(funcID string) error

RemoveNetwork removes the network config of a function instance identified by funcID. The allocated network devices for the given function instance must not be in use anymore when calling this function.

Jump to

Keyboard shortcuts

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