l3stack

package
v0.0.0-...-5426c23 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Package l3stack terminates raw IP flows from a virtual interface and hands their payload to l3session. It is an optional adapter: the rendr root module and target graph do not depend on a userspace IP stack.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Device  virtualif.FullDuplexCancellableDevice
	Router  l3ingress.FlowDecisionFunc
	Starter *l3session.Starter

	// FlowTable is optional. When nil, Gateway creates one around Router.
	FlowTable    *l3ingress.FlowTable
	OnParseError l3ingress.ParseErrorHandler
	OnFlowError  FlowErrorHandler

	TCPMaxInFlight int
	LinkQueue      int
	// TCPPeerReadyTimeout bounds each SYN's wait for the remote egress. Zero
	// uses l3session.DefaultTCPPeerReadyTimeout.
	TCPPeerReadyTimeout time.Duration

	// FlowLifetime controls automatic active-flow and closed-history reaping.
	// New normalizes and retains an immutable value copy.
	FlowLifetime FlowLifetimeTuning
}

Config assembles one virtual-interface ingress gateway.

type FlowErrorHandler

type FlowErrorHandler func(l3ingress.L3Identity, error)

FlowErrorHandler observes a flow-local failure. One rejected or failed flow does not terminate unrelated sessions or the virtual interface pump.

type FlowLifetimeTuning

type FlowLifetimeTuning struct {
	// UDPIdle is the maximum interval without ingress or a delivered reply.
	// Zero selects 30 seconds.
	UDPIdle time.Duration
	// TCPUnestablishedIdle bounds pending, denied, orphan, and otherwise
	// unestablished TCP state. Zero selects 10 seconds. Established TCP is
	// retained until its own transport lifecycle closes it.
	TCPUnestablishedIdle time.Duration
	// ClosedRetention bounds diagnostic closed-flow snapshots. Zero selects
	// five minutes.
	ClosedRetention time.Duration
}

FlowLifetimeTuning controls bounded L3 flow retention. Every duration is mandatory: zero selects its default and negative values are rejected.

func DefaultFlowLifetimeTuning

func DefaultFlowLifetimeTuning() FlowLifetimeTuning

DefaultFlowLifetimeTuning returns the immutable defaults copied by New.

type Gateway

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

Gateway owns one gVisor TCP endpoint domain plus the rendr per-flow relays. It does not own Device; the embedding application controls interface policy and lifetime.

func New

func New(config Config) (*Gateway, error)

New creates an idle gateway. Run performs packet I/O.

func (*Gateway) Close

func (g *Gateway) Close() error

Close cancels Run and waits for all flow relays. It does not close Device.

func (*Gateway) HandlePacket

func (g *Gateway) HandlePacket(ctx context.Context, event l3ingress.PacketEvent) error

HandlePacket implements l3ingress.PacketHandler.

func (*Gateway) ReapIdle

func (g *Gateway) ReapIdle(cutoff time.Time) []l3ingress.FlowSnapshot

ReapIdle applies protocol-aware idle semantics with one explicit cutoff. It is retained as a deterministic administrative hook; Run owns automatic scheduling with the configured protocol-specific lifetimes.

func (*Gateway) Run

func (g *Gateway) Run(ctx context.Context) error

Run pumps packets until ctx is canceled, Device closes, or a device-level error occurs. Flow-local failures are reported through OnFlowError.

Jump to

Keyboard shortcuts

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