program

package
v1.3.0-pre.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KeepCollection bool
)

Functions

func GetProgramInfo

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

func LoadFmodRetProgram added in v1.1.0

func LoadFmodRetProgram(bpfDir string, load *Program, progName string, verbose int) error

func LoadKprobeProgram

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

func LoadKprobeProgramAttachMany added in v1.0.0

func LoadKprobeProgramAttachMany(bpfDir string, load *Program, syms []string, verbose int) error

func LoadLSMProgram added in v0.10.0

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

func LoadLSMProgramSimple added in v1.2.0

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

func LoadMultiKprobeProgram added in v0.8.3

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

func LoadMultiUprobeProgram added in v1.1.0

func LoadMultiUprobeProgram(bpfDir 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,
	load *Program,
	attach AttachFunc,
	verbose int,
) error

func LoadProgramOpts added in v1.2.0

func LoadProgramOpts(
	bpfDir string,
	load *Program,
	opts *LoadOpts,
	verbose int,
) error

func LoadRawTracepointProgram

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

func LoadTracepointProgram

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

func LoadTracingProgram added in v0.10.0

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

func LoadUprobeProgram added in v0.9.0

func LoadUprobeProgram(bpfDir 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 KprobeAttachMany added in v1.0.0

func KprobeAttachMany(load *Program, syms []string, 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 MultiUprobeAttach added in v1.1.0

func MultiUprobeAttach(load *Program) 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, bpfDir string) AttachFunc

func TracingAttach added in v0.10.0

func TracingAttach() AttachFunc

func UprobeAttach added in v0.9.0

func UprobeAttach(load *Program) AttachFunc

type LoadOpts added in v1.2.0

type LoadOpts struct {
	Attach AttachFunc
	Open   OpenFunc
}

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
	Entries      MaxEntries
	InnerEntries MaxEntries
}

Map represents BPF maps.

func MapBuilder

func MapBuilder(name string, lds ...*Program) *Map

func MapBuilderPin

func MapBuilderPin(name, pin string, lds ...*Program) *Map

func (*Map) Close

func (m *Map) Close() error

func (*Map) GetFD

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

func (*Map) GetMaxEntries added in v1.2.0

func (m *Map) GetMaxEntries() (uint32, bool)

func (*Map) GetMaxInnerEntries added in v1.2.0

func (m *Map) GetMaxInnerEntries() (uint32, bool)

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 MaxEntries added in v1.2.0

type MaxEntries struct {
	Val uint32
	Set bool
}

type MultiKprobeAttachData added in v0.9.0

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

type MultiUprobeAttachData added in v1.1.0

type MultiUprobeAttachData struct {
	// Path -> []{Symbol,Cookie}
	Attach map[string]*MultiUprobeAttachSymbolsCookies
}

type MultiUprobeAttachSymbolsCookies added in v1.1.0

type MultiUprobeAttachSymbolsCookies struct {
	Symbols []string
	Cookies []uint64
}

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

func LSMOpen added in v1.2.0

func LSMOpen(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
	OverrideFmodRet bool

	// Needs attached link to be pinned
	PinLink 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]*Map

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

	RewriteConstants map[string]interface{}

	// 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
	// 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) SetPolicy added in v1.2.0

func (p *Program) SetPolicy(policy string) *Program

func (*Program) SetRetProbe

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

func (*Program) SetTailCall added in v1.2.0

func (p *Program) SetTailCall(prefix string, m *Map) *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