Documentation ¶
Index ¶
- Constants
- func GetUnsafePointer(data interface{}) (unsafe.Pointer, error)
- type BPFLink
- type BPFMap
- func (b *BPFMap) DeleteKey(key unsafe.Pointer) error
- func (b *BPFMap) GetFd() int
- func (b *BPFMap) GetMaxEntries() uint32
- func (b *BPFMap) GetModule() *Module
- func (b *BPFMap) GetName() string
- func (b *BPFMap) GetPinPath() string
- func (b *BPFMap) GetValue(key unsafe.Pointer) ([]byte, error)
- func (b *BPFMap) IsPinned() bool
- func (b *BPFMap) Iterator() *BPFMapIterator
- func (b *BPFMap) KeySize() int
- func (b *BPFMap) Pin(pinPath string) error
- func (b *BPFMap) Resize(maxEntries uint32) error
- func (b *BPFMap) SetPinPath(pinPath string) error
- func (b *BPFMap) Unpin(pinPath string) error
- func (b *BPFMap) Update(key, value unsafe.Pointer) error
- func (b *BPFMap) ValueSize() int
- type BPFMapIterator
- type BPFProg
- func (p *BPFProg) AttachKprobe(kp string) (*BPFLink, error)
- func (p *BPFProg) AttachKprobeLegacy(kp string) (*BPFLink, error)
- func (p *BPFProg) AttachKretprobe(kp string) (*BPFLink, error)
- func (p *BPFProg) AttachKretprobeLegacy(kp string) (*BPFLink, error)
- func (p *BPFProg) AttachLSM() (*BPFLink, error)
- func (p *BPFProg) AttachPerfEvent(fd int) (*BPFLink, error)
- func (p *BPFProg) AttachRawTracepoint(tpEvent string) (*BPFLink, error)
- func (p *BPFProg) AttachTracepoint(tp string) (*BPFLink, error)
- func (p *BPFProg) AttachURetprobe(pid int, path string, offset uint32) (*BPFLink, error)
- func (p *BPFProg) AttachUprobe(pid int, path string, offset uint32) (*BPFLink, error)
- func (p *BPFProg) GetFd() int
- func (p *BPFProg) GetModule() *Module
- func (p *BPFProg) GetName() string
- func (p *BPFProg) GetType() uint32
- func (p *BPFProg) SetAutoload(autoload bool) error
- func (p *BPFProg) SetTracepoint() error
- type BPFProgType
- type LinkType
- type Module
- func (m *Module) BPFLoadObject() error
- func (m *Module) Close()
- func (m *Module) GetMap(mapName string) (*BPFMap, error)
- func (m *Module) GetProgram(progName string) (*BPFProg, error)
- func (m *Module) InitPerfBuf(mapName string, eventsChan chan []byte, lostChan chan uint64, pageCnt int) (*PerfBuffer, error)
- func (m *Module) InitRingBuf(mapName string, eventsChan chan []byte) (*RingBuffer, error)
- func (m *Module) TcHookInit() *TcHook
- type NewModuleArgs
- type PerfBuffer
- type RingBuffer
- type TcAttachPoint
- type TcFlags
- type TcHook
- func (hook *TcHook) Attach(tcOpts *TcOpts) error
- func (hook *TcHook) Create() error
- func (hook *TcHook) Destroy() error
- func (hook *TcHook) Detach(tcOpts *TcOpts) error
- func (hook *TcHook) GetInterfaceIndex() int
- func (hook *TcHook) Query(tcOpts *TcOpts) error
- func (hook *TcHook) SetAttachPoint(attachPoint TcAttachPoint)
- func (hook *TcHook) SetInterfaceByIndex(ifaceIdx int)
- func (hook *TcHook) SetInterfaceByName(ifaceName string) error
- func (hook *TcHook) SetParent(a int, b int)
- type TcOpts
Constants ¶
const ( BPFProgTypeUnspec uint32 = iota BPFProgTypeSocketFilter BPFProgTypeKprobe BPFProgTypeSchedCls BPFProgTypeSchedAct BPFProgTypeTracepoint BPFProgTypeXdp BPFProgTypePerfEvent BPFProgTypeCgroupSkb BPFProgTypeCgroupSock BPFProgTypeLwtIn BPFProgTypeLwtOut BPFProgTypeLwtXmit BPFProgTypeSockOps BPFProgTypeSkSkb BPFProgTypeCgroupDevice BPFProgTypeSkMsg BPFProgTypeRawTracepoint BPFProgTypeCgroupSockAddr BPFProgTypeLwtSeg6Local BPFProgTypeLircMode2 BPFProgTypeSkReuseport BPFProgTypeFlowDissector BPFProgTypeCgroupSysctl BPFProgTypeRawTracepointWritable BPFProgTypeCgroupSockopt BPFProgTypeTracing BPFProgTypeStructOps BPFProgTypeExt BPFProgTypeLsm BPFProgTypeSkLookup )
Variables ¶
This section is empty.
Functions ¶
func GetUnsafePointer ¶
Types ¶
type BPFMap ¶
type BPFMap struct {
// contains filtered or unexported fields
}
func (*BPFMap) DeleteKey ¶
DeleteKey takes a pointer to the key which is stored in the map. It removes the key and associated value from the BPFMap. All basic types, and structs are supported as keys.
NOTE: Slices and arrays are also supported but special care should be taken as to take a reference to the first element in the slice or array instead of the slice/array itself, as to avoid undefined behavior.
func (*BPFMap) GetMaxEntries ¶
GetMaxEntries returns the map's capacity. Note: for ring buffer and perf buffer, maxEntries is the capacity in bytes.
func (*BPFMap) GetPinPath ¶
func (*BPFMap) GetValue ¶
GetValue takes a pointer to the key which is stored in the map. It returns the associated value as a slice of bytes. All basic types, and structs are supported as keys.
NOTE: Slices and arrays are also supported but special care should be taken as to take a reference to the first element in the slice or array instead of the slice/array itself, as to avoid undefined behavior.
func (*BPFMap) Iterator ¶
func (b *BPFMap) Iterator() *BPFMapIterator
func (*BPFMap) Resize ¶
Resize changes the map's capacity to maxEntries. It should be called after the module was initialized but prior to it being loaded with BPFLoadObject. Note: for ring buffer and perf buffer, maxEntries is the capacity in bytes.
func (*BPFMap) SetPinPath ¶
func (*BPFMap) Update ¶
Update takes a pointer to a key and a value to associate it with in the BPFMap. The unsafe.Pointer should be taken on a reference to the underlying datatype. All basic types, and structs are supported
NOTE: Slices and arrays are supported but references should be passed to the first element in the slice or array.
For example:
key := 1 value := []byte{'a', 'b', 'c'} keyPtr := unsafe.Pointer(&key) valuePtr := unsafe.Pointer(&value[0]) bpfmap.Update(keyPtr, valuePtr)
type BPFMapIterator ¶
type BPFMapIterator struct {
// contains filtered or unexported fields
}
func (*BPFMapIterator) Err ¶
func (it *BPFMapIterator) Err() error
Err returns the last error that ocurred while table.Iter or iter.Next
func (*BPFMapIterator) Key ¶
func (it *BPFMapIterator) Key() []byte
Key returns the current key value of the iterator, if the most recent call to Next returned true. The slice is valid only until the next call to Next.
func (*BPFMapIterator) Next ¶
func (it *BPFMapIterator) Next() bool
type BPFProg ¶
type BPFProg struct {
// contains filtered or unexported fields
}
func (*BPFProg) AttachKprobe ¶
this API should be used for kernels > 4.17
func (*BPFProg) AttachKprobeLegacy ¶
func (*BPFProg) AttachKretprobe ¶
this API should be used for kernels > 4.17
func (*BPFProg) AttachKretprobeLegacy ¶
func (*BPFProg) AttachRawTracepoint ¶
func (*BPFProg) AttachURetprobe ¶
AttachURetprobe attaches the BPFProgram to exit of the symbol in the library or binary at 'path' which can be relative or absolute. A pid can be provided to attach to, or -1 can be specified to attach to all processes
func (*BPFProg) AttachUprobe ¶
AttachUprobe attaches the BPFProgram to entry of the symbol in the library or binary at 'path' which can be relative or absolute. A pid can be provided to attach to, or -1 can be specified to attach to all processes
func (*BPFProg) SetAutoload ¶
func (*BPFProg) SetTracepoint ¶
type BPFProgType ¶
type BPFProgType uint32
BPFProgType is an enum as defined in https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/bpf.h
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func NewModuleFromBuffer ¶
func NewModuleFromBufferArgs ¶
func NewModuleFromBufferArgs(args NewModuleArgs) (*Module, error)
func NewModuleFromFile ¶
func NewModuleFromFileArgs ¶
func NewModuleFromFileArgs(args NewModuleArgs) (*Module, error)
func (*Module) BPFLoadObject ¶
func (*Module) InitPerfBuf ¶
func (*Module) InitRingBuf ¶
func (m *Module) InitRingBuf(mapName string, eventsChan chan []byte) (*RingBuffer, error)
func (*Module) TcHookInit ¶
type NewModuleArgs ¶
type PerfBuffer ¶
type PerfBuffer struct {
// contains filtered or unexported fields
}
func (*PerfBuffer) Close ¶
func (pb *PerfBuffer) Close()
func (*PerfBuffer) Start ¶
func (pb *PerfBuffer) Start()
func (*PerfBuffer) Stop ¶
func (pb *PerfBuffer) Stop()
type RingBuffer ¶
type RingBuffer struct {
// contains filtered or unexported fields
}
func (*RingBuffer) Close ¶
func (rb *RingBuffer) Close()
func (*RingBuffer) Start ¶
func (rb *RingBuffer) Start()
func (*RingBuffer) Stop ¶
func (rb *RingBuffer) Stop()
type TcAttachPoint ¶
type TcAttachPoint uint32
const ( BPFTcIngress TcAttachPoint = C.BPF_TC_INGRESS BPFTcEgress TcAttachPoint = C.BPF_TC_EGRESS BPFTcIngressEgress TcAttachPoint = C.BPF_TC_INGRESS | C.BPF_TC_EGRESS BPFTcCustom TcAttachPoint = C.BPF_TC_CUSTOM )
type TcHook ¶
type TcHook struct {
// contains filtered or unexported fields
}
func (*TcHook) GetInterfaceIndex ¶
func (*TcHook) SetAttachPoint ¶
func (hook *TcHook) SetAttachPoint(attachPoint TcAttachPoint)
func (*TcHook) SetInterfaceByIndex ¶
func (*TcHook) SetInterfaceByName ¶
Directories ¶
Path | Synopsis |
---|---|
selftest
|
|
attachgenericfd
Module
|
|
global-variable
Module
|
|
iter
Module
|
|
iterators
Module
|
|
log-callbacks
Module
|
|
map-pin-info
Module
|
|
map-update
Module
|
|
module-attach-detach
Module
|
|
perfbuffers
Module
|
|
tracing
Module
|
|
tracing-by-offset
Module
|
|
uprobe
Module
|