pdump

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: 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 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 with fresh rings from the settings
	// and publishes it.
	//
	// On error nothing stays allocated.
	UpdateModule(name string, settings Settings) (Module, error)
	// DeleteModule removes the module config from the dataplane.
	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 {
	ffi.AttachConfig `yaml:",inline"`

	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 Module added in v0.1.0

type Module interface {
	// Rings returns the per-worker rings, valid until Free succeeds.
	Rings() []Ring
	// Free releases the module config and its rings, reporting
	// ffi.ErrStillReferenced while a live generation still holds it.
	Free() error
}

Module is a published pdump module config with its capture rings.

type ModuleConfig

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

func NewModuleConfig

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

func (*ModuleConfig) AsFFIModule

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

func (*ModuleConfig) Free

func (m *ModuleConfig) Free() error

Free destroys the module config, or reports ffi.ErrStillReferenced while a live generation still holds it. Safe to call multiple times.

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) SetupRings added in v0.1.0

func (m *ModuleConfig) SetupRings(size uint32) ([]Ring, error)

SetupRings allocates a capture ring of the given size for every worker.

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(backend Backend, 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.

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 updated or deleted

Every request reads the rings 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.

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 Ring added in v0.1.0

type Ring struct {
	WriteIdx    *uint64
	ReadableIdx *uint64
	Data        []byte
}

Ring is one worker's capture ring inside the module config memory.

type Settings added in v0.1.0

type Settings struct {
	Filter   string
	Mode     uint32
	Snaplen  uint32
	RingSize uint32
}

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

Directories

Path Synopsis
pdumppb
v1

Jump to

Keyboard shortcuts

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