vni

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AllocatorOption

type AllocatorOption func(*VNIAllocator)

AllocatorOption configures a VNIAllocator.

func WithQuarantineWindow

func WithQuarantineWindow(d time.Duration) AllocatorOption

WithQuarantineWindow overrides how long a released VNI is withheld from reuse.

func WithRandomBase added in v0.22.0

func WithRandomBase() AllocatorOption

WithRandomBase starts the allocation scan at a random point in the 24-bit VNI space instead of 1. Relays allocate VNIs independently, but an agent connected to several relays installs them all in one icx handler keyed globally by VNI — with a common base every relay hands the same agent the same low VNIs and its reconnects collide until backoff walks past every live session. A random per-process base makes cross-relay overlap vanishingly unlikely.

type VNIAllocator

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

VNIAllocator is a relay-local VNI allocator with quarantine-on-release: a released VNI is held for a quarantine window before it can be handed out again, so a new connection never reuses a VNI whose icx SA teardown may still be in flight (which would let a stale SA match the new peer). VNIs are unique only per relay (§2.5) and nothing stores them durably; a relay restart abandons the whole space and agents reconnect with fresh VNIs.

Quarantined VNIs keep their bit set in the pool (so FirstZero skips them) and carry a release deadline; the next Allocate sweeps any whose deadline has passed back into the free pool.

func NewVNIAllocator

func NewVNIAllocator(opts ...AllocatorOption) *VNIAllocator

NewVNIAllocator creates a relay-local quarantine-aware VNI allocator.

func (*VNIAllocator) Allocate

func (a *VNIAllocator) Allocate() (uint, error)

Allocate reserves and returns an unused VNI. VNI 0 is reserved (the icx handler rejects it), so allocation starts at 1 (VNIPool.Allocate begins at 1).

func (*VNIAllocator) Release

func (a *VNIAllocator) Release(vni uint)

Release moves a VNI into quarantine; it becomes reusable only after the quarantine window elapses (enforced lazily on the next Allocate).

type VNIPool

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

TODO: support for some kind of persistent bitmap datastructure (sqlite3?).

func NewVNIPool

func NewVNIPool() *VNIPool

func NewVNIPoolWithBase added in v0.22.0

func NewVNIPoolWithBase(base uint32) *VNIPool

NewVNIPoolWithBase creates a pool whose allocation scan starts at base, wrapping around to 1 when the space above base is exhausted. base is clamped into [1, maxVNI).

func (*VNIPool) Allocate

func (v *VNIPool) Allocate() (uint, error)

func (*VNIPool) Release

func (v *VNIPool) Release(vni uint)

Jump to

Keyboard shortcuts

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