registry

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrStarted     = errors.New("registry has already been started")
	ErrNotStarted  = errors.New("registry has not yet been started")
	ErrMapNotFound = errors.New("MapSpec not found")
)
View Source
var Cell = cell.Module(
	"registry",
	"Registry of datapath MapSpecs that can be modified during Hive construction",
	cell.Provide(provide),
)

Functions

This section is empty.

Types

type MapRegistry

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

MapRegistry contains [ebpf.MapSpec]s for all pinned maps in the datapath.

The registry allows Cells to provide [MapSpecPatch]es during Hive construction, e.g. for changing MaxEntries of a map based on configuration parameters. Only select fields can be modified, see MapSpecPatch for details.

Once the registry has been started, MapSpecs can only be retrieved but not modified. Any packages which need to create maps at runtime should obtain the MapSpecs from this registry.

func (*MapRegistry) Get

func (r *MapRegistry) Get(name string) (*ebpf.MapSpec, error)

Get returns a copy of the MapSpec for the given map name. Must be called during Hive start in cell.Lifecycle.Start or cell.Hook.OnStart, otherwise returns ErrNotStarted.

Returns ErrMapNotFound if no map with the given name exists.

func (*MapRegistry) GetPatch

func (r *MapRegistry) GetPatch(name string) (*MapSpecPatch, error)

GetPatch returns a MapSpecPatch for the given map name if MapRegistry.Modify was called by a Cell during startup. Must be called during Hive start in cell.Lifecycle.Start or cell.Hook.OnStart, otherwise returns ErrNotStarted.

This is intended for the loader to apply patches during Collection loading.

Returns ErrMapNotFound if no map with the given name exists or if MapRegistry.Modify was not called for the map.

func (*MapRegistry) Modify

func (r *MapRegistry) Modify(name string, modify func(*MapSpecPatch)) error

Modify allows modifying the MapSpec for the given map name. Must be called during Hive construction in cell.Provide or cell.Invoke, otherwise returns ErrStarted.

Returns ErrMapNotFound if no map with the given name exists.

type MapSpecPatch

type MapSpecPatch struct {
	MaxEntries uint32
	Flags      uint32

	InnerMap *MapSpecPatch
}

MapSpecPatch allows modifying select fields of an ebpf.MapSpec.

func (*MapSpecPatch) Apply

func (p *MapSpecPatch) Apply(spec *ebpf.MapSpec)

Apply applies the patch to the given MapSpec.

Jump to

Keyboard shortcuts

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