program

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 14 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 LoadLSMProgram added in v0.10.0

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

func LoadMultiKprobeProgram added in v0.8.3

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

func LoadOrCreatePinnedMap added in v0.9.0

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

func LoadProgram

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

func LoadRawTracepointProgram

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

func LoadTracepointProgram

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

func LoadTracingProgram added in v0.10.0

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

func LoadUprobeProgram added in v0.9.0

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

Types

type AttachFunc

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 LSMAttach added in v0.10.0

func LSMAttach() AttachFunc

func MultiKprobeAttach added in v0.8.3

func MultiKprobeAttach(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 TracepointAttach

func TracepointAttach(load *Program) AttachFunc

func TracingAttach added in v0.10.0

func TracingAttach() AttachFunc

func UprobeAttach added in v0.9.0

func UprobeAttach(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 added in v0.9.0

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

func (*Map) LoadOrCreatePinnedMap added in v0.9.0

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) SetInnerMaxEntries added in v0.11.0

func (m *Map) SetInnerMaxEntries(max int)

func (*Map) SetMaxEntries added in v0.9.0

func (m *Map) SetMaxEntries(max int)

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 MultiKprobeAttachData added in v0.9.0

type MultiKprobeAttachData struct {
	Symbols   []string
	Cookies   []uint64
	Overrides []string
}

type OpenFunc added in v0.11.0

type OpenFunc func(*ebpf.CollectionSpec) error

func KprobeOpen added in v0.11.0

func KprobeOpen(load *Program) OpenFunc

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{}

	// AttachData represents specific data for attaching probe
	AttachData interface{}

	MapLoad []*MapLoad

	PinMap map[string]string

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

	MaxEntriesMap      map[string]uint32
	MaxEntriesInnerMap map[string]uint32
	// 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) SetAttachData added in v0.9.0

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

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()

type UprobeAttachData added in v0.9.0

type UprobeAttachData struct {
	Path   string
	Symbol string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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