Documentation
¶
Overview ¶
SPDX-License-Identifier: Apache-2.0 Copyright Authors of Tetragon
Index ¶
- func AddGlobalMap(name string)
- func DeleteGlobMap(name string)
- func GetMaxEntriesPinnedMap(pinPath string) (uint32, error)
- func GetProgramInfo(l *Program) (program, label, prog string)
- func IsGlobalMap(name string) bool
- func LinkPin(lnk link.Link, bpfDir string, load *Program, extra ...string) error
- func LoadFmodRetProgram(bpfDir string, load *Program, maps []*Map, progName string, verbose int) error
- func LoadKprobeProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadKprobeProgramAttachMany(bpfDir string, load *Program, syms []string, maps []*Map, verbose int) error
- func LoadLSMProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadLSMProgramSimple(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadMultiKprobeProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadMultiUprobeProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadOrCreatePinnedMap(pinPath string, mapSpec *ebpf.MapSpec, create bool) (*ebpf.Map, error)
- func LoadProgram(bpfDir string, load *Program, maps []*Map, attach AttachFunc, verbose int) error
- func LoadProgramOpts(bpfDir string, load *Program, opts *LoadOpts, verbose int) error
- func LoadRawTracepointProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadSeccompProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadTracepointProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadTracingProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func LoadUprobeProgram(bpfDir string, load *Program, maps []*Map, verbose int) error
- func PolicyMapPath(mapDir, policy, name string) string
- type AttachFunc
- func KprobeAttach(load *Program, bpfDir string) AttachFunc
- func KprobeAttachMany(load *Program, syms []string, bpfDir string) AttachFunc
- func LSMAttach(load *Program, bpfDir string) AttachFunc
- func MultiKprobeAttach(load *Program, bpfDir string) AttachFunc
- func MultiUprobeAttach(load *Program, bpfDir string) AttachFunc
- func NoAttach() AttachFunc
- func RawAttach(targetFD int) AttachFunc
- func RawAttachWithFlags(targetFD int, flags uint32) AttachFunc
- func RawTracepointAttach(load *Program) AttachFunc
- func SeccompAttach() AttachFunc
- func TracepointAttach(load *Program, bpfDir string) AttachFunc
- func TracingAttach(load *Program, bpfDir string) AttachFunc
- func UprobeAttach(load *Program, bpfDir string) AttachFunc
- type LoadOpts
- type LoadedCollection
- type LoadedMap
- type LoadedProgram
- type Map
- func MapBuilder(name string, lds ...*Program) *Map
- func MapBuilderOpts(name string, opts MapOpts, lds ...*Program) *Map
- func MapBuilderPin(name, pinName string, lds ...*Program) *Map
- func MapBuilderPolicy(name string, lds ...*Program) *Map
- func MapBuilderProgram(name string, lds ...*Program) *Map
- func MapBuilderRodataConfigAtInit(elfName, pinName string, load func() (any, error), lds ...*Program) *Map
- func MapBuilderSensor(name string, lds ...*Program) *Map
- func MapBuilderType(name string, ty MapType, lds ...*Program) *Map
- func MapShared(name string, lds ...*Program) *Map
- func MapSharedPin(name, pinName string, lds ...*Program) *Map
- func MapUser(name string, prog *Program) *Map
- func MapUserFrom(m *Map) *Map
- func MapUserPolicy(name string, prog *Program) *Map
- func MapUserProgram(name string, prog *Program) *Map
- func MapUserSensor(name string, prog *Program) *Map
- func (m *Map) ClearFlag(flag uint32)
- func (m *Map) Close() error
- func (m *Map) GetFD() (int, error)
- func (m *Map) GetFlags() uint32
- func (m *Map) GetMaxEntries() (uint32, bool)
- func (m *Map) GetMaxInnerEntries() (uint32, bool)
- func (m *Map) IsCompatibleWith(spec *ebpf.MapSpec) error
- func (m *Map) IsOwner() bool
- func (m *Map) IsShared() bool
- func (m *Map) LoadOrCreatePinnedMap(pinPath string, mapSpec *ebpf.MapSpec) error
- func (m *Map) LoadPinnedMap(path string) error
- func (m *Map) New(spec *ebpf.MapSpec) error
- func (m *Map) Pin(path string) error
- func (m *Map) SetFlag(flag uint32)
- func (m *Map) SetFlags(flags uint32)
- func (m *Map) SetInnerMaxEntries(maximum int)
- func (m *Map) SetMaxEntries(maximum int)
- func (m *Map) String() string
- func (m *Map) Unload(unpin bool) error
- type MapLoad
- type MapOpts
- type MapType
- type MaxEntries
- type MissingConstantsError
- type MultiKprobeAttachData
- type MultiUprobeAttachData
- type MultiUprobeAttachSymbolsCookies
- type OpenFunc
- type Program
- func (p *Program) CopyLoadedMapsInfo(dst map[int]bpf.ExtendedMapInfo)
- func (p *Program) Relink() error
- func (p *Program) SetAttachData(d any) *Program
- func (p *Program) SetLoadedMapsInfo(m map[int]bpf.ExtendedMapInfo)
- func (p *Program) SetLoaderData(d any) *Program
- func (p *Program) SetPolicy(policy string) *Program
- func (p *Program) SetRetProbe(ret bool) *Program
- func (p *Program) SetTailCall(prefix string, m *Map) *Program
- func (p *Program) String() string
- func (p *Program) Unlink() error
- func (p *Program) Unload(unpin bool) error
- type State
- type TracingAttachData
- type UprobeAttachData
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGlobalMap ¶ added in v1.2.1
func AddGlobalMap(name string)
func DeleteGlobMap ¶ added in v1.2.1
func DeleteGlobMap(name string)
func GetMaxEntriesPinnedMap ¶ added in v1.2.1
func GetProgramInfo ¶
func IsGlobalMap ¶ added in v1.2.1
func LoadFmodRetProgram ¶ added in v1.1.0
func LoadKprobeProgram ¶
func LoadKprobeProgramAttachMany ¶ added in v1.0.0
func LoadLSMProgram ¶ added in v0.10.0
func LoadLSMProgramSimple ¶ added in v1.2.0
func LoadMultiKprobeProgram ¶ added in v0.8.3
func LoadMultiUprobeProgram ¶ added in v1.1.0
func LoadOrCreatePinnedMap ¶ added in v0.9.0
func LoadProgram ¶
func LoadProgramOpts ¶ added in v1.2.0
func LoadSeccompProgram ¶ added in v1.5.0
func LoadTracepointProgram ¶
func LoadTracingProgram ¶ added in v0.10.0
func LoadUprobeProgram ¶ added in v0.9.0
func PolicyMapPath ¶ added in v1.2.1
Types ¶
type AttachFunc ¶
type AttachFunc func(*ebpf.Collection, *ebpf.CollectionSpec, *ebpf.Program, *ebpf.ProgramSpec) (unloader.Unloader, error)
AttachFunc is the type for the various attachment functions. The function is given the program and it's up to it to close it.
func KprobeAttach ¶
func KprobeAttach(load *Program, bpfDir string) AttachFunc
func KprobeAttachMany ¶ added in v1.0.0
func KprobeAttachMany(load *Program, syms []string, bpfDir string) AttachFunc
func LSMAttach ¶ added in v0.10.0
func LSMAttach(load *Program, bpfDir string) AttachFunc
func MultiKprobeAttach ¶ added in v0.8.3
func MultiKprobeAttach(load *Program, bpfDir string) AttachFunc
func MultiUprobeAttach ¶ added in v1.1.0
func MultiUprobeAttach(load *Program, bpfDir string) AttachFunc
func NoAttach ¶
func NoAttach() AttachFunc
func RawAttach ¶
func RawAttach(targetFD int) AttachFunc
func RawAttachWithFlags ¶ added in v0.10.0
func RawAttachWithFlags(targetFD int, flags uint32) AttachFunc
func RawTracepointAttach ¶
func RawTracepointAttach(load *Program) AttachFunc
func SeccompAttach ¶ added in v1.5.0
func SeccompAttach() AttachFunc
func TracepointAttach ¶
func TracepointAttach(load *Program, bpfDir string) AttachFunc
func TracingAttach ¶ added in v0.10.0
func TracingAttach(load *Program, bpfDir string) AttachFunc
func UprobeAttach ¶ added in v0.9.0
func UprobeAttach(load *Program, bpfDir string) AttachFunc
type LoadOpts ¶ added in v1.2.0
type LoadOpts struct {
Attach AttachFunc
Open OpenFunc
Maps []*Map
}
type LoadedCollection ¶
type LoadedCollection struct {
Programs map[string]*LoadedProgram
Maps map[string]*LoadedMap
}
type LoadedProgram ¶
type Map ¶
type Map struct {
Name string
PinName string
PinPath string
Prog *Program
PinState State
MapHandle *ebpf.Map
Entries MaxEntries
InnerEntries MaxEntries
Flags uint32
Type MapType
Owner bool
// Configure prepares a copied map specification before the pinned map is
// opened or created. It must not change fields, load, pin, or unpin maps.
Configure func(spec *ebpf.MapSpec) error
// Validate checks state which isn't covered by MapSpec.Compatible.
Validate func(m *ebpf.Map, spec *ebpf.MapSpec) error
}
Map represents BPF maps.
Note there are restriction (no dots) on what the bpffs file name can contain, so Map holds two names: Name - ELF name, map's ebpf program handle. PinName - bpffs filename, it may differ from the ELF map name.
func MapBuilder ¶
func MapBuilderOpts ¶ added in v1.2.1
func MapBuilderPin ¶
MapBuilderPin creates a global map with distinct ELF and bpffs names.
func MapBuilderPolicy ¶ added in v1.2.1
func MapBuilderProgram ¶ added in v1.2.1
func MapBuilderRodataConfigAtInit ¶ added in v1.8.0
func MapBuilderRodataConfigAtInit(elfName, pinName string, load func() (any, error), lds ...*Program) *Map
MapBuilderRodataConfigAtInit creates a shared, read-only, frozen configuration map with the given ELF and pin names, populated by load func.
load must return a fixed-layout struct usable with encoding/binary.Write (fixed-width integer fields and fixed-size arrays thereof only - no strings, slices, maps, or pointers). The encoded byte length of the returned value must exactly match the compiled size of the corresponding ".rodata.<name>" section in the target BPF object, including any C-side padding.
It must only be called at init time (e.g. assigned to a package-level var, as RodataConfigMap is).
func MapBuilderSensor ¶ added in v1.2.1
func MapBuilderType ¶ added in v1.2.1
func MapSharedPin ¶ added in v1.8.0
MapSharedPin creates a shared global map with distinct ELF and bpffs names.
func MapUserFrom ¶ added in v1.4.0
func MapUserPolicy ¶ added in v1.2.1
func MapUserProgram ¶ added in v1.2.1
func MapUserSensor ¶ added in v1.2.1
func (*Map) GetMaxEntries ¶ added in v1.2.0
func (*Map) GetMaxInnerEntries ¶ added in v1.2.0
func (*Map) IsCompatibleWith ¶ added in v0.9.0
func (*Map) LoadOrCreatePinnedMap ¶ added in v0.9.0
func (*Map) LoadPinnedMap ¶
func (*Map) SetInnerMaxEntries ¶ added in v0.11.0
func (*Map) SetMaxEntries ¶ added in v0.9.0
type MaxEntries ¶ added in v1.2.0
type MissingConstantsError ¶ added in v1.2.1
type MissingConstantsError struct {
// The constants missing from .rodata.
Constants []string
}
MissingConstantsError is returned by [rewriteConstants].
func (*MissingConstantsError) Error ¶ added in v1.2.1
func (m *MissingConstantsError) Error() string
type MultiKprobeAttachData ¶ added in v0.9.0
type MultiUprobeAttachData ¶ added in v1.1.0
type MultiUprobeAttachData struct {
// linkPath -> []{Symbol,Cookie}
Attach map[string]*MultiUprobeAttachSymbolsCookies
}
type MultiUprobeAttachSymbolsCookies ¶ added in v1.1.0
type OpenFunc ¶ added in v0.11.0
type OpenFunc func(*ebpf.CollectionSpec) error
func KprobeOpen ¶ added in v0.11.0
func TracingOpen ¶ added in v1.7.0
func UprobeOpen ¶ added in v1.6.0
type Program ¶
type Program struct {
// Name is the name of the BPF object file.
Name string
// Attach is the attachment point, e.g. the kernel function.
Attach string
// Label is the program section name to load from program.
Label string
// PinPath is the pinned path to this program. Note this is a relative path
// based on the BPF directory FGS is running under.
PinPath string
// PinName
PinName string
// RetProbe indicates whether a kprobe/uprobe is a kretprobe/uretprobe
RetProbe bool
// ErrorFatal indicates whether a program must load and fatal otherwise.
// Most program will set this to true. For example, kernel functions hooks
// may change across verions so different names are attempted, hence
// avoiding fataling when the first attempt fails.
ErrorFatal bool
// Needs override bpf program
Override bool
OverrideFmodRet bool
// Needs sleepable offload bpf program
SleepableOffload bool
// Needs sleepable preload bpf program
SleepablePreload bool
// Type is the type of BPF program. For example, tc, skb, tracepoint,
// etc.
Type string
LoadState State
// LoaderData represents per-type specific fields.
LoaderData any
// AttachData represents specific data for attaching probe
AttachData any
// Functions to call after loading maps to populate them
MapLoad []*MapLoad
PinMap map[string]*Map
// available when option.Config.KeepCollection is true
LC *LoadedCollection
// Initialized map of constants to be populated in the program at
// loading time.
RewriteConstants map[string]any
// Type information used for CO-RE relocations.
KernelTypes *btf.Spec
// Tail call prefix/map
TcPrefix string
TcMap *Map
Link link.Link
Prog *ebpf.Program
// policy name the program belongs to
Policy string
// RewriteProg allows rewriting bpf programs before they are loaded.
// This is currently used for generated code for cel expressions, but can be extended to
// other uses.
RewriteProg map[string]func(prog *ebpf.ProgramSpec) error
// contains filtered or unexported fields
}
Program reprents a BPF program.
func (*Program) CopyLoadedMapsInfo ¶ added in v1.8.0
func (p *Program) CopyLoadedMapsInfo(dst map[int]bpf.ExtendedMapInfo)
CopyLoadedMapsInfo copies the program's loadedMapsInfo entries into dst under the program's read lock. Used by Sensor.TotalMemlock and any other reader to avoid racing with concurrent load/unload. dst must be non-nil; the caller owns it and merges entries from one or more programs into it.
func (*Program) SetAttachData ¶ added in v0.9.0
func (*Program) SetLoadedMapsInfo ¶ added in v1.8.0
func (p *Program) SetLoadedMapsInfo(m map[int]bpf.ExtendedMapInfo)
SetLoadedMapsInfo replaces the program's loadedMapsInfo map under the program's lock. Callers that build the map incrementally should do so in a local map and pass it here once, rather than mutating the field directly. Pass nil to clear (e.g. on unload).
func (*Program) SetLoaderData ¶
func (*Program) SetRetProbe ¶
func (*Program) SetTailCall ¶ added in v1.2.0
type State ¶
type State struct {
// contains filtered or unexported fields
}
State represents the state of a BPF program or map.
NB: Currently there is no case where we attempt to load a program that is already loaded. If this changes, we can use the count as a reference count to track users of a bpf program.
type TracingAttachData ¶ added in v1.7.0
type TracingAttachData struct {
AttachTo string
}