network

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const Subnet = "10.200.0.0/16"

Subnet is the internal IP range used for Firecracker microVMs.

Variables

This section is empty.

Functions

func AddPortMapping added in v0.5.5

func AddPortMapping(hostInterface string, hostPort int, guestIP string, guestPort int, protocol string) error

AddPortMapping adds DNAT and FORWARD rules for a port mapping.

func Bootstrap

func Bootstrap() error

Bootstrap dynamically configures the host's networking stack to allow the MicroVMs to reach the internet via NAT and IP Forwarding.

func CreatePointToPointTap

func CreatePointToPointTap(name, hostIP, guestIP string, uid, gid int) error

CreatePointToPointTap creates a new TAP interface and establishes a Point-to-Point peer route. Uses netlink syscalls directly to avoid fork/exec overhead and kernel RTNL lock contention from concurrent `ip` command invocations.

func CreateTap

func CreateTap(name, ipAddr string) error

CreateTap creates a new TAP interface and assigns it an IP.

func DeleteTap

func DeleteTap(name string) error

DeleteTap removes a TAP interface.

func RemovePortMapping added in v0.5.5

func RemovePortMapping(hostInterface string, hostPort int, guestIP string, guestPort int, protocol string) error

RemovePortMapping removes the DNAT and FORWARD rules for a port mapping.

func Teardown

func Teardown() error

Teardown safely reverses the NAT setup.

Types

type IPAM

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

IPAM manages the allocation of /32 point-to-point IP addresses for Firecracker MicroVMs out of a given CIDR block.

func NewIPAM

func NewIPAM(cidr string) (*IPAM, error)

NewIPAM creates a new IP address manager from a CIDR string.

func (*IPAM) Acquire

func (i *IPAM) Acquire() (string, error)

Acquire gets an unused /32 guest IP from the configured subnet block.

func (*IPAM) Release

func (i *IPAM) Release(ip string)

Release returns the IP to the pool.

type PortManager added in v0.5.5

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

PortManager tracks host port usage across all MicroVMs managed by the daemon. It supports both explicit "deterministic" allocation and random "ephemeral" allocation.

func NewPortManager added in v0.5.5

func NewPortManager(start, end int) *PortManager

NewPortManager initializes a new PortManager with the specified ephemeral range.

func (*PortManager) Allocate added in v0.5.5

func (pm *PortManager) Allocate(requestedPort int, protocol string, iface string, vmID string) (int, error)

Allocate attempts to reserve a port for a specific VM. If requestedPort is 0, it picks an available port from the ephemeral pool. If requestedPort is > 0, it checks if the port is available and claims it.

func (*PortManager) Release added in v0.5.5

func (pm *PortManager) Release(port int)

Release frees a previously allocated port.

Jump to

Keyboard shortcuts

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