fwstate

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultStashSize = uint64(C.FWSTATE_STASH_DEFAULT_SIZE)

DefaultStashSize is the per-worker stash size a zero request selects.

View Source
const HarnessWorkerCount = int(C.FWSTATE_TEST_WORKER_COUNT)

HarnessWorkerCount is the dataplane worker count of the harness agent.

StashRecordSize is the stash bytes one record takes.

Variables

This section is empty.

Functions

func AgentFreeBytes added in v0.1.0

func AgentFreeBytes(agent *C.struct_agent) uint64

AgentFreeBytes sums the free bytes of the allocator behind the agent.

func CheckStateExists

func CheckStateExists(
	cpModule *C.struct_cp_module,
	proto layers.IPProtocol,
	srcPort uint16,
	dstPort uint16,
	srcAddr string,
	dstAddr string,
) bool

CheckStateExists checks if a state exists in the linked fwtable

func ClearSyncDestination added in v0.1.0

func ClearSyncDestination(cpModule *C.struct_cp_module)

ClearSyncDestination leaves both emission endpoints disabled for a no-sync configuration.

func CreateAndFreeModuleConfig added in v0.1.0

func CreateAndFreeModuleConfig(agent *C.struct_agent) (uint64, error)

CreateAndFreeModuleConfig builds an fwstate module config without map links on the agent and destroys it again, reporting how many per-worker read positions the config held and the first error.

func CreateMapV4 added in v0.1.0

func CreateMapV4(object *C.struct_fwstate_map_v4_object, workerCount uint16, indexSize uint32, stashSize uint64) (int, error)

CreateMapV4 creates the map with a 1024-slot first layer and a stash of stashSize bytes per worker, zero selecting the default, and reports the C return code with errno.

func DestroyMapV4Object added in v0.1.0

func DestroyMapV4Object(agent *C.struct_agent, object *C.struct_fwstate_map_v4_object)

DestroyMapV4Object tears the object down and returns its storage to the agent, as the typed destructor does once the object dangles.

func FreeStaleMapV4Layers

func FreeStaleMapV4Layers(object *C.struct_fwstate_map_v4_object)

FreeStaleMapV4Layers releases the layers parked by UnlinkStaleMapV4Layers.

func GetCurrentTime

func GetCurrentTime() uint64

GetCurrentTime returns current time in nanoseconds

func GetLayerCount

func GetLayerCount(cpModule *C.struct_cp_module) (uint32, uint32)

GetLayerCount returns the number of layers in both IPv4 and IPv6 tables

func GetStateDeadline

func GetStateDeadline(
	cpModule *C.struct_cp_module,
	proto layers.IPProtocol,
	srcPort uint16,
	dstPort uint16,
	srcAddr string,
	dstAddr string,
) uint64

GetStateDeadline returns the deadline of a state entry

func InsertMapV4Layer

func InsertMapV4Layer(
	object *C.struct_fwstate_map_v4_object,
	indexSize uint32,
	extraBucketCount uint32,
	workerCount uint16,
) int

InsertMapV4Layer appends one layer to the object's table chain and reports the C return code.

func InsertNewLayer

func InsertNewLayer(cpModule *C.struct_cp_module)

InsertNewLayer appends a new layer to both linked map objects via the C harness helper.

func MapV4StashSize added in v0.1.0

func MapV4StashSize(object *C.struct_fwstate_map_v4_object) uint64

MapV4StashSize reports the object's per-worker stash size in bytes.

func NewBareMapV4Object added in v0.1.0

func NewBareMapV4Object(agent *C.struct_agent, name string) *C.struct_fwstate_map_v4_object

NewBareMapV4Object creates an IPv4 map object that is not created yet: no stash and no table layer, unregistered (dangling).

func NewHarnessAgent

func NewHarnessAgent(memCtx testutils.MemoryContext) *C.struct_agent

NewHarnessAgent allocates a stand-alone harness agent in the given memory context, without any module config or linked map objects.

func NewMapV4Object

func NewMapV4Object(agent *C.struct_agent, name string) *C.struct_fwstate_map_v4_object

NewMapV4Object creates an IPv4 map object with its first table layer already installed, leaving it unregistered (dangling).

func SetSyncMTU added in v0.1.0

func SetSyncMTU(cpModule *C.struct_cp_module, mtu uint16)

SetSyncMTU sets the sync MTU on a module config produced by fwstateModuleConfig. Zero selects the default.

func SetSyncSuppressTimeout

func SetSyncSuppressTimeout(cpModule *C.struct_cp_module, ns uint64)

SetSyncSuppressTimeout sets the sync suppression window (nanoseconds) on a module config produced by fwstateModuleConfig. Zero disables suppression.

func SetSyncTCPTimeouts

func SetSyncTCPTimeouts(cpModule *C.struct_cp_module, tcp, tcpFin uint64)

SetSyncTCPTimeouts overrides the TCP established (tcp) and teardown (tcp_fin) timeouts so a test can distinguish an established refresh from a shorter-TTL state transition.

func SetSyncUnicastDestination added in v0.1.0

func SetSyncUnicastDestination(cpModule *C.struct_cp_module)

SetSyncUnicastDestination sets a unicast emission endpoint for a test.

func TrimStaleLayers

func TrimStaleLayers(cpModule *C.struct_cp_module, now uint64) error

TrimStaleLayers trims stale layers from both linked map objects.

func UnlinkStaleMapV4Layers

func UnlinkStaleMapV4Layers(object *C.struct_fwstate_map_v4_object, now uint64) int

UnlinkStaleMapV4Layers parks expired tail layers in the stale chain and reports the C return code.

Types

type CursorResult

type CursorResult struct {
	Idx      uint32
	Proto    uint16
	SrcPort  uint16
	DstPort  uint16
	SrcAddr  uint32
	DstAddr  uint32
	Flags    uint8
	External bool

	CreatedAt   uint64
	UpdatedAt   uint64
	PktForward  uint64
	PktBackward uint64
}

CursorResult holds data from a single cursor entry, copied into Go memory.

type MemCounters

type MemCounters struct {
	BallocCount uint64
	BfreeCount  uint64
	BallocSize  uint64
	BfreeSize   uint64
}

MemCounters is a snapshot of one memory context's accounting counters, for tests that assert where allocations and frees were charged.

func AgentMemCounters

func AgentMemCounters(agent *C.struct_agent) MemCounters

AgentMemCounters snapshots the stand-in agent's context counters.

func ObjectMemCounters

func ObjectMemCounters(object *C.struct_fwstate_map_v4_object) MemCounters

ObjectMemCounters snapshots a map object's own context counters.

type StateValueSnapshot

type StateValueSnapshot struct {
	Found           bool
	External        bool
	FlagsRaw        uint8
	CreatedAt       uint64
	UpdatedAt       uint64
	PacketsForward  uint64
	PacketsBackward uint64
	Deadline        uint64
}

StateValueSnapshot is a Go-side snapshot of a fw_state_value entry.

func GetStateValue

func GetStateValue(
	cpModule *C.struct_cp_module,
	proto layers.IPProtocol,
	srcPort uint16,
	dstPort uint16,
	srcAddr string,
	dstAddr string,
) StateValueSnapshot

GetStateValue reads the raw fw_state_value for a given 5-tuple via a fwtable lookup across all layers. Returns Found=false if the state does not exist.

type SyncFrameOption

type SyncFrameOption func(*C.struct_fw_state_sync_frame)

SyncFrameOption is a functional option for createSyncFrame

func WithFrameFib

func WithFrameFib(fib uint8) SyncFrameOption

WithFrameFib sets fib (direction marker: 0 = forward, 1 = backward)

func WithFrameFlags

func WithFrameFlags(flags uint8) SyncFrameOption

WithFrameFlags sets raw flags byte in the sync frame. `flags` is a union exposed to cgo as [1]byte, so we write through it directly.

Jump to

Keyboard shortcuts

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