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 <inputNode> <count>" 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