Documentation
¶
Overview ¶
Package bpf exposes Go-native, cgo-free libbpf workflows.
Index ¶
- Constants
- Variables
- func AssociateProgramStructOps(progFD, mapFD int, opts StructOpsAssociationOptions) error
- func AttachProgram(progFD, targetFD int, attachType AttachType, flags uint32) error
- func AttachProgramWithOptions(progFD, targetFD int, attachType AttachType, opts ProgramAttachOptions) error
- func BTFFDByID(id uint32) (int, error)
- func BTFFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
- func BTFInfoByFD(fd int, info []byte) (uint32, error)
- func BindProgramMap(progFD, mapFD int) error
- func BindProgramMapWithOptions(progFD, mapFD int, opts ProgramBindOptions) error
- func CreateIterator(linkFD int) (int, error)
- func CreateLink(progFD, targetFD int, attachType AttachType) (int, error)
- func CreateMap(opts MapCreateOptions) (int, error)
- func CreateTCHook(hook TCHook) error
- func CreateToken(bpffsFD int) (int, error)
- func CreateTokenWithOptions(bpffsFD int, opts TokenCreateOptions) (int, error)
- func DeleteMapBatch(fd int, keys []byte, opts MapBatchDeleteOptions) (uint32, error)
- func DeleteMapElement(fd int, key []byte, flags uint64) error
- func DestroyTCHook(hook TCHook) error
- func DetachLinkFD(linkFD int) error
- func DetachProgram(targetFD int, attachType AttachType) error
- func DetachProgram2(progFD, targetFD int, attachType AttachType) error
- func DetachProgramWithOptions(progFD, targetFD int, attachType AttachType, opts ProgramDetachOptions) error
- func DistillBase(src, newBase, newSplit *BTF) error
- func EnableStats(statsType StatsType) (int, error)
- func ErrorString(code int) (string, error)
- func FindVmlinuxBTFID(name string, attachType AttachType) (int, error)
- func FreezeMap(fd int) error
- func LinkFDByID(id uint32) (int, error)
- func LinkFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
- func LinkInfoByFD(fd int, info []byte) (uint32, error)
- func LoadBTF(data []byte) (int, error)
- func LoadProgram(opts ProgramLoadOptions) (int, error)
- func LoadRawBTF(types, strings []byte, tokenFD int) (int, error)
- func LookupAndDeleteMapElement(fd int, key []byte, valueSize int, flags uint64) ([]byte, error)
- func LookupMapElement(fd int, key []byte, valueSize int, flags uint64) ([]byte, error)
- func MajorVersion() uint32
- func MapFDByID(id uint32) (int, error)
- func MapFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
- func MapInfoByFD(fd int, info []byte) (uint32, error)
- func MinorVersion() uint32
- func NextBTFID(startID uint32) (uint32, error)
- func NextLinkID(startID uint32) (uint32, error)
- func NextMapID(startID uint32) (uint32, error)
- func NextMapKey(fd int, current []byte, keySize int) ([]byte, error)
- func NextProgramID(startID uint32) (uint32, error)
- func NumPossibleCPUs() (int, error)
- func ObjectInfoByFD(fd int, info []byte) (uint32, error)
- func OpenPinnedObject(path string) (int, error)
- func OpenPinnedObjectWithOptions(path string, opts ObjectGetOptions) (int, error)
- func OpenRawTracepoint(name string, progFD int) (int, error)
- func OpenRawTracepointWithOptions(name string, progFD int, opts RawTracepointOptions) (int, error)
- func PinObject(fd int, path string) error
- func PinObjectWithOptions(fd int, path string, opts ObjectPinOptions) error
- func ProbeHelper(programType ProgramType, helper HelperID) (bool, error)
- func ProbeMapType(t MapType) (bool, error)
- func ProbeProgramType(t ProgramType) (bool, error)
- func ProgramFDByID(id uint32) (int, error)
- func ProgramFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
- func ProgramInfoByFD(fd int, info []byte) (uint32, error)
- func ProgramStreamRead(progFD int, streamID uint32, buf []byte) (int, error)
- func ProgramTypeByName(name string) (ProgramType, AttachType, error)
- func SetLogger(logger Logger)
- func SetMemlockRlimit(bytes uint64) error
- func SetStrictMode(mode StrictMode) error
- func TCDetach(hook TCHook, opts TCOptions) error
- func TCParent(major, minor uint32) uint32
- func UpdateLinkFD(linkFD, newProgramFD int) error
- func UpdateLinkFDWithOptions(linkFD, newProgramFD int, opts LinkUpdateOptions) error
- func UpdateMapBatch(fd int, keys, values []byte, opts MapBatchUpdateOptions) (uint32, error)
- func UpdateMapElement(fd int, key, value []byte, flags uint64) error
- func VersionString() string
- func XDPAttach(ifindex, progFD int, flags uint32) error
- func XDPDetach(ifindex int, flags uint32) error
- func XDPQueryID(ifindex int, flags int) (uint32, error)
- type AttachType
- type BTF
- func BTFByFD(fd int) (*BTF, error)
- func LoadBTFByID(id uint32) (*BTF, error)
- func LoadKernelBTF() (*BTF, error)
- func LoadModuleBTF(module string, vmlinux *BTF) (*BTF, error)
- func LoadSplitBTFByID(id uint32, base *BTF) (*BTF, error)
- func NewBTF() (*BTF, error)
- func NewBTFBytes(data []byte) (*BTF, error)
- func NewBTFSplit(base *BTF) (*BTF, error)
- func NewBTFSplitBytes(data []byte, base *BTF) (*BTF, error)
- func ParseBTFELF(path string) (*BTF, error)
- func ParseBTFELFSplit(path string, base *BTF) (*BTF, error)
- func ParseBTFFile(path string) (*BTF, error)
- func ParseBTFRaw(path string) (*BTF, error)
- func ParseBTFRawSplit(path string, base *BTF) (*BTF, error)
- func ParseBTFSplit(path string, base *BTF) (*BTF, error)
- func (b *BTF) ABIHandle() abi.BTFHandle
- func (b *BTF) AddArray(indexTypeID, elemTypeID int, elements uint32) (int, error)
- func (b *BTF) AddConst(refTypeID int) (int, error)
- func (b *BTF) AddDataSec(name string, byteSize uint32) (int, error)
- func (b *BTF) AddDataSecVarInfo(varTypeID int, offset, byteSize uint32) (int, error)
- func (b *BTF) AddDeclAttr(value string, refTypeID, componentIndex int) (int, error)
- func (b *BTF) AddDeclTag(value string, refTypeID, componentIndex int) (int, error)
- func (b *BTF) AddEnum(name string, byteSize uint32) (int, error)
- func (b *BTF) AddEnum64(name string, byteSize uint32, signed bool) (int, error)
- func (b *BTF) AddEnum64Value(name string, value uint64) (int, error)
- func (b *BTF) AddEnumValue(name string, value int64) (int, error)
- func (b *BTF) AddField(name string, typeID int, bitOffset, bitSize uint32) (int, error)
- func (b *BTF) AddFloat(name string, byteSize uint64) (int, error)
- func (b *BTF) AddForward(name string, kind BTFFwdKind) (int, error)
- func (b *BTF) AddFunc(name string, linkage BTFFuncLinkage, protoTypeID int) (int, error)
- func (b *BTF) AddFuncParam(name string, typeID int) (int, error)
- func (b *BTF) AddFuncProto(retTypeID int) (int, error)
- func (b *BTF) AddInt(name string, byteSize uint64, encoding int32) (int, error)
- func (b *BTF) AddPointer(refTypeID int) (int, error)
- func (b *BTF) AddRestrict(refTypeID int) (int, error)
- func (b *BTF) AddString(s string) (int, error)
- func (b *BTF) AddStruct(name string, byteSize uint32) (int, error)
- func (b *BTF) AddTypeAttr(value string, refTypeID int) (int, error)
- func (b *BTF) AddTypeFrom(src *BTF, typeID uint32) (int, error)
- func (b *BTF) AddTypeTag(value string, refTypeID int) (int, error)
- func (b *BTF) AddTypedef(name string, refTypeID int) (int, error)
- func (b *BTF) AddUnion(name string, byteSize uint32) (int, error)
- func (b *BTF) AddVar(name string, linkage int32, typeID int) (int, error)
- func (b *BTF) AddVolatile(refTypeID int) (int, error)
- func (b *BTF) AlignOf(typeID uint32) (int, error)
- func (b *BTF) Append(src *BTF) (int, error)
- func (b *BTF) Base() *BTF
- func (b *BTF) Close() error
- func (b *BTF) Dedup() error
- func (b *BTF) Endianness() BTFEndianness
- func (b *BTF) FD() int
- func (b *BTF) FindByName(name string) (int, error)
- func (b *BTF) FindByNameKind(name string, kind BTFKind) (int, error)
- func (b *BTF) FindString(s string) (int, error)
- func (b *BTF) LoadIntoKernel() error
- func (b *BTF) NameByOffset(offset uint32) string
- func (b *BTF) Permute(idMap []uint32, opts BTFPermuteOptions) error
- func (b *BTF) PointerSize() uint64
- func (b *BTF) RawData() []byte
- func (b *BTF) Relocate(base *BTF) error
- func (b *BTF) ResolveSize(typeID uint32) (int64, error)
- func (b *BTF) ResolveType(typeID uint32) (int, error)
- func (b *BTF) SetEndianness(endian BTFEndianness) error
- func (b *BTF) SetFD(fd int) error
- func (b *BTF) SetPointerSize(size uint64) error
- func (b *BTF) StringByOffset(offset uint32) string
- func (b *BTF) TypeByID(typeID uint32) (BTFType, error)
- func (b *BTF) TypeCount() uint32
- type BTFDump
- type BTFEndianness
- type BTFExt
- type BTFFuncLinkage
- type BTFFwdKind
- type BTFKind
- type BTFPermuteOptions
- type BTFType
- type BTFTypeDataOptions
- type BTFTypeDeclarationOptions
- type CgroupOptions
- type Error
- type FuncInfo
- type GetFDByIDOptions
- type HandleOwnership
- type HelperID
- type KprobeOptions
- type LineInfo
- type Link
- func (l *Link) ABIHandle() abi.LinkHandle
- func (l *Link) Close() error
- func (l *Link) Destroy() error
- func (l *Link) Detach() error
- func (l *Link) Disconnect()
- func (l *Link) FD() int
- func (l *Link) Pin(path string) error
- func (l *Link) PinPath() string
- func (l *Link) Unpin() error
- func (l *Link) UpdateMap(m *Map) error
- func (l *Link) UpdateProgram(prog *Program) error
- type LinkType
- type LinkUpdateOptions
- type Linker
- type LogLevel
- type Logger
- type LoggerFunc
- type Map
- func (m *Map) ABIHandle() abi.MapHandle
- func (m *Map) AttachStructOps() (*Link, error)
- func (m *Map) Autoattach() bool
- func (m *Map) Autocreate() bool
- func (m *Map) BTFKeyTypeID() uint32
- func (m *Map) BTFValueTypeID() uint32
- func (m *Map) Delete(key []byte, flags uint64) error
- func (m *Map) ExclusiveProgram() *Program
- func (m *Map) Extra() uint64
- func (m *Map) FD() int
- func (m *Map) Flags() uint32
- func (m *Map) Ifindex() uint32
- func (m *Map) InitialValue() []byte
- func (m *Map) InnerMap() *Map
- func (m *Map) IsInternal() bool
- func (m *Map) IsPinned() bool
- func (m *Map) KeySize() uint32
- func (m *Map) Lookup(key []byte, flags uint64) ([]byte, error)
- func (m *Map) LookupAndDelete(key []byte, flags uint64) ([]byte, error)
- func (m *Map) MaxEntries() uint32
- func (m *Map) NUMANode() uint32
- func (m *Map) Name() string
- func (m *Map) NextKey(current []byte) ([]byte, error)
- func (m *Map) Pin(path string) error
- func (m *Map) PinPath() string
- func (m *Map) ReuseFD(fd int) error
- func (m *Map) SetAutoattach(autoattach bool) error
- func (m *Map) SetAutocreate(autocreate bool) error
- func (m *Map) SetExclusiveProgram(prog *Program) error
- func (m *Map) SetExtra(extra uint64) error
- func (m *Map) SetFlags(flags uint32) error
- func (m *Map) SetIfindex(ifindex uint32) error
- func (m *Map) SetInitialValue(value []byte) error
- func (m *Map) SetInnerMapFD(fd int) error
- func (m *Map) SetKeySize(size uint32) error
- func (m *Map) SetMaxEntries(maxEntries uint32) error
- func (m *Map) SetNUMANode(numaNode uint32) error
- func (m *Map) SetPinPath(path string) error
- func (m *Map) SetType(t MapType) error
- func (m *Map) SetValueSize(size uint32) error
- func (m *Map) Type() MapType
- func (m *Map) Unpin(path string) error
- func (m *Map) Update(key, value []byte, flags uint64) error
- func (m *Map) ValueSize() uint32
- type MapBatchDeleteOptions
- type MapBatchLookupOptions
- type MapBatchLookupResult
- type MapBatchOptions
- type MapBatchUpdateOptions
- type MapCreateOptions
- type MapType
- type NetfilterOptions
- type NetkitOptions
- type Object
- func (o *Object) ABIHandle() abi.ObjectHandle
- func (o *Object) BTF() (*BTF, error)
- func (o *Object) BTFFD() int
- func (o *Object) Close() error
- func (o *Object) GenerateLoader() error
- func (o *Object) KernelLog() string
- func (o *Object) KernelVersion() uint32
- func (o *Object) Load() error
- func (o *Object) Map(name string) (*Map, error)
- func (o *Object) MapFD(name string) (int, error)
- func (o *Object) Maps() ([]*Map, error)
- func (o *Object) MapsReverse() ([]*Map, error)
- func (o *Object) Name() string
- func (o *Object) Pin(path string) error
- func (o *Object) PinMaps(path string) error
- func (o *Object) PinPrograms(path string) error
- func (o *Object) Prepare() error
- func (o *Object) Program(name string) (*Program, error)
- func (o *Object) Programs() ([]*Program, error)
- func (o *Object) ProgramsReverse() ([]*Program, error)
- func (o *Object) SetKernelVersion(version uint32) error
- func (o *Object) TokenFD() int
- func (o *Object) Unpin(path string) error
- func (o *Object) UnpinMaps(path string) error
- func (o *Object) UnpinPrograms(path string) error
- type ObjectGetOptions
- type ObjectOptions
- type ObjectPinOptions
- type PerfBuffer
- func (pb *PerfBuffer) Buffer(index int) ([]byte, error)
- func (pb *PerfBuffer) BufferCount() uint64
- func (pb *PerfBuffer) BufferFD(index uint64) int
- func (pb *PerfBuffer) Close() error
- func (pb *PerfBuffer) Consume() error
- func (pb *PerfBuffer) ConsumeBuffer(index uint64) error
- func (pb *PerfBuffer) EpollFD() int
- func (pb *PerfBuffer) Poll(timeoutMillis int) (int, error)
- type PerfBufferEvent
- type PerfBufferEventCallback
- type PerfBufferEventResult
- type PerfBufferLostCallback
- type PerfBufferSample
- type PerfBufferSampleCallback
- type PerfEventAttachOptions
- type PerfEventAttr
- type PerfEventAttrFlags
- type PerfEventHeader
- type PerfEventType
- type PerfSampleType
- type PerfSoftwareEvent
- type ProbeAttachMode
- type Program
- func (p *Program) ABIHandle() abi.ProgramHandle
- func (p *Program) AssociateStructOps(m *Map, opts StructOpsAssociationOptions) error
- func (p *Program) Attach() (*Link, error)
- func (p *Program) AttachCgroup(cgroupFD int) (*Link, error)
- func (p *Program) AttachCgroupWithOptions(cgroupFD int, opts CgroupOptions) (*Link, error)
- func (p *Program) AttachFreplace(targetFD int, function string) (*Link, error)
- func (p *Program) AttachIterator() (*Link, error)
- func (p *Program) AttachKprobe(function string, retprobe bool) (*Link, error)
- func (p *Program) AttachKprobeMulti(pattern string) (*Link, error)
- func (p *Program) AttachKprobeWithOptions(function string, opts KprobeOptions) (*Link, error)
- func (p *Program) AttachKsyscall(syscall string) (*Link, error)
- func (p *Program) AttachLSM() (*Link, error)
- func (p *Program) AttachNetNS(netnsFD int) (*Link, error)
- func (p *Program) AttachNetfilter(opts NetfilterOptions) (*Link, error)
- func (p *Program) AttachNetkit(ifindex int, opts NetkitOptions) (*Link, error)
- func (p *Program) AttachPerfEvent(perfEventFD int) (*Link, error)
- func (p *Program) AttachPerfEventWithOptions(perfEventFD int, opts PerfEventAttachOptions) (*Link, error)
- func (p *Program) AttachRawTracepoint(name string) (*Link, error)
- func (p *Program) AttachRawTracepointWithOptions(name string, opts RawTracepointOptions) (*Link, error)
- func (p *Program) AttachSockMap(mapFD int) (*Link, error)
- func (p *Program) AttachTCX(ifindex int, opts TCXOptions) (*Link, error)
- func (p *Program) AttachTrace() (*Link, error)
- func (p *Program) AttachTraceWithOptions(opts TraceOptions) (*Link, error)
- func (p *Program) AttachTracepoint(category, name string) (*Link, error)
- func (p *Program) AttachTracepointWithOptions(category, name string, opts TracepointOptions) (*Link, error)
- func (p *Program) AttachUSDT(pid int, binaryPath, provider, name string) (*Link, error)
- func (p *Program) AttachUprobe(pid int, binaryPath string, offset uint64, retprobe bool) (*Link, error)
- func (p *Program) AttachUprobeMulti(pid int, binaryPath, pattern string) (*Link, error)
- func (p *Program) AttachUprobeWithOptions(pid int, binaryPath string, offset uint64, opts UprobeOptions) (*Link, error)
- func (p *Program) AttachXDP(ifindex int) (*Link, error)
- func (p *Program) Autoattach() bool
- func (p *Program) Autoload() bool
- func (p *Program) ExpectedAttachType() AttachType
- func (p *Program) FD() int
- func (p *Program) Flags() uint32
- func (p *Program) FuncInfo() ([]FuncInfo, error)
- func (p *Program) FuncInfoCount() uint32
- func (p *Program) Instructions() []byte
- func (p *Program) LineInfo() (*ProgramLineInfo, error)
- func (p *Program) LineInfoCount() uint32
- func (p *Program) LogBuffer() []byte
- func (p *Program) LogLevel() uint32
- func (p *Program) LogString() string
- func (p *Program) Name() string
- func (p *Program) Pin(path string) error
- func (p *Program) SectionName() string
- func (p *Program) SetAttachTarget(targetFD int, function string) error
- func (p *Program) SetAutoattach(autoattach bool) error
- func (p *Program) SetAutoload(autoload bool) error
- func (p *Program) SetExpectedAttachType(t AttachType) error
- func (p *Program) SetFlags(flags uint32) error
- func (p *Program) SetIfindex(ifindex uint32) error
- func (p *Program) SetInstructions(insns []byte) error
- func (p *Program) SetLogBuffer(size uint32) error
- func (p *Program) SetLogLevel(level uint32) error
- func (p *Program) SetType(t ProgramType) error
- func (p *Program) SourceLineInfo() ([]LineInfo, error)
- func (p *Program) TestRun(opts ProgramTestRunOptions) (ProgramTestRunResult, error)
- func (p *Program) Type() ProgramType
- func (p *Program) Unload() error
- func (p *Program) Unpin(path string) error
- type ProgramAttachOptions
- type ProgramBindOptions
- type ProgramDetachOptions
- type ProgramLineInfo
- type ProgramLoadOptions
- type ProgramQueryOptions
- type ProgramQueryResult
- type ProgramSectionHandler
- type ProgramSectionHandlerOptions
- type ProgramTestRunOptions
- type ProgramTestRunResult
- type ProgramType
- type RawPerfBufferOptions
- type RawTracepointOptions
- type Ring
- type RingBuffer
- func (rb *RingBuffer) Add(mapFD int, callback RingBufferCallback) error
- func (rb *RingBuffer) Close() error
- func (rb *RingBuffer) Consume() (int, error)
- func (rb *RingBuffer) ConsumeN(n uint64) (int, error)
- func (rb *RingBuffer) EpollFD() int
- func (rb *RingBuffer) Poll(timeoutMillis int) (int, error)
- func (rb *RingBuffer) Ring(index uint32) (*Ring, error)
- type RingBufferCallback
- type RingBufferSample
- type Skeleton
- func (s *Skeleton) Attach() error
- func (s *Skeleton) Close() error
- func (s *Skeleton) Detach() error
- func (s *Skeleton) Load() error
- func (s *Skeleton) Map(name string) (*Map, error)
- func (s *Skeleton) MapLink(name string) (*Link, error)
- func (s *Skeleton) MappedValue(name string) ([]byte, error)
- func (s *Skeleton) Object() (*Object, error)
- func (s *Skeleton) Open(opts ObjectOptions) (*Object, error)
- func (s *Skeleton) Program(name string) (*Program, error)
- func (s *Skeleton) ProgramLink(name string) (*Link, error)
- type SkeletonMapSpec
- type SkeletonProgramSpec
- type SkeletonSpec
- type SkeletonVariableSpec
- type StatsType
- type StrictMode
- type StructOpsAssociationOptions
- type Subskeleton
- type SubskeletonSpec
- type TCAttachPoint
- type TCHook
- type TCOptions
- type TCXOptions
- type TaskFDQueryOptions
- type TaskFDQueryResult
- type TokenCreateOptions
- type TraceOptions
- type TracepointOptions
- type UprobeOptions
- type UserRingBuffer
- type UserRingSample
- type WrapObjectOptions
- type XDPAttachMode
- type XDPQueryResult
Constants ¶
const ( UpdateAny uint64 = abi.BPF_ANY UpdateNoExist uint64 = abi.BPF_NOEXIST UpdateExist uint64 = abi.BPF_EXIST UpdateLock uint64 = abi.BPF_F_LOCK )
const ( BTFIntSigned int32 = abi.BTF_INT_SIGNED BTFIntChar int32 = abi.BTF_INT_CHAR BTFIntBool int32 = abi.BTF_INT_BOOL )
const TCReplace uint32 = abi.BPF_TC_F_REPLACE
Variables ¶
var ( ErrClosed = errors.New("bpf: closed handle") ErrNotFound = errors.New("bpf: not found") )
Functions ¶
func AssociateProgramStructOps ¶
func AssociateProgramStructOps(progFD, mapFD int, opts StructOpsAssociationOptions) error
func AttachProgram ¶
func AttachProgram(progFD, targetFD int, attachType AttachType, flags uint32) error
func AttachProgramWithOptions ¶
func AttachProgramWithOptions(progFD, targetFD int, attachType AttachType, opts ProgramAttachOptions) error
func BTFFDByIDWithOptions ¶
func BTFFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
func BindProgramMap ¶
func BindProgramMapWithOptions ¶
func BindProgramMapWithOptions(progFD, mapFD int, opts ProgramBindOptions) error
func CreateIterator ¶
func CreateLink ¶
func CreateLink(progFD, targetFD int, attachType AttachType) (int, error)
func CreateMap ¶
func CreateMap(opts MapCreateOptions) (int, error)
func CreateTCHook ¶
func CreateToken ¶
func CreateTokenWithOptions ¶
func CreateTokenWithOptions(bpffsFD int, opts TokenCreateOptions) (int, error)
func DeleteMapBatch ¶
func DeleteMapBatch(fd int, keys []byte, opts MapBatchDeleteOptions) (uint32, error)
func DestroyTCHook ¶
func DetachLinkFD ¶
func DetachProgram ¶
func DetachProgram(targetFD int, attachType AttachType) error
func DetachProgram2 ¶
func DetachProgram2(progFD, targetFD int, attachType AttachType) error
func DetachProgramWithOptions ¶
func DetachProgramWithOptions(progFD, targetFD int, attachType AttachType, opts ProgramDetachOptions) error
func DistillBase ¶
func EnableStats ¶
func ErrorString ¶
func FindVmlinuxBTFID ¶
func FindVmlinuxBTFID(name string, attachType AttachType) (int, error)
func LinkFDByID ¶
func LinkFDByIDWithOptions ¶
func LinkFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
func LoadProgram ¶
func LoadProgram(opts ProgramLoadOptions) (int, error)
func LookupMapElement ¶
func MajorVersion ¶
func MajorVersion() uint32
func MapFDByIDWithOptions ¶
func MapFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
func MinorVersion ¶
func MinorVersion() uint32
func NextLinkID ¶
func NextProgramID ¶
func NumPossibleCPUs ¶
func OpenPinnedObject ¶
func OpenPinnedObjectWithOptions ¶
func OpenPinnedObjectWithOptions(path string, opts ObjectGetOptions) (int, error)
func OpenRawTracepointWithOptions ¶
func OpenRawTracepointWithOptions(name string, progFD int, opts RawTracepointOptions) (int, error)
func PinObjectWithOptions ¶
func PinObjectWithOptions(fd int, path string, opts ObjectPinOptions) error
func ProbeHelper ¶
func ProbeHelper(programType ProgramType, helper HelperID) (bool, error)
func ProbeMapType ¶
func ProbeProgramType ¶
func ProbeProgramType(t ProgramType) (bool, error)
func ProgramFDByID ¶
func ProgramFDByIDWithOptions ¶
func ProgramFDByIDWithOptions(id uint32, opts GetFDByIDOptions) (int, error)
func ProgramStreamRead ¶
func ProgramTypeByName ¶
func ProgramTypeByName(name string) (ProgramType, AttachType, error)
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger installs a process-wide libbpf logger. Passing nil disables libbpf logging through this package.
func SetMemlockRlimit ¶
func SetStrictMode ¶
func SetStrictMode(mode StrictMode) error
func UpdateLinkFD ¶
func UpdateLinkFDWithOptions ¶
func UpdateLinkFDWithOptions(linkFD, newProgramFD int, opts LinkUpdateOptions) error
func UpdateMapBatch ¶
func UpdateMapBatch(fd int, keys, values []byte, opts MapBatchUpdateOptions) (uint32, error)
func VersionString ¶
func VersionString() string
Types ¶
type AttachType ¶
type AttachType int32
const ( AttachCgroupInetIngress AttachType = abi.BPF_CGROUP_INET_INGRESS AttachCgroupInetEgress AttachType = abi.BPF_CGROUP_INET_EGRESS AttachTraceRawTracepoint AttachType = abi.BPF_TRACE_RAW_TP AttachTraceFEntry AttachType = abi.BPF_TRACE_FENTRY AttachTraceFExit AttachType = abi.BPF_TRACE_FEXIT AttachModifyReturn AttachType = abi.BPF_MODIFY_RETURN AttachLSMMac AttachType = abi.BPF_LSM_MAC AttachTraceIterator AttachType = abi.BPF_TRACE_ITER AttachXDP AttachType = abi.BPF_XDP AttachPerfEvent AttachType = abi.BPF_PERF_EVENT AttachTraceKprobeMulti AttachType = abi.BPF_TRACE_KPROBE_MULTI AttachStructOps AttachType = abi.BPF_STRUCT_OPS AttachNetfilter AttachType = abi.BPF_NETFILTER AttachTCXIngress AttachType = abi.BPF_TCX_INGRESS AttachTCXEgress AttachType = abi.BPF_TCX_EGRESS AttachTraceUprobeMulti AttachType = abi.BPF_TRACE_UPROBE_MULTI AttachNetkitPrimary AttachType = abi.BPF_NETKIT_PRIMARY AttachNetkitPeer AttachType = abi.BPF_NETKIT_PEER )
func AttachTypeByName ¶
func AttachTypeByName(name string) (AttachType, error)
func (AttachType) String ¶
func (t AttachType) String() string
type BTF ¶
type BTF struct {
// contains filtered or unexported fields
}
func LoadBTFByID ¶
func LoadKernelBTF ¶
func NewBTFBytes ¶
func NewBTFSplit ¶
func ParseBTFELF ¶
func ParseBTFFile ¶
func ParseBTFRaw ¶
func (*BTF) AddDataSecVarInfo ¶
func (*BTF) AddDeclAttr ¶
func (*BTF) AddDeclTag ¶
func (*BTF) AddForward ¶
func (b *BTF) AddForward(name string, kind BTFFwdKind) (int, error)
func (*BTF) Endianness ¶
func (b *BTF) Endianness() BTFEndianness
func (*BTF) LoadIntoKernel ¶
func (*BTF) NameByOffset ¶
func (*BTF) PointerSize ¶
func (*BTF) SetEndianness ¶
func (b *BTF) SetEndianness(endian BTFEndianness) error
func (*BTF) SetPointerSize ¶
func (*BTF) StringByOffset ¶
type BTFDump ¶
type BTFDump struct {
// contains filtered or unexported fields
}
func NewBTFDump ¶
NewBTFDump creates a BTF dump handle that writes rendered text to w. The BTF handle is borrowed by libbpf and must remain open until the dump is closed.
func (*BTFDump) DumpTypeData ¶
func (d *BTFDump) DumpTypeData(typeID uint32, data []byte, opts BTFTypeDataOptions) error
func (*BTFDump) EmitTypeDeclaration ¶
func (d *BTFDump) EmitTypeDeclaration(typeID uint32, opts BTFTypeDeclarationOptions) error
type BTFEndianness ¶
type BTFEndianness int32
const ( BTFLittleEndian BTFEndianness = abi.BTF_LITTLE_ENDIAN BTFBigEndian BTFEndianness = abi.BTF_BIG_ENDIAN )
type BTFExt ¶
type BTFExt struct {
// contains filtered or unexported fields
}
func (*BTFExt) Endianness ¶
func (e *BTFExt) Endianness() BTFEndianness
func (*BTFExt) SetEndianness ¶
func (e *BTFExt) SetEndianness(endian BTFEndianness) error
type BTFFuncLinkage ¶
type BTFFuncLinkage int32
const ( BTFFuncStatic BTFFuncLinkage = abi.BTF_FUNC_STATIC BTFFuncGlobal BTFFuncLinkage = abi.BTF_FUNC_GLOBAL BTFFuncExtern BTFFuncLinkage = abi.BTF_FUNC_EXTERN )
type BTFFwdKind ¶
type BTFFwdKind int32
const ( BTFFwdStruct BTFFwdKind = abi.BTF_FWD_STRUCT BTFFwdUnion BTFFwdKind = abi.BTF_FWD_UNION BTFFwdEnum BTFFwdKind = abi.BTF_FWD_ENUM )
type BTFKind ¶
type BTFKind uint32
const ( BTFKindUnknown BTFKind = abi.BTF_KIND_UNKN BTFKindInt BTFKind = abi.BTF_KIND_INT BTFKindPointer BTFKind = abi.BTF_KIND_PTR BTFKindArray BTFKind = abi.BTF_KIND_ARRAY BTFKindStruct BTFKind = abi.BTF_KIND_STRUCT BTFKindUnion BTFKind = abi.BTF_KIND_UNION BTFKindEnum BTFKind = abi.BTF_KIND_ENUM BTFKindForward BTFKind = abi.BTF_KIND_FWD BTFKindTypedef BTFKind = abi.BTF_KIND_TYPEDEF BTFKindVolatile BTFKind = abi.BTF_KIND_VOLATILE BTFKindConst BTFKind = abi.BTF_KIND_CONST BTFKindRestrict BTFKind = abi.BTF_KIND_RESTRICT BTFKindFunc BTFKind = abi.BTF_KIND_FUNC BTFKindFuncProto BTFKind = abi.BTF_KIND_FUNC_PROTO BTFKindVar BTFKind = abi.BTF_KIND_VAR BTFKindDataSec BTFKind = abi.BTF_KIND_DATASEC BTFKindFloat BTFKind = abi.BTF_KIND_FLOAT BTFKindDeclTag BTFKind = abi.BTF_KIND_DECL_TAG BTFKindTypeTag BTFKind = abi.BTF_KIND_TYPE_TAG BTFKindEnum64 BTFKind = abi.BTF_KIND_ENUM64 )
type BTFPermuteOptions ¶
type BTFPermuteOptions struct {
Ext *BTFExt
}
type BTFTypeDataOptions ¶
type CgroupOptions ¶
type Error ¶
type GetFDByIDOptions ¶
type HandleOwnership ¶
type HandleOwnership int
const ( BorrowHandle HandleOwnership = iota OwnHandle )
type KprobeOptions ¶
type KprobeOptions struct {
Cookie uint64
Offset uint64
Retprobe bool
AttachMode ProbeAttachMode
}
type Link ¶
type Link struct {
// contains filtered or unexported fields
}
func (*Link) ABIHandle ¶
func (l *Link) ABIHandle() abi.LinkHandle
func (*Link) Disconnect ¶
func (l *Link) Disconnect()
func (*Link) UpdateProgram ¶
type LinkType ¶
type LinkType int32
const ( LinkTypeUnspec LinkType = abi.BPF_LINK_TYPE_UNSPEC LinkTypeRawTracepoint LinkType = abi.BPF_LINK_TYPE_RAW_TRACEPOINT LinkTypeTracing LinkType = abi.BPF_LINK_TYPE_TRACING LinkTypeCgroup LinkType = abi.BPF_LINK_TYPE_CGROUP LinkTypeIterator LinkType = abi.BPF_LINK_TYPE_ITER LinkTypeNetNS LinkType = abi.BPF_LINK_TYPE_NETNS LinkTypeXDP LinkType = abi.BPF_LINK_TYPE_XDP LinkTypePerfEvent LinkType = abi.BPF_LINK_TYPE_PERF_EVENT LinkTypeKprobeMulti LinkType = abi.BPF_LINK_TYPE_KPROBE_MULTI LinkTypeStructOps LinkType = abi.BPF_LINK_TYPE_STRUCT_OPS LinkTypeNetfilter LinkType = abi.BPF_LINK_TYPE_NETFILTER LinkTypeTCX LinkType = abi.BPF_LINK_TYPE_TCX LinkTypeUprobeMulti LinkType = abi.BPF_LINK_TYPE_UPROBE_MULTI LinkTypeNetkit LinkType = abi.BPF_LINK_TYPE_NETKIT LinkTypeSockMap LinkType = abi.BPF_LINK_TYPE_SOCKMAP )
type LinkUpdateOptions ¶
type LogLevel ¶
type LogLevel int32
LogLevel is a libbpf log severity.
const ( LogLevelWarn LogLevel = abi.LIBBPF_WARN LogLevelInfo LogLevel = abi.LIBBPF_INFO LogLevelDebug LogLevel = abi.LIBBPF_DEBUG )
type LoggerFunc ¶
LoggerFunc adapts a function to Logger.
func (LoggerFunc) Log ¶
func (fn LoggerFunc) Log(level LogLevel, message string)
type Map ¶
type Map struct {
// contains filtered or unexported fields
}
func (*Map) AttachStructOps ¶
func (*Map) Autoattach ¶
func (*Map) Autocreate ¶
func (*Map) BTFKeyTypeID ¶
func (*Map) BTFValueTypeID ¶
func (*Map) ExclusiveProgram ¶
func (*Map) InitialValue ¶
func (*Map) IsInternal ¶
func (*Map) LookupAndDelete ¶
func (*Map) MaxEntries ¶
func (*Map) SetAutoattach ¶
func (*Map) SetAutocreate ¶
func (*Map) SetExclusiveProgram ¶
func (*Map) SetIfindex ¶
func (*Map) SetInitialValue ¶
func (*Map) SetInnerMapFD ¶
func (*Map) SetKeySize ¶
func (*Map) SetMaxEntries ¶
func (*Map) SetNUMANode ¶
func (*Map) SetPinPath ¶
func (*Map) SetValueSize ¶
type MapBatchDeleteOptions ¶
type MapBatchDeleteOptions struct {
KeySize int
MapBatchOptions
}
type MapBatchLookupOptions ¶
type MapBatchLookupResult ¶
func LookupAndDeleteMapBatch ¶
func LookupAndDeleteMapBatch(fd int, opts MapBatchLookupOptions) (MapBatchLookupResult, error)
func LookupMapBatch ¶
func LookupMapBatch(fd int, opts MapBatchLookupOptions) (MapBatchLookupResult, error)
type MapBatchOptions ¶
type MapBatchUpdateOptions ¶
type MapBatchUpdateOptions struct {
KeySize int
ValueSize int
MapBatchOptions
}
type MapCreateOptions ¶
type MapType ¶
type MapType int32
const ( MapTypeUnspec MapType = abi.BPF_MAP_TYPE_UNSPEC MapTypeHash MapType = abi.BPF_MAP_TYPE_HASH MapTypeArray MapType = abi.BPF_MAP_TYPE_ARRAY MapTypeProgramArray MapType = abi.BPF_MAP_TYPE_PROG_ARRAY MapTypePerfEventArray MapType = abi.BPF_MAP_TYPE_PERF_EVENT_ARRAY MapTypePerCPUHash MapType = abi.BPF_MAP_TYPE_PERCPU_HASH MapTypePerCPUArray MapType = abi.BPF_MAP_TYPE_PERCPU_ARRAY MapTypeStackTrace MapType = abi.BPF_MAP_TYPE_STACK_TRACE MapTypeArrayOfMaps MapType = abi.BPF_MAP_TYPE_ARRAY_OF_MAPS MapTypeHashOfMaps MapType = abi.BPF_MAP_TYPE_HASH_OF_MAPS MapTypeSockMap MapType = abi.BPF_MAP_TYPE_SOCKMAP MapTypeSockHash MapType = abi.BPF_MAP_TYPE_SOCKHASH MapTypeQueue MapType = abi.BPF_MAP_TYPE_QUEUE MapTypeStack MapType = abi.BPF_MAP_TYPE_STACK MapTypeStructOps MapType = abi.BPF_MAP_TYPE_STRUCT_OPS MapTypeRingBuffer MapType = abi.BPF_MAP_TYPE_RINGBUF MapTypeUserRingBuffer MapType = abi.BPF_MAP_TYPE_USER_RINGBUF MapTypeArena MapType = abi.BPF_MAP_TYPE_ARENA MapTypeInstructionArray MapType = abi.BPF_MAP_TYPE_INSN_ARRAY )
type NetfilterOptions ¶
type NetkitOptions ¶
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
func OpenObjectFile ¶
func OpenObjectFile(path string, opts ObjectOptions) (*Object, error)
func OpenObjectMem ¶
func OpenObjectMem(data []byte, opts ObjectOptions) (*Object, error)
func WrapObject ¶
func WrapObject(handle abi.ObjectHandle, opts WrapObjectOptions) (*Object, error)
func (*Object) ABIHandle ¶
func (o *Object) ABIHandle() abi.ObjectHandle
func (*Object) GenerateLoader ¶
func (*Object) KernelVersion ¶
func (*Object) MapsReverse ¶
func (*Object) PinPrograms ¶
func (*Object) ProgramsReverse ¶
func (*Object) SetKernelVersion ¶
func (*Object) UnpinPrograms ¶
type ObjectGetOptions ¶
type ObjectOptions ¶
type ObjectOptions struct {
// Name overrides libbpf's object name derived from the path or memory
// buffer.
Name string
// RelaxedMaps allows non-strict map definition parsing.
RelaxedMaps bool
// PinRootPath is the root directory for maps with pinning metadata.
PinRootPath string
// KConfig is additional kernel config content for CONFIG_* externs.
KConfig string
// BTFCustomPath replaces vmlinux BTF for CO-RE relocations.
BTFCustomPath string
// KernelLogSize allocates an object-owned verifier/BTF log buffer.
KernelLogSize uint32
// KernelLogLevel requests kernel verifier/BTF logging.
KernelLogLevel uint32
// BPFTokenPath derives a BPF token from the given BPF filesystem path.
BPFTokenPath string
// DisableBPFToken sets an explicit empty BPF token path, disabling
// libbpf's implicit token creation and environment-variable fallback.
DisableBPFToken bool
}
type ObjectPinOptions ¶
type PerfBuffer ¶
type PerfBuffer struct {
// contains filtered or unexported fields
}
func NewPerfBuffer ¶
func NewPerfBuffer(mapFD int, pageCount uint64, sampleCallback PerfBufferSampleCallback, lostCallback PerfBufferLostCallback) (*PerfBuffer, error)
func NewRawPerfBuffer ¶
func NewRawPerfBuffer(mapFD int, pageCount uint64, attr PerfEventAttr, eventCallback PerfBufferEventCallback, opts RawPerfBufferOptions) (*PerfBuffer, error)
NewRawPerfBuffer creates a raw perf buffer using caller-supplied perf event attributes and a raw event callback.
func (*PerfBuffer) BufferCount ¶
func (pb *PerfBuffer) BufferCount() uint64
func (*PerfBuffer) BufferFD ¶
func (pb *PerfBuffer) BufferFD(index uint64) int
func (*PerfBuffer) Close ¶
func (pb *PerfBuffer) Close() error
func (*PerfBuffer) Consume ¶
func (pb *PerfBuffer) Consume() error
func (*PerfBuffer) ConsumeBuffer ¶
func (pb *PerfBuffer) ConsumeBuffer(index uint64) error
func (*PerfBuffer) EpollFD ¶
func (pb *PerfBuffer) EpollFD() int
type PerfBufferEvent ¶
type PerfBufferEvent struct {
CPU int
Header PerfEventHeader
// Data is a borrowed view over the full event record, including Header,
// and is only valid during the callback. Copy it before retaining it.
Data []byte
}
PerfBufferEvent is a raw perf event record passed to a raw perf buffer callback.
type PerfBufferEventCallback ¶
type PerfBufferEventCallback func(PerfBufferEvent) (PerfBufferEventResult, error)
PerfBufferEventCallback is called synchronously from Poll, Consume, or ConsumeBuffer for raw perf buffers. It must not call methods on the same PerfBuffer.
type PerfBufferEventResult ¶
type PerfBufferEventResult int32
PerfBufferEventResult controls raw perf event iteration.
const ( // PerfEventDone stops event processing successfully. PerfEventDone PerfBufferEventResult = abi.LIBBPF_PERF_EVENT_DONE // PerfEventError stops event processing with an error. PerfEventError PerfBufferEventResult = abi.LIBBPF_PERF_EVENT_ERROR // PerfEventContinue continues event processing. PerfEventContinue PerfBufferEventResult = abi.LIBBPF_PERF_EVENT_CONT )
type PerfBufferLostCallback ¶
PerfBufferLostCallback is called synchronously from Poll, Consume, or ConsumeBuffer. It must not call methods on the same PerfBuffer.
type PerfBufferSample ¶
type PerfBufferSampleCallback ¶
type PerfBufferSampleCallback func(PerfBufferSample) error
PerfBufferSampleCallback is called synchronously from Poll, Consume, or ConsumeBuffer. It must not call methods on the same PerfBuffer.
type PerfEventAttachOptions ¶
type PerfEventAttr ¶
type PerfEventAttr struct {
Type PerfEventType
Config uint64
SamplePeriodOrFrequency uint64
SampleType PerfSampleType
ReadFormat uint64
Flags PerfEventAttrFlags
WakeupEventsOrWatermark uint32
BPType uint32
Config1 uint64
Config2 uint64
BranchSampleType uint64
SampleRegsUser uint64
SampleStackUser uint32
ClockID int32
SampleRegsIntr uint64
AuxWatermark uint32
SampleMaxStack uint16
AuxSampleSize uint32
AuxAction uint32
SigData uint64
Config3 uint64
Config4 uint64
}
PerfEventAttr describes the perf event attributes used by NewRawPerfBuffer. The generated ABI sets the kernel size field automatically. Fields ending in "Or" select the corresponding perf_event_attr union member according to the flag bits, as Linux does.
type PerfEventAttrFlags ¶
type PerfEventAttrFlags uint64
PerfEventAttrFlags is the Linux perf_event_attr flag bitmask.
const ( PerfEventAttrDisabled PerfEventAttrFlags = 1 << 0 PerfEventAttrInherit PerfEventAttrFlags = 1 << 1 PerfEventAttrPinned PerfEventAttrFlags = 1 << 2 PerfEventAttrExclusive PerfEventAttrFlags = 1 << 3 PerfEventAttrExcludeUser PerfEventAttrFlags = 1 << 4 PerfEventAttrExcludeKernel PerfEventAttrFlags = 1 << 5 PerfEventAttrExcludeHV PerfEventAttrFlags = 1 << 6 PerfEventAttrExcludeIdle PerfEventAttrFlags = 1 << 7 PerfEventAttrMmap PerfEventAttrFlags = 1 << 8 PerfEventAttrComm PerfEventAttrFlags = 1 << 9 PerfEventAttrFreq PerfEventAttrFlags = 1 << 10 PerfEventAttrInheritStat PerfEventAttrFlags = 1 << 11 PerfEventAttrEnableOnExec PerfEventAttrFlags = 1 << 12 PerfEventAttrTask PerfEventAttrFlags = 1 << 13 PerfEventAttrWatermark PerfEventAttrFlags = 1 << 14 PerfEventAttrPreciseIPConstantSkid PerfEventAttrFlags = 1 << 15 PerfEventAttrPreciseIPZeroRequested PerfEventAttrFlags = 2 << 15 PerfEventAttrPreciseIPZeroRequired PerfEventAttrFlags = 3 << 15 PerfEventAttrMmapData PerfEventAttrFlags = 1 << 17 PerfEventAttrSampleIDAll PerfEventAttrFlags = 1 << 18 PerfEventAttrExcludeHost PerfEventAttrFlags = 1 << 19 PerfEventAttrExcludeGuest PerfEventAttrFlags = 1 << 20 PerfEventAttrExcludeCallchainKernel PerfEventAttrFlags = 1 << 21 PerfEventAttrExcludeCallchainUser PerfEventAttrFlags = 1 << 22 PerfEventAttrMmap2 PerfEventAttrFlags = 1 << 23 PerfEventAttrCommExec PerfEventAttrFlags = 1 << 24 PerfEventAttrUseClockID PerfEventAttrFlags = 1 << 25 PerfEventAttrContextSwitch PerfEventAttrFlags = 1 << 26 PerfEventAttrWriteBackward PerfEventAttrFlags = 1 << 27 PerfEventAttrNamespaces PerfEventAttrFlags = 1 << 28 PerfEventAttrKSymbol PerfEventAttrFlags = 1 << 29 PerfEventAttrBPFEvent PerfEventAttrFlags = 1 << 30 PerfEventAttrAuxOutput PerfEventAttrFlags = 1 << 31 PerfEventAttrCgroup PerfEventAttrFlags = 1 << 32 PerfEventAttrTextPoke PerfEventAttrFlags = 1 << 33 PerfEventAttrBuildID PerfEventAttrFlags = 1 << 34 PerfEventAttrInheritThread PerfEventAttrFlags = 1 << 35 PerfEventAttrRemoveOnExec PerfEventAttrFlags = 1 << 36 PerfEventAttrSigtrap PerfEventAttrFlags = 1 << 37 PerfEventAttrDeferCallchain PerfEventAttrFlags = 1 << 38 PerfEventAttrDeferOutput PerfEventAttrFlags = 1 << 39 )
type PerfEventHeader ¶
PerfEventHeader describes the header at the start of a raw perf event.
type PerfEventType ¶
type PerfEventType uint32
PerfEventType is the Linux perf_event_attr type field.
const ( PerfEventTypeHardware PerfEventType = abi.PERF_TYPE_HARDWARE PerfEventTypeSoftware PerfEventType = abi.PERF_TYPE_SOFTWARE PerfEventTypeTracepoint PerfEventType = abi.PERF_TYPE_TRACEPOINT PerfEventTypeHWCache PerfEventType = abi.PERF_TYPE_HW_CACHE PerfEventTypeRaw PerfEventType = abi.PERF_TYPE_RAW PerfEventTypeBreakpoint PerfEventType = abi.PERF_TYPE_BREAKPOINT )
type PerfSampleType ¶
type PerfSampleType uint64
PerfSampleType is a Linux perf sample_type bitmask.
const ( PerfSampleIP PerfSampleType = abi.PERF_SAMPLE_IP PerfSampleTID PerfSampleType = abi.PERF_SAMPLE_TID PerfSampleTime PerfSampleType = abi.PERF_SAMPLE_TIME PerfSampleAddr PerfSampleType = abi.PERF_SAMPLE_ADDR PerfSampleRead PerfSampleType = abi.PERF_SAMPLE_READ PerfSampleCallchain PerfSampleType = abi.PERF_SAMPLE_CALLCHAIN PerfSampleID PerfSampleType = abi.PERF_SAMPLE_ID PerfSampleCPU PerfSampleType = abi.PERF_SAMPLE_CPU PerfSamplePeriod PerfSampleType = abi.PERF_SAMPLE_PERIOD PerfSampleStreamID PerfSampleType = abi.PERF_SAMPLE_STREAM_ID PerfSampleRaw PerfSampleType = abi.PERF_SAMPLE_RAW PerfSampleBranchStack PerfSampleType = abi.PERF_SAMPLE_BRANCH_STACK PerfSampleRegsUser PerfSampleType = abi.PERF_SAMPLE_REGS_USER PerfSampleStackUser PerfSampleType = abi.PERF_SAMPLE_STACK_USER PerfSampleWeight PerfSampleType = abi.PERF_SAMPLE_WEIGHT PerfSampleDataSrc PerfSampleType = abi.PERF_SAMPLE_DATA_SRC PerfSampleIdentifier PerfSampleType = abi.PERF_SAMPLE_IDENTIFIER PerfSampleTransaction PerfSampleType = abi.PERF_SAMPLE_TRANSACTION PerfSampleRegsIntr PerfSampleType = abi.PERF_SAMPLE_REGS_INTR PerfSamplePhysicalAddr PerfSampleType = abi.PERF_SAMPLE_PHYS_ADDR PerfSampleAux PerfSampleType = abi.PERF_SAMPLE_AUX PerfSampleCgroup PerfSampleType = abi.PERF_SAMPLE_CGROUP PerfSampleDataPageSize PerfSampleType = abi.PERF_SAMPLE_DATA_PAGE_SIZE PerfSampleCodePageSize PerfSampleType = abi.PERF_SAMPLE_CODE_PAGE_SIZE )
type PerfSoftwareEvent ¶
type PerfSoftwareEvent uint64
PerfSoftwareEvent is a software perf event config value.
const ( PerfSoftwareCPUClock PerfSoftwareEvent = abi.PERF_COUNT_SW_CPU_CLOCK PerfSoftwareTaskClock PerfSoftwareEvent = abi.PERF_COUNT_SW_TASK_CLOCK PerfSoftwarePageFaults PerfSoftwareEvent = abi.PERF_COUNT_SW_PAGE_FAULTS PerfSoftwareContextSwitches PerfSoftwareEvent = abi.PERF_COUNT_SW_CONTEXT_SWITCHES PerfSoftwareCPUMigrations PerfSoftwareEvent = abi.PERF_COUNT_SW_CPU_MIGRATIONS PerfSoftwareBPFOutput PerfSoftwareEvent = abi.PERF_COUNT_SW_BPF_OUTPUT PerfSoftwareCgroupSwitches PerfSoftwareEvent = abi.PERF_COUNT_SW_CGROUP_SWITCHES )
type ProbeAttachMode ¶
type ProbeAttachMode int32
const ( ProbeAttachDefault ProbeAttachMode = abi.PROBE_ATTACH_MODE_DEFAULT ProbeAttachLegacy ProbeAttachMode = abi.PROBE_ATTACH_MODE_LEGACY ProbeAttachPerf ProbeAttachMode = abi.PROBE_ATTACH_MODE_PERF ProbeAttachLink ProbeAttachMode = abi.PROBE_ATTACH_MODE_LINK )
type Program ¶
type Program struct {
// contains filtered or unexported fields
}
func (*Program) ABIHandle ¶
func (p *Program) ABIHandle() abi.ProgramHandle
func (*Program) AssociateStructOps ¶
func (p *Program) AssociateStructOps(m *Map, opts StructOpsAssociationOptions) error
func (*Program) AttachCgroupWithOptions ¶
func (p *Program) AttachCgroupWithOptions(cgroupFD int, opts CgroupOptions) (*Link, error)
func (*Program) AttachFreplace ¶
func (*Program) AttachIterator ¶
func (*Program) AttachKprobe ¶
func (*Program) AttachKprobeMulti ¶
func (*Program) AttachKprobeWithOptions ¶
func (p *Program) AttachKprobeWithOptions(function string, opts KprobeOptions) (*Link, error)
func (*Program) AttachNetfilter ¶
func (p *Program) AttachNetfilter(opts NetfilterOptions) (*Link, error)
func (*Program) AttachNetkit ¶
func (p *Program) AttachNetkit(ifindex int, opts NetkitOptions) (*Link, error)
func (*Program) AttachPerfEventWithOptions ¶
func (p *Program) AttachPerfEventWithOptions(perfEventFD int, opts PerfEventAttachOptions) (*Link, error)
func (*Program) AttachRawTracepoint ¶
func (*Program) AttachRawTracepointWithOptions ¶
func (p *Program) AttachRawTracepointWithOptions(name string, opts RawTracepointOptions) (*Link, error)
func (*Program) AttachTCX ¶
func (p *Program) AttachTCX(ifindex int, opts TCXOptions) (*Link, error)
func (*Program) AttachTrace ¶
func (*Program) AttachTraceWithOptions ¶
func (p *Program) AttachTraceWithOptions(opts TraceOptions) (*Link, error)
func (*Program) AttachTracepoint ¶
func (*Program) AttachTracepointWithOptions ¶
func (p *Program) AttachTracepointWithOptions(category, name string, opts TracepointOptions) (*Link, error)
func (*Program) AttachUSDT ¶
func (*Program) AttachUprobe ¶
func (*Program) AttachUprobeMulti ¶
func (*Program) AttachUprobeWithOptions ¶
func (*Program) Autoattach ¶
func (*Program) ExpectedAttachType ¶
func (p *Program) ExpectedAttachType() AttachType
func (*Program) FuncInfoCount ¶
func (*Program) Instructions ¶
func (*Program) LineInfo ¶
func (p *Program) LineInfo() (*ProgramLineInfo, error)
func (*Program) LineInfoCount ¶
func (*Program) SectionName ¶
func (*Program) SetAttachTarget ¶
func (*Program) SetAutoattach ¶
func (*Program) SetAutoload ¶
func (*Program) SetExpectedAttachType ¶
func (p *Program) SetExpectedAttachType(t AttachType) error
func (*Program) SetIfindex ¶
func (*Program) SetInstructions ¶
func (*Program) SetLogBuffer ¶
SetLogBuffer installs an object-owned verifier log buffer for this program. Passing zero clears the program log buffer.
func (*Program) SetLogLevel ¶
func (*Program) SetType ¶
func (p *Program) SetType(t ProgramType) error
func (*Program) SourceLineInfo ¶
SourceLineInfo returns source line-info records stored on the libbpf program.
func (*Program) TestRun ¶
func (p *Program) TestRun(opts ProgramTestRunOptions) (ProgramTestRunResult, error)
func (*Program) Type ¶
func (p *Program) Type() ProgramType
type ProgramAttachOptions ¶
type ProgramBindOptions ¶
type ProgramBindOptions struct {
Flags uint32
}
type ProgramDetachOptions ¶
type ProgramLineInfo ¶
type ProgramLineInfo struct {
// contains filtered or unexported fields
}
func ProgramLineInfoByFD ¶
func ProgramLineInfoByFD(fd int) (*ProgramLineInfo, error)
func (*ProgramLineInfo) Close ¶
func (l *ProgramLineInfo) Close() error
func (*ProgramLineInfo) LookupInstruction ¶
func (l *ProgramLineInfo) LookupInstruction(insnOffset uint32, skip uint32) (LineInfo, error)
func (*ProgramLineInfo) LookupJitedAddress ¶
type ProgramLoadOptions ¶
type ProgramLoadOptions struct {
Type ProgramType
Name string
License string
Instructions []byte
}
type ProgramQueryOptions ¶
type ProgramQueryResult ¶
type ProgramQueryResult struct {
AttachFlags uint32
ProgramIDs []uint32
ProgramAttachFlags []uint32
LinkIDs []uint32
LinkAttachFlags []uint32
Count uint32
Revision uint64
}
func QueryPrograms ¶
func QueryPrograms(targetFD int, attachType AttachType, queryFlags uint32, maxPrograms int) (ProgramQueryResult, error)
func QueryProgramsWithOptions ¶
func QueryProgramsWithOptions(target int, attachType AttachType, opts ProgramQueryOptions) (ProgramQueryResult, error)
type ProgramSectionHandler ¶
type ProgramSectionHandler struct {
// contains filtered or unexported fields
}
ProgramSectionHandler owns a registered process-wide custom BPF SEC() handler.
func RegisterProgramSectionHandler ¶
func RegisterProgramSectionHandler(opts ProgramSectionHandlerOptions) (*ProgramSectionHandler, error)
RegisterProgramSectionHandler registers a process-wide custom BPF SEC() handler. The returned handler must be closed to unregister it.
func (*ProgramSectionHandler) Close ¶
func (h *ProgramSectionHandler) Close() error
Close unregisters the custom BPF SEC() handler. Close is idempotent.
func (*ProgramSectionHandler) ID ¶
func (h *ProgramSectionHandler) ID() int
ID returns the registered libbpf handler ID, or zero after Close.
type ProgramSectionHandlerOptions ¶
type ProgramSectionHandlerOptions struct {
Section string
Fallback bool
ProgramType ProgramType
ExpectedAttachType AttachType
}
ProgramSectionHandlerOptions configures a process-wide custom BPF SEC() handler without custom callbacks.
type ProgramTestRunOptions ¶
type ProgramTestRunResult ¶
func TestRunProgram ¶
func TestRunProgram(fd int, opts ProgramTestRunOptions) (ProgramTestRunResult, error)
type ProgramType ¶
type ProgramType int32
const ( ProgramTypeUnspec ProgramType = abi.BPF_PROG_TYPE_UNSPEC ProgramTypeSocketFilter ProgramType = abi.BPF_PROG_TYPE_SOCKET_FILTER ProgramTypeKprobe ProgramType = abi.BPF_PROG_TYPE_KPROBE ProgramTypeSchedClass ProgramType = abi.BPF_PROG_TYPE_SCHED_CLS ProgramTypeSchedAction ProgramType = abi.BPF_PROG_TYPE_SCHED_ACT ProgramTypeTracepoint ProgramType = abi.BPF_PROG_TYPE_TRACEPOINT ProgramTypeXDP ProgramType = abi.BPF_PROG_TYPE_XDP ProgramTypePerfEvent ProgramType = abi.BPF_PROG_TYPE_PERF_EVENT ProgramTypeRawTracepoint ProgramType = abi.BPF_PROG_TYPE_RAW_TRACEPOINT ProgramTypeTracing ProgramType = abi.BPF_PROG_TYPE_TRACING ProgramTypeStructOps ProgramType = abi.BPF_PROG_TYPE_STRUCT_OPS ProgramTypeExtension ProgramType = abi.BPF_PROG_TYPE_EXT ProgramTypeLSM ProgramType = abi.BPF_PROG_TYPE_LSM ProgramTypeSyscall ProgramType = abi.BPF_PROG_TYPE_SYSCALL ProgramTypeNetfilter ProgramType = abi.BPF_PROG_TYPE_NETFILTER )
func (ProgramType) String ¶
func (t ProgramType) String() string
type RawPerfBufferOptions ¶
RawPerfBufferOptions configures raw perf-buffer CPU and map-key selection. CPUs and MapKeys must both be empty or have matching lengths.
type RawTracepointOptions ¶
type RawTracepointOptions struct {
Cookie uint64
}
type Ring ¶
type Ring struct {
// contains filtered or unexported fields
}
func (*Ring) AvailableDataSize ¶
func (*Ring) ConsumerPosition ¶
func (*Ring) ProducerPosition ¶
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
func NewRingBuffer ¶
func NewRingBuffer(mapFD int, callback RingBufferCallback) (*RingBuffer, error)
func (*RingBuffer) Add ¶
func (rb *RingBuffer) Add(mapFD int, callback RingBufferCallback) error
func (*RingBuffer) Close ¶
func (rb *RingBuffer) Close() error
func (*RingBuffer) Consume ¶
func (rb *RingBuffer) Consume() (int, error)
func (*RingBuffer) EpollFD ¶
func (rb *RingBuffer) EpollFD() int
type RingBufferCallback ¶
type RingBufferCallback func(RingBufferSample) error
RingBufferCallback is called synchronously from Poll, Consume, or ConsumeN. It must not call methods on the same RingBuffer.
type RingBufferSample ¶
type RingBufferSample struct {
// Data is a borrowed view into libbpf-owned memory and is only valid
// during the callback. Copy it before retaining it.
Data []byte
}
type Skeleton ¶
type Skeleton struct {
// contains filtered or unexported fields
}
Skeleton owns a libbpf skeleton descriptor and its opened object.
func NewSkeleton ¶
func NewSkeleton(spec SkeletonSpec) (*Skeleton, error)
NewSkeleton creates a skeleton descriptor from object bytes.
func (*Skeleton) MappedValue ¶
MappedValue returns a borrowed view of an mmaped skeleton map value. The returned slice is valid only while the skeleton and object remain open.
type SkeletonMapSpec ¶
SkeletonMapSpec describes a map entry expected in a BPF skeleton.
type SkeletonProgramSpec ¶
type SkeletonProgramSpec struct {
Name string
}
SkeletonProgramSpec describes a program entry expected in a BPF skeleton.
type SkeletonSpec ¶
type SkeletonSpec struct {
Name string
Data []byte
Maps []SkeletonMapSpec
Programs []SkeletonProgramSpec
}
SkeletonSpec describes a libbpf-style skeleton backed by object bytes.
type SkeletonVariableSpec ¶
SkeletonVariableSpec describes a subskeleton variable and its backing map.
type StrictMode ¶
type StrictMode uint32
type StructOpsAssociationOptions ¶
type StructOpsAssociationOptions struct {
Flags uint32
}
type Subskeleton ¶
type Subskeleton struct {
// contains filtered or unexported fields
}
Subskeleton owns a libbpf subskeleton descriptor for a borrowed object.
func OpenSubskeleton ¶
func OpenSubskeleton(spec SubskeletonSpec) (*Subskeleton, error)
OpenSubskeleton opens a subskeleton against an already-open BPF object.
func (*Subskeleton) Close ¶
func (ss *Subskeleton) Close() error
func (*Subskeleton) VariableData ¶
func (ss *Subskeleton) VariableData(name string) ([]byte, error)
VariableData returns a borrowed view of a subskeleton variable. The returned slice is valid only while the subskeleton and object remain open.
type SubskeletonSpec ¶
type SubskeletonSpec struct {
Object *Object
Maps []SkeletonMapSpec
Programs []SkeletonProgramSpec
Variables []SkeletonVariableSpec
}
SubskeletonSpec describes a subskeleton for an already-open BPF object.
type TCAttachPoint ¶
type TCAttachPoint int32
const ( TCIngress TCAttachPoint = abi.BPF_TC_INGRESS TCEgress TCAttachPoint = abi.BPF_TC_EGRESS TCCustom TCAttachPoint = abi.BPF_TC_CUSTOM TCQdisc TCAttachPoint = abi.BPF_TC_QDISC )
type TCHook ¶
type TCHook struct {
Ifindex int
AttachPoint TCAttachPoint
Parent uint32
Handle uint32
Qdisc string
}
type TCXOptions ¶
type TaskFDQueryOptions ¶
type TaskFDQueryResult ¶
type TaskFDQueryResult struct {
Name string
NameLength uint32
ProgramID uint32
FDType uint32
ProbeOffset uint64
ProbeAddress uint64
}
func TaskFDQuery ¶
func TaskFDQuery(pid, fd int, opts TaskFDQueryOptions) (TaskFDQueryResult, error)
type TokenCreateOptions ¶
type TokenCreateOptions struct {
Flags uint32
}
type TraceOptions ¶
type TraceOptions struct {
Cookie uint64
}
type TracepointOptions ¶
type TracepointOptions struct {
Cookie uint64
}
type UprobeOptions ¶
type UprobeOptions struct {
RefCounterOffset uint64
Cookie uint64
Retprobe bool
FunctionName string
AttachMode ProbeAttachMode
}
type UserRingBuffer ¶
type UserRingBuffer struct {
// contains filtered or unexported fields
}
func NewUserRingBuffer ¶
func NewUserRingBuffer(mapFD int) (*UserRingBuffer, error)
func (*UserRingBuffer) Close ¶
func (rb *UserRingBuffer) Close() error
func (*UserRingBuffer) Reserve ¶
func (rb *UserRingBuffer) Reserve(size uint32) (*UserRingSample, error)
Reserve reserves a sample. The returned sample holds ring capacity until it is submitted or discarded.
func (*UserRingBuffer) ReserveBlocking ¶
func (rb *UserRingBuffer) ReserveBlocking(size uint32, timeoutMillis int) (*UserRingSample, error)
ReserveBlocking reserves a sample, waiting up to timeoutMillis according to libbpf's user-ring-buffer rules.
type UserRingSample ¶
type UserRingSample struct {
// contains filtered or unexported fields
}
UserRingSample is a reserved user-ring record. It must be submitted or discarded exactly once.
func (*UserRingSample) Bytes ¶
func (s *UserRingSample) Bytes() []byte
Bytes returns a borrowed view that is valid only until Submit, Discard, or the parent ring buffer is closed.
func (*UserRingSample) Discard ¶
func (s *UserRingSample) Discard() error
Discard releases the reserved sample without publishing it.
func (*UserRingSample) Submit ¶
func (s *UserRingSample) Submit() error
Submit publishes the reserved sample to the ring buffer.
type WrapObjectOptions ¶
type WrapObjectOptions struct {
Ownership HandleOwnership
}
type XDPAttachMode ¶
type XDPAttachMode uint8
const ( XDPAttachedNone XDPAttachMode = abi.XDP_ATTACHED_NONE XDPAttachedDriver XDPAttachMode = abi.XDP_ATTACHED_DRV XDPAttachedSKB XDPAttachMode = abi.XDP_ATTACHED_SKB XDPAttachedHW XDPAttachMode = abi.XDP_ATTACHED_HW XDPAttachedMulti XDPAttachMode = abi.XDP_ATTACHED_MULTI )
type XDPQueryResult ¶
type XDPQueryResult struct {
ProgramID uint32
DriverProgramID uint32
HardwareProgramID uint32
SKBProgramID uint32
AttachMode XDPAttachMode
FeatureFlags uint64
ZeroCopyMaxSegments uint32
}
func XDPQuery ¶
func XDPQuery(ifindex, flags int) (XDPQueryResult, error)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package abi exposes the generated libbpf ABI for the pinned libbpf source revision.
|
Package abi exposes the generated libbpf ABI for the pinned libbpf source revision. |
|
internal
|
|
|
cmd/genbpf
command
|
|