vpp

package
v0.0.0-...-6b8ee43 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateStartupConf

func GenerateStartupConf(w io.Writer, s *VPPSettings) error

GenerateStartupConf writes a VPP startup.conf to w based on the given settings. The output follows the production-proven template from IPng.ch / VyOS.

func SetVPPEventBus

func SetVPPEventBus(eb ze.EventBus)

SetVPPEventBus sets the package-level EventBus reference. MUST be called before VPPManager.Run starts.

func SetVPPLogger

func SetVPPLogger(l *slog.Logger)

SetVPPLogger sets the package-level logger for the VPP component.

func SetVPPMetricsRegistry

func SetVPPMetricsRegistry(reg metrics.Registry)

SetVPPMetricsRegistry sets the package-level metrics registry for VPP telemetry. Called via ConfigureMetrics callback before RunEngine.

func ShowRuntime

func ShowRuntime() (string, error)

ShowRuntime sends "show runtime" for node counters.

func TraceClear

func TraceClear() (string, error)

TraceClear sends "clear trace".

func TraceShow

func TraceShow() (string, error)

TraceShow sends "show trace" and returns raw output.

func TraceStart

func TraceStart(inputNode string, count int) (string, error)

TraceStart sends "trace add " to VPP.

func ValidatePCIAddress

func ValidatePCIAddress(addr string) error

ValidatePCIAddress checks that addr matches the PCI bus address format.

Types

type CPUSettings

type CPUSettings struct {
	MainCore *uint8 // nil = auto
	Workers  *uint8 // nil = auto
	// PollSleepMicroseconds is VPP's fixed sleep between main-loop polls
	// (emitted as unix { poll-sleep-usec N }). nil = unset (VPP default: no
	// sleep, busy-poll at 100% CPU). An explicit 0 is emitted (VPP treats 0 as
	// "do not sleep", matching the default, but the operator asked for it).
	PollSleepMicroseconds *uint32
}

CPUSettings holds VPP CPU pinning settings.

type Connector

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

Connector manages the GoVPP connection to VPP's binary API socket. It provides API channels for dependent plugins (fibvpp, ifacevpp) via NewChannel. MUST call Close on shutdown.

func GetActiveConnector

func GetActiveConnector() *Connector

GetActiveConnector returns the GoVPP connector from the running VPP Manager. Dependent plugins (fibvpp, ifacevpp) call this to get API channels. Returns nil if the VPP component is not running.

func NewConnector

func NewConnector(apiSocket string) *Connector

NewConnector creates a Connector for the given VPP API socket path.

func (*Connector) Close

func (c *Connector) Close()

Close disconnects from VPP. Safe to call multiple times.

func (*Connector) Connect

func (c *Connector) Connect(ctx context.Context, maxAttempts int, retryInterval time.Duration) error

Connect establishes the GoVPP connection to VPP's binary API socket. It uses AsyncConnect with retry logic (maxAttempts attempts, retryInterval between each). Blocks until connected, context canceled, or all attempts exhausted. Does NOT hold the mutex during the blocking wait.

func (*Connector) IsConnected

func (c *Connector) IsConnected() bool

IsConnected returns whether the GoVPP connection is established.

func (*Connector) NewChannel

func (c *Connector) NewChannel() (api.Channel, error)

NewChannel creates a new GoVPP API channel for making VPP binary API calls. Each caller should create its own channel. Channels are safe for concurrent use. Caller MUST call channel.Close() when done.

func (*Connector) WaitConnected

func (c *Connector) WaitConnected(ctx context.Context, timeout time.Duration) error

WaitConnected blocks until the Connector reports connected, or the timeout elapses, or ctx is canceled. Returns nil on success, ctx.Err() on cancel, and a timeout error on deadline. Callers that need a synchronous guarantee before calling NewChannel use this to smooth over cold-boot races where ze and VPP start together but VPP has not yet accepted API clients.

Implementation polls IsConnected at a 50ms interval; this is coarse enough to avoid burning CPU on a warm cache and fine enough that a 5-second wait loses at most ~50ms of latency. No condition variable because Connect can happen from any goroutine and we do not want to re-architect the mutex.

type DPDKBinder

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

DPDKBinder manages DPDK NIC driver binding and unbinding. It saves original drivers so they can be restored on teardown. MUST call UnbindAll on shutdown to restore original drivers.

func NewDPDKBinder

func NewDPDKBinder() *DPDKBinder

NewDPDKBinder creates a new DPDK NIC binder.

func (*DPDKBinder) BindAll

func (d *DPDKBinder) BindAll(interfaces []DPDKInterface) error

BindAll binds all configured DPDK interfaces to vfio-pci. MUST be called before starting VPP. Caller MUST call UnbindAll on teardown to restore original drivers.

func (*DPDKBinder) UnbindAll

func (d *DPDKBinder) UnbindAll() error

UnbindAll restores all NICs to their original drivers. Safe to call multiple times.

type DPDKInterface

type DPDKInterface struct {
	PCIAddress string
	Name       string
	RxQueues   *uint8 // nil = VPP default
	TxQueues   *uint8 // nil = VPP default
}

DPDKInterface represents a single DPDK-managed NIC.

type DPDKSettings

type DPDKSettings struct {
	Interfaces []DPDKInterface
}

DPDKSettings holds DPDK NIC configuration.

type IfaceStatsReader

type IfaceStatsReader interface {
	GetInterfaceStats(*api.InterfaceStats) error
}

IfaceStatsReader is the subset of the VPP stats provider that dependent plugins (ifacevpp) need to read per-interface counters.

func GetActiveStatsProvider

func GetActiveStatsProvider() IfaceStatsReader

GetActiveStatsProvider returns the VPP stats reader from the running VPP Manager. Dependent plugins (ifacevpp) call this to read per-interface counters. Returns nil if the VPP component has no stats connection.

type LCPSettings

type LCPSettings struct {
	Enabled    bool
	Sync       bool
	AutoSubint bool
	Netns      string
}

LCPSettings holds Linux Control Plane plugin settings.

func GetActiveLCPSettings

func GetActiveLCPSettings() (LCPSettings, bool)

GetActiveLCPSettings returns the LCP settings of the running VPP Manager and whether they are available. Returns ok=false when the VPP component is not running, so callers treat LCP as unavailable rather than assuming defaults.

type MemorySettings

type MemorySettings struct {
	MainHeap     string // e.g. "1G", "1536M"
	HugepageSize string // "2M" or "1G"
	Buffers      uint32
}

MemorySettings holds VPP memory and buffer settings.

type PluginSettings

type PluginSettings struct {
	Wireguard bool
}

PluginSettings holds optional VPP plugin enablement toggles. startup.conf disables plugins by default (plugin default { disable }); each toggle here emits an explicit `plugin .so { enable }`.

type StatsSettings

type StatsSettings struct {
	SegmentSize  string
	SocketPath   string
	PollInterval uint16 // seconds, 1-3600, default 30
}

StatsSettings holds VPP stats segment settings.

type VPPManager

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

VPPManager is the self-contained VPP lifecycle manager. It owns startup, health monitoring, crash recovery, and clean shutdown. Call Run(ctx) to start the lifecycle loop. Run blocks until ctx is canceled.

func NewVPPManager

func NewVPPManager(settings *VPPSettings, confDir, vppBinary string) *VPPManager

NewVPPManager creates a VPP lifecycle manager from parsed settings. confDir is the directory where startup.conf will be written. vppBinary is the path to the VPP executable.

func (*VPPManager) GetConnector

func (m *VPPManager) GetConnector() *Connector

GetConnector returns the GoVPP connector for dependent plugins. Dependents call connector.NewChannel() to get API channels.

func (*VPPManager) IsConnected

func (m *VPPManager) IsConnected() bool

IsConnected returns whether the GoVPP connection is established.

func (*VPPManager) Run

func (m *VPPManager) Run(ctx context.Context) error

Run is the self-contained lifecycle loop. It blocks until ctx is canceled.

Sequence: generate startup.conf, bind DPDK NICs, exec VPP, connect GoVPP, emit ("vpp","connected"), monitor. On crash: emit ("vpp","disconnected"), backoff, restart, emit ("vpp","reconnected"). On ctx cancel: SIGTERM VPP, wait, unbind NICs.

type VPPSettings

type VPPSettings struct {
	Enabled   bool
	External  bool // true: ze connects via GoVPP but does not exec/supervise the VPP binary
	APISocket string
	CPU       CPUSettings
	Memory    MemorySettings
	DPDK      DPDKSettings
	Stats     StatsSettings
	LCP       LCPSettings
	Plugins   PluginSettings
}

VPPSettings holds parsed VPP configuration from the YANG config tree.

func ParseConfigSection

func ParseConfigSection(data string) (*VPPSettings, error)

ParseConfigSection parses a wrapped VPP config section delivered by the plugin-server `ExtractConfigSubtree` helper. That helper wraps every subtree in its path structure, so a section for the "vpp" root arrives as `{"vpp": {...}}` rather than the bare `{...}` that ParseSettings operates on. This function unwraps the "vpp" root and delegates to ParseSettings.

Use this from plugin OnConfigure callbacks. Use ParseSettings directly from tests or callers that already hold the inner subtree.

func ParseSettings

func ParseSettings(section json.RawMessage) (*VPPSettings, error)

ParseSettings extracts VPP configuration from a YANG config JSON section. The section is the "vpp" subtree from the config tree.

func (*VPPSettings) Validate

func (s *VPPSettings) Validate() error

Validate checks the settings for semantic errors beyond YANG schema validation.

Directories

Path Synopsis
Package yang embeds the vpp component's YANG configuration schema and registers it with the config module registry.
Package yang embeds the vpp component's YANG configuration schema and registers it with the config module registry.

Jump to

Keyboard shortcuts

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