pdump

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 20 Imported by: 1 module, 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

Overview

Package pdump implements the control plane service for packet dumping. This file defines PdumpService, which handles gRPC requests for configuring and managing packet capture modules (identified by name). It keeps the published configuration of every name and serves the capture streams reading it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend added in v0.1.0

type Backend interface {
	// UpdateModule builds a module config from the settings, links its
	// ring by name and publishes it.
	//
	// On error nothing stays allocated.
	UpdateModule(name string, settings Settings) (Module, error)
	// DeleteModule removes the module config from the dataplane. It never
	// touches the ring the config was linked to.
	DeleteModule(name string) error
}

Backend publishes and removes pdump module configs in shared memory.

func NewBackend added in v0.1.0

func NewBackend(agent *ffi.Agent, options ...BackendOption) Backend

NewBackend creates a backend over the agent's shared memory.

type BackendOption added in v0.1.0

type BackendOption func(*backendOptions)

BackendOption configures the shared-memory backend.

func WithBackendLog added in v0.1.0

func WithBackendLog(log *zap.Logger) BackendOption

WithBackendLog sets the logger for the shared-memory backend.

type Config

type Config struct {
	modulebase.BaseConfig `yaml:",inline"`
	DebugEBPF             bool `yaml:"debug_ebpf"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Default

func (m *Config) Default()

Default resets Config to DefaultConfig.

type Module added in v0.1.0

type Module interface {
	// Free releases the module config, reporting ffi.ErrStillReferenced
	// while a live generation still holds it.
	Free() error
}

Module is a published pdump module config.

It no longer exposes rings: a stream reads its capture's binding, which outlives any one module generation across a same-object update.

type Option

type Option = modulebase.Option

Option configures the PdumpModule constructor.

func WithLog

func WithLog(log *zap.Logger) Option

WithLog sets the logger for the pdump module.

type PdumpModule

type PdumpModule struct {
	*modulebase.Base
	// contains filtered or unexported fields
}

PdumpModule is a control-plane component of a packet dump module.

It also hosts the ring service. That service owns the standalone named rings created through this agent.

func NewPdumpModule

func NewPdumpModule(cfg *Config, options ...Option) (*PdumpModule, error)

func (*PdumpModule) Run

func (m *PdumpModule) Run(ctx context.Context) error

Run runs the module until the specified context is canceled. Implements the gateway.BackgroundService interface.

type PdumpService

type PdumpService struct {
	pdumppb.UnimplementedPdumpServiceServer
	// contains filtered or unexported fields
}

PdumpService provides packet capture functionality through a gRPC interface. It manages packet capture configurations and the bindings their streams read.

func NewPdumpService

func NewPdumpService(backend Backend, ringOwner RingOwner, options ...PdumpServiceOption) *PdumpService

NewPdumpService initializes a new packet capture service.

The ring owner resolves the ring names configs bind to; production passes the ring service this agent hosts, a test fakes it.

func (*PdumpService) DeleteConfig

DeleteConfig removes a packet capture configuration.

The ring the config was linked to is never deleted.

func (*PdumpService) ListConfigs

ListConfigs retrieves all configured packet capture modules.

func (*PdumpService) ReadDump

ReadDump streams captured packets from the specified packet capture module.

The stream continues until one of the following termination conditions occurs:

  • The client disconnects (context cancellation from the gRPC stream)
  • The service is shut down
  • An error occurs while sending a packet record on the stream
  • The configuration of this module is deleted or rebound to another ring

Every request reads its binding's ring through its own read positions, so concurrent ReadDump requests do not interfere with each other. The handler returns only after its readers have stopped reading those rings.

func (*PdumpService) SetConfig

SetConfig updates or creates packet capture configuration.

Only the config fields the request carries change. ring_name is required to create a config, keeps the bound ring when absent on an update, and is invalid when carried empty. A newly bound ring must exist and be at least the pdump minimum capacity, whatever the snaplen; a same-object update keeps its binding without a new check. On any failure the published config, its binding and its streams are left exactly as they were. An update with unchanged effective settings and the same ring object preserves the published config and capture budget.

func (*PdumpService) ShowConfig

ShowConfig retrieves the current configuration for a specific packet capture module.

func (*PdumpService) Shutdown

func (m *PdumpService) Shutdown()

Shutdown ends every active ReadDump stream.

Each handler returns only after the readers it started have stopped, so the shared memory may be released once the handlers have drained.

type PdumpServiceOption

type PdumpServiceOption func(*pdumpServiceOptions)

PdumpServiceOption configures a packet capture service.

func WithPdumpServiceLog

func WithPdumpServiceLog(log *zap.Logger) PdumpServiceOption

WithPdumpServiceLog sets the logger for a packet capture service.

type RingHandle added in v0.2.0

type RingHandle = ring.Handle

RingHandle identifies one ring from its create to its delete.

type RingLease added in v0.2.0

type RingLease interface {
	// Handle returns the handle this lease pins.
	//
	// A binding compares handles, not names, to tell a same-object update
	// from a rebind: a ring deleted and recreated under the same name
	// gets a new handle.
	Handle() RingHandle
	// Release removes this lease's block on the ring's delete.
	//
	// It is safe to call more than once.
	Release()
	// Capacity returns the size of each worker's data area in bytes.
	//
	// It is the bound a reader checks a record's length against to tell
	// a real frame from corruption.
	Capacity() uint32
	// Sources returns a record source per worker's ring, indexed by
	// worker, for a reader to read from.
	Sources() ([]cring.RecordSource, error)
}

RingLease is what a capture binding needs from an acquired ring.

It must be enough to tell whether two leases pin the same ring, to check a ring meets the pdump minimum capacity on bind and to bound a reader's records against that same capacity, to read the ring's sources and to let the ring go again. A production lease pins a ring hosted in this agent; a test fakes one directly, with no dataplane ring object underneath.

type RingOwner added in v0.2.0

type RingOwner interface {
	// LookupHandle returns the handle registered under a name.
	LookupHandle(name string) (RingHandle, bool)
	// Acquire blocks the delete of the named ring and returns a lease.
	//
	// It succeeds only if the name still maps to the given handle.
	Acquire(name string, handle RingHandle) (RingLease, error)
	// ReclaimDeferred frees the deleted rings whose generations have
	// drained, returning their memory to the agent.
	ReclaimDeferred()
}

RingOwner is where the pdump service looks up and pins its rings.

Production resolves rings in the ring service hosted in this agent. A test fakes it with in-memory record sources, since pdump's C library stubs DPDK and cannot link the real ring object's CGo harness.

type Settings added in v0.1.0

type Settings struct {
	Filter   string
	Mode     uint32
	Snaplen  uint32
	RingName string
	RatePPS  uint64
}

Settings are the capture parameters a module config is built from.

Settings carry the name of the pre-existing ring object the module captures into. It is always set on a published config: a config update fills it in before the backend ever sees an empty value.

Directories

Path Synopsis
pdumppb
v1

Jump to

Keyboard shortcuts

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