fwstate

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2026 License: Apache-2.0 Imports: 11 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

This section is empty.

Variables

This section is empty.

Functions

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 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 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 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 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