network

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// NetQueueSize is the default virtio-net ring depth per queue.
	// 512 balances download throughput (favors larger rings) against
	// request-response latency (favors smaller rings).
	NetQueueSize = 512
)

Variables

View Source
var (
	ErrNotFound      = errors.New("network not found")
	ErrNotConfigured = errors.New("network provider not configured")
)

Functions

func NetNumQueues added in v0.3.2

func NetNumQueues(cpu int) int

NetNumQueues returns the virtio-net queue count for the given CPU count. CH uses queue pairs (TX+RX), so the result is always even (≥ 2).

func ResolveQueueSize added in v0.3.2

func ResolveQueueSize(qs int) int

ResolveQueueSize returns qs if positive, otherwise the default NetQueueSize.

func TuneTAP added in v0.3.2

func TuneTAP(link netlink.Link) error

TuneTAP applies best-effort performance tuning to a TAP device.

func VMIDPrefix added in v0.3.2

func VMIDPrefix(vmID string) string

VMIDPrefix returns the first 8 characters of a VM ID, matching the truncation used by both bridge and CNI TAP device naming.

Types

type Network

type Network interface {
	Type() string

	// Verify checks whether the network namespace for a VM exists.
	// Returns nil if the netns is present, an error otherwise.
	Verify(ctx context.Context, vmID string) error
	// Config creates network namespace, bridge, and tap for a VM.
	// When existing configs are provided (recovery after host reboot),
	// the netns and tap devices are recreated using the persisted MAC addresses.
	// NOTE: vmCfg.Network may be mutated to record the resolved conflist name.
	Config(ctx context.Context, vmID string, numNICs int, vmCfg *types.VMConfig, existing ...*types.NetworkConfig) ([]*types.NetworkConfig, error)
	Delete(context.Context, []string) ([]string, error)
	Inspect(context.Context, string) (*types.Network, error)
	List(context.Context) ([]*types.Network, error)

	RegisterGC(*gc.Orchestrator)
}

Network defines the interface for a network provider (CNI, etc.).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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