pdump

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: 25 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 interacts with data plane agents via FFI (Foreign Function Interface) to apply capture settings (filters, mode, snaplen, ring buffer size) and to facilitate reading captured packets from shared ring buffers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// InstanceID specifies which dataplane instance this module serves.
	//
	// Required: a listed module must set it explicitly, even to 0.
	InstanceID xcfg.Required[uint32] `yaml:"instance_id"`
	// MemoryPath is the path to the shared-memory file that is used to
	// communicate with dataplane.
	MemoryPath xcfg.NonEmptyString `yaml:"memory_path"`
	// MemoryRequirements is the amount of memory that is required for a single
	// transaction.
	MemoryRequirements xcfg.NonZero[datasize.ByteSize] `yaml:"memory_requirements"`

	Endpoint  xcfg.NonEmptyString `yaml:"endpoint"`
	DebugEBPF bool                `yaml:"debug_ebpf"`
}

func DefaultConfig

func DefaultConfig() *Config

func (*Config) Default

func (m *Config) Default()

Default resets Config to DefaultConfig.

type ModuleConfig

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

func NewModuleConfig

func NewModuleConfig(
	agent *ffi.Agent,
	name string,
	options ...ModuleConfigOption,
) (*ModuleConfig, error)

func (*ModuleConfig) AsFFIModule

func (m *ModuleConfig) AsFFIModule() ffi.ModuleConfig

func (*ModuleConfig) Free

func (m *ModuleConfig) Free() error

Free destroys the module config when it is dangling — referenced by no live configuration generation — and reports nil. While a live generation still references it the free is refused with ffi.ErrStillReferenced and the handle stays usable: the caller must remember it and free it again once the generations holding it drain. Safe to call multiple times: subsequent calls are no-ops reporting nil.

func (*ModuleConfig) SetDumpMode

func (m *ModuleConfig) SetDumpMode(pbMode uint32) error

func (*ModuleConfig) SetFilter

func (m *ModuleConfig) SetFilter(filter string) error

func (*ModuleConfig) SetSnapLen

func (m *ModuleConfig) SetSnapLen(snaplen uint32) error

func (*ModuleConfig) SetupRing

func (m *ModuleConfig) SetupRing(ring *ringBuffer) error

type ModuleConfigOption

type ModuleConfigOption func(*moduleConfigOptions)

ModuleConfigOption configures a pdump module configuration.

func WithModuleConfigLog

func WithModuleConfigLog(log *zap.Logger) ModuleConfigOption

WithModuleConfigLog sets the logger for a pdump module configuration.

type Option

type Option func(*moduleOptions)

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 {
	// contains filtered or unexported fields
}

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

func NewPdumpModule

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

func (*PdumpModule) Close

func (m *PdumpModule) Close() error

Close closes the module.

func (*PdumpModule) Endpoint

func (m *PdumpModule) Endpoint() string

func (*PdumpModule) Name

func (m *PdumpModule) Name() string

func (*PdumpModule) RegisterService

func (m *PdumpModule) RegisterService(server *grpc.Server)

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.

func (*PdumpModule) ServicesNames

func (m *PdumpModule) ServicesNames() []string

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 ring buffers.

func NewPdumpService

func NewPdumpService(agent *ffi.Agent, options ...PdumpServiceOption) *PdumpService

NewPdumpService initializes a new packet capture service.

func (*PdumpService) DeleteConfig

DeleteConfig removes a packet capture configuration.

func (*PdumpService) ListConfigs

ListConfigs retrieves all configured packet capture modules.

func (*PdumpService) ReadDump

ReadDump streams captured packets from the specified packet capture module. This function establishes a continuous stream of packet data by:

  1. Validating the target module (name)
  2. Retrieving and cloning the ring buffer configuration for safe concurrent access
  3. Spawning ring buffer readers that continuously monitor shared memory
  4. Forwarding captured packet records to the gRPC stream

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 (signaled via m.quitCh)
  • An error occurs while sending a packet record on the stream
  • The configuration of this module is updated (updateModuleConfig terminates matching readers)

Note: Ring buffer readers operate on a cloned configuration to ensure thread safety and prevent interference between concurrent ReadDump requests.

func (*PdumpService) ReclaimDeferred

func (m *PdumpService) ReclaimDeferred()

ReclaimDeferred retries every deferred config, dropping the ones whose generations have drained and keeping the rest deferred. It is the reclamation handler for this module's superseded configs; the service itself runs it after each successful publish, and anything else may call it at any time.

func (*PdumpService) SetConfig

SetConfig updates or creates packet capture configuration. Supports partial updates via UpdateMask.

func (*PdumpService) ShowConfig

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

func (*PdumpService) Shutdown

func (m *PdumpService) Shutdown()

Shutdown signals a graceful shutdown to all active ReadDump streams.

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.

Jump to

Keyboard shortcuts

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