program

package
v0.8.20 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: Apache-2.0 Copyright Authors of Tetragon

Index

Constants

This section is empty.

Variables

View Source
var (
	KeepCollection bool
)

Functions

func GetProgramInfo

func GetProgramInfo(l *Program) (program, label, prog string)

func LoadKprobeProgram

func LoadKprobeProgram(bpfDir, mapDir string, load *Program, verbose int) error

func LoadMultiKprobeProgram

func LoadMultiKprobeProgram(bpfDir, mapDir string, load *Program, verbose int) error

func LoadOrCreatePinnedMap added in v0.8.20

func LoadOrCreatePinnedMap(pinPath string, mapSpec *ebpf.MapSpec) (*ebpf.Map, error)

func LoadProgram

func LoadProgram(
	bpfDir string,
	mapDirs []string,
	load *Program,
	withProgram AttachFunc,
	verbose int,
) error

func LoadRawTracepointProgram

func LoadRawTracepointProgram(bpfDir, mapDir string, load *Program, verbose int) error

func LoadTailCallProgram

func LoadTailCallProgram(bpfDir, mapDir string, load *Program, verbose int) error

func LoadTracepointProgram

func LoadTracepointProgram(bpfDir, mapDir string, load *Program, verbose int) error

Types

type AttachFunc

type AttachFunc func(*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) AttachFunc

func MultiKprobeAttach

func MultiKprobeAttach(load *Program) AttachFunc

func NoAttach

func NoAttach(load *Program) AttachFunc

func RawAttach

func RawAttach(targetFD int) AttachFunc

func RawTracepointAttach

func RawTracepointAttach(load *Program) AttachFunc

func TracepointAttach

func TracepointAttach(load *Program) AttachFunc

type LoadedCollection

type LoadedCollection struct {
	Programs map[string]*LoadedProgram
	Maps     map[string]*LoadedMap
}

type LoadedMap

type LoadedMap struct {
	ID ebpf.MapID
}

type LoadedProgram

type LoadedProgram struct {
	ID     ebpf.ProgramID
	MapIDs []ebpf.MapID
	Type   ebpf.ProgramType
}

type Map

type Map struct {
	Name      string
	PinName   string
	Prog      *Program
	PinState  State
	MapHandle *ebpf.Map
}

Map represents BPF maps.

func MapBuilder

func MapBuilder(name string, ld *Program) *Map

func MapBuilderPin

func MapBuilderPin(name, pin string, ld *Program) *Map

func (*Map) Close

func (m *Map) Close() error

func (*Map) GetFD

func (m *Map) GetFD() (int, error)

func (*Map) IsCompatibleWith

func (m *Map) IsCompatibleWith(spec *ebpf.MapSpec) error

func (*Map) LoadOrCreatePinnedMap added in v0.8.20

func (m *Map) LoadOrCreatePinnedMap(pinPath string, mapSpec *ebpf.MapSpec) error

func (*Map) LoadPinnedMap

func (m *Map) LoadPinnedMap(path string) error

func (*Map) New

func (m *Map) New(spec *ebpf.MapSpec) error

func (*Map) Pin

func (m *Map) Pin(path string) error

func (*Map) Unload

func (m *Map) Unload() error

type MapLoad

type MapLoad struct {
	Index uint32
	Name  string
	Load  func(m *ebpf.Map, index uint32) error
}

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

	// RetProbe indicates whether a kprobe is a kretprobe.
	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

	// Type is the type of BPF program. For example, tc, skb, tracepoint,
	// etc.
	Type      string
	LoadState State

	// LoaderData represents per-type specific fields.
	LoaderData interface{}

	MapLoad []*MapLoad

	PinMap map[string]string

	// available when program.KeepCollection is true
	LC *LoadedCollection

	MultiSymbols []string
	MultiCookies []uint64
	// contains filtered or unexported fields
}

Program reprents a BPF program.

func Builder

func Builder(
	objFile, attach, label, pinFile string,
	ty string,
) *Program
func (p *Program) Relink() error

func (*Program) SetLoaderData

func (p *Program) SetLoaderData(d interface{}) *Program

func (*Program) SetRetProbe

func (p *Program) SetRetProbe(ret bool) *Program
func (p *Program) Unlink() error

func (*Program) Unload

func (p *Program) Unload() error

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.

func Idle

func Idle() State

func (*State) IsLoaded

func (s *State) IsLoaded() bool

func (*State) RefDec

func (s *State) RefDec() int

func (*State) RefInc

func (s *State) RefInc()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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