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 ¶
- type Backend
- type BackendOption
- type Config
- type Module
- type ModuleConfig
- func (m *ModuleConfig) AsFFIModule() ffi.ModuleConfig
- func (m *ModuleConfig) Free() error
- func (m *ModuleConfig) SetDumpMode(pbMode uint32) error
- func (m *ModuleConfig) SetFilter(filter string) error
- func (m *ModuleConfig) SetSnapLen(snaplen uint32) error
- func (m *ModuleConfig) SetupRings(size uint32) ([]Ring, error)
- type Option
- type PdumpModule
- type PdumpService
- func (m *PdumpService) DeleteConfig(ctx context.Context, request *pdumppb.DeleteConfigRequest) (*pdumppb.DeleteConfigResponse, error)
- func (m *PdumpService) ListConfigs(ctx context.Context, request *pdumppb.ListConfigsRequest) (*pdumppb.ListConfigsResponse, error)
- func (m *PdumpService) ReadDump(req *pdumppb.ReadDumpRequest, ...) error
- func (m *PdumpService) SetConfig(ctx context.Context, request *pdumppb.SetConfigRequest) (*pdumppb.SetConfigResponse, error)
- func (m *PdumpService) ShowConfig(ctx context.Context, request *pdumppb.ShowConfigRequest) (*pdumppb.ShowConfigResponse, error)
- func (m *PdumpService) Shutdown()
- type PdumpServiceOption
- type Ring
- type Settings
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
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 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) 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 ¶
func (m *PdumpService) DeleteConfig( ctx context.Context, request *pdumppb.DeleteConfigRequest, ) (*pdumppb.DeleteConfigResponse, error)
DeleteConfig removes a packet capture configuration.
func (*PdumpService) ListConfigs ¶
func (m *PdumpService) ListConfigs( ctx context.Context, request *pdumppb.ListConfigsRequest, ) (*pdumppb.ListConfigsResponse, error)
ListConfigs retrieves all configured packet capture modules.
func (*PdumpService) ReadDump ¶
func (m *PdumpService) ReadDump(req *pdumppb.ReadDumpRequest, stream grpc.ServerStreamingServer[pdumppb.Record]) error
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 ¶
func (m *PdumpService) SetConfig( ctx context.Context, request *pdumppb.SetConfigRequest, ) (*pdumppb.SetConfigResponse, error)
SetConfig updates or creates packet capture configuration. Only the config fields the request carries change.
func (*PdumpService) ShowConfig ¶
func (m *PdumpService) ShowConfig( ctx context.Context, request *pdumppb.ShowConfigRequest, ) (*pdumppb.ShowConfigResponse, error)
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.