ebpf

package
v1.18.4 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 11 Imported by: 5

Documentation

Overview

Package ebpf provides functions that allow golang programs to interact with ebpf maps by wrapping the cilium/ebpf library. +groupName=pkg

Index

Constants

View Source
const (
	Hash       = ciliumebpf.Hash
	PerCPUHash = ciliumebpf.PerCPUHash
	Array      = ciliumebpf.Array
	HashOfMaps = ciliumebpf.HashOfMaps
	LPMTrie    = ciliumebpf.LPMTrie
	LRUHash    = ciliumebpf.LRUHash
	LRUCPUHash = ciliumebpf.LRUCPUHash
	RingBuf    = ciliumebpf.RingBuf

	PinNone   = ciliumebpf.PinNone
	PinByName = ciliumebpf.PinByName
)

Variables

View Source
var (
	ErrKeyNotExist = ciliumebpf.ErrKeyNotExist
)

Functions

func GetOpenMaps

func GetOpenMaps() []*models.BPFMap

GetOpenMaps returns a slice of all open BPF maps. This is identical to calling GetMap() on all open maps.

Types

type IterateCallback

type IterateCallback func(key, value any)

IterateCallback represents the signature of the callback function expected by the IterateWithCallback method, which in turn is used to iterate all the keys/values of a map.

type Map

type Map struct {
	*ciliumebpf.Map
	// contains filtered or unexported fields
}

Map represents an eBPF map.

func LoadPinnedMap

func LoadPinnedMap(logger *slog.Logger, fileName string) (*Map, error)

LoadPinnedMap wraps cilium/ebpf's LoadPinnedMap.

func LoadRegisterMap

func LoadRegisterMap(logger *slog.Logger, mapName string) (*Map, error)

LoadRegisterMap loads the specified map from a bpffs pin path and registers its handle in the package-global map register.

func MapFromID

func MapFromID(logger *slog.Logger, id int) (*Map, error)

func NewMap

func NewMap(logger *slog.Logger, spec *MapSpec) *Map

NewMap creates a new Map object.

func (*Map) GetModel

func (m *Map) GetModel() *models.BPFMap

GetModel returns a BPF map in the representation served via the API.

func (*Map) IsEmpty added in v1.17.0

func (m *Map) IsEmpty() bool

func (*Map) IterateWithCallback

func (m *Map) IterateWithCallback(key, value any, cb IterateCallback) error

IterateWithCallback iterates through all the keys/values of a map, passing each key/value pair to the cb callback.

func (*Map) OpenOrCreate

func (m *Map) OpenOrCreate() error

OpenOrCreate tries to open or create the eBPF map identified by the spec in the Map object.

type MapSpec

type MapSpec = ciliumebpf.MapSpec

type PinType

type PinType = ciliumebpf.PinType

Jump to

Keyboard shortcuts

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