Documentation
¶
Overview ¶
Package goebpf provides a simple library for handling eBPF programs. The eBPF programs have to be compiled with the header file coming with the package. This package provides a way to load the generated elf binaries and to do lookups on the eBPF maps.
Index ¶
- func GetTimeMonotonicNs() uint64
- type BPFMap
- type BPFMapIterator
- type BPFMapType
- type BPFProg
- func (b *BPFProg) Attach(ifname string) (int, error)
- func (b *BPFProg) Detach(fd int) error
- func (b *BPFProg) Load() error
- func (b *BPFProg) Log() []byte
- func (b *BPFProg) Map(name string) *BPFMap
- func (b *BPFProg) Maps() map[string]*BPFMap
- func (b *BPFProg) Release()
- func (b *BPFProg) SetDefaultMaxEntries(max int)
- func (b *BPFProg) SetMaxEntries(table string, max int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetTimeMonotonicNs ¶
func GetTimeMonotonicNs() uint64
Types ¶
type BPFMap ¶
type BPFMap struct { Name string // contains filtered or unexported fields }
BPFMap represents a eBPF map. An eBPF map has to be declared in the C file using the macro MAP provided by the libbpf.h header file.
func (*BPFMap) Iterator ¶
func (m *BPFMap) Iterator() *BPFMapIterator
Iterator returns a BPFMapIterator
func (*BPFMap) Lookup ¶
Lookup does a lookup on the corresponding BPFMap. Key/values parameters need to be pointers and need to be be used according to the eBPF map definition declared in the eBPF C file. See the libbpf.h file coming with this package.
func (*BPFMap) Type ¶
func (m *BPFMap) Type() BPFMapType
Type returns the type of a BPFMap wich is the type of the eBPF map.
type BPFMapIterator ¶
type BPFMapIterator struct {
// contains filtered or unexported fields
}
func (*BPFMapIterator) Next ¶
func (i *BPFMapIterator) Next(key interface{}, value interface{}) bool
Next returns the next key, value of the BPFMap, returns true when the next element has been found, false otherwise.
type BPFMapType ¶
type BPFMapType uint32
A BPFMapType represents a eBPF map type
const ( BPF_MAP_TYPE_UNSPEC BPFMapType = C.BPF_MAP_TYPE_UNSPEC BPF_MAP_TYPE_HASH BPF_MAP_TYPE_ARRAY BPF_MAP_TYPE_PROG_ARRAY BPF_MAP_TYPE_PERF_EVENT_ARRAY BPF_MAP_TYPE_PERCPU_HASH BPF_MAP_TYPE_PERCPU_ARRAY BPF_MAP_TYPE_STACK_TRACE )
Types of maps
type BPFProg ¶
type BPFProg struct {
// contains filtered or unexported fields
}
BPFMap represents a eBPF program.
func (*BPFProg) Map ¶
Map returns the BPFMap for the given name. The name is the name used for the map declaration with the MAP macro is the eBPF C file.
func (*BPFProg) Release ¶
func (b *BPFProg) Release()
Release releases the memory allocated by a BPFProg.
func (*BPFProg) SetDefaultMaxEntries ¶
SetDefaultMaxEntries sets the default max_entries for all the maps that will be loaded, if not defined the value