Documentation ¶
Index ¶
- Constants
- func CheckOrMountFS(bpfRoot string)
- func ConvertKeyValue(bKey []byte, bValue []byte, key interface{}, value interface{}) error
- func CreateMap(mapType int, keySize, valueSize, maxEntries, flags, innerID uint32, ...) (int, error)
- func DeleteElement(fd int, key unsafe.Pointer) error
- func DisableMapPreAllocation()
- func EnableMapPreAllocation()
- func Environment() []string
- func GetMapPrefix() string
- func GetMapRoot() string
- func GetMtime() (uint64, error)
- func GetNextKey(fd int, key, nextKey unsafe.Pointer) error
- func GetOpenMaps() []*models.BPFMap
- func GetPreAllocateMapFlags(t MapType) uint32
- func GetProgFDByID(id uint32) (int, error)
- func GetProgNextID(current uint32) (uint32, error)
- func LocalMapName(name string, id uint16) string
- func LocalMapPath(name string, id uint16) string
- func LookupElement(fd int, key, value unsafe.Pointer) error
- func MapFdFromID(id int) (int, error)
- func MapPath(name string) string
- func MapPrefixPath() string
- func ObjClose(fd int) error
- func ObjGet(pathname string) (int, error)
- func ObjPin(fd int, pathname string) error
- func OpenOrCreateMap(path string, mapType int, keySize, valueSize, maxEntries, flags uint32, ...) (int, bool, error)
- func ReadFeatureProbes(filename string)
- func SetMapPrefix(path string)
- func SetMapRoot(path string)
- func UpdateElement(fd int, key, value unsafe.Pointer, flags uint64) error
- type DesiredAction
- type DumpCallback
- type DumpParser
- type DumpStats
- type EPoll
- type EndpointKey
- type ErrorFunc
- type EventMap
- type LostFunc
- type Map
- func (m *Map) CheckAndUpgrade(desired *MapInfo) bool
- func (m *Map) Close() error
- func (m *Map) DeepEquals(other *Map) bool
- func (m *Map) Delete(key MapKey) error
- func (m *Map) DeleteAll() error
- func (m *Map) DeleteWithErrno(key MapKey) (error, syscall.Errno)
- func (m *Map) Dump(hash map[string][]string) error
- func (m *Map) DumpIfExists(hash map[string][]string) error
- func (m *Map) DumpReliablyWithCallback(cb DumpCallback, stats *DumpStats) error
- func (m *Map) DumpWithCallback(cb DumpCallback) error
- func (m *Map) DumpWithCallbackIfExists(cb DumpCallback) error
- func (m *Map) EndParallelMode()
- func (m *Map) GetFd() int
- func (m *Map) GetModel() *models.BPFMap
- func (m *Map) GetNextKey(key MapKey, nextKey MapKey) error
- func (m *Map) Lookup(key MapKey) (MapValue, error)
- func (m *Map) Name() string
- func (m *Map) Open() error
- func (m *Map) OpenOrCreate() (bool, error)
- func (m *Map) OpenParallel() (bool, error)
- func (m *Map) Path() (string, error)
- func (m *Map) Reopen() error
- func (m *Map) Unpin() error
- func (m *Map) UnpinIfExists() error
- func (m *Map) Update(key MapKey, value MapValue) error
- func (m *Map) WithCache() *Map
- func (m *Map) WithNonPersistent() *Map
- type MapInfo
- type MapKey
- type MapType
- type MapValidator
- type MapValue
- type PerCpuEvents
- type PerfEvent
- func (e *PerfEvent) Close()
- func (e *PerfEvent) Debug() string
- func (e *PerfEvent) DebugDump() string
- func (e *PerfEvent) Disable() error
- func (e *PerfEvent) Enable() error
- func (e *PerfEvent) Mmap(pagesize int, npages int) error
- func (e *PerfEvent) Munmap() error
- func (e *PerfEvent) Read(receive ReceiveFunc, lostFn LostFunc, err ErrorFunc)
- type PerfEventConfig
- type PerfEventHeader
- type PerfEventLost
- type PerfEventMmapPage
- type PerfEventSample
- type ProgInfo
- type ProgType
- type ReadState
- type ReceiveFunc
Constants ¶
const ( // BPF map type constants. Must match enum bpf_map_type from linux/bpf.h BPF_MAP_TYPE_UNSPEC = 0 BPF_MAP_TYPE_HASH = 1 BPF_MAP_TYPE_ARRAY = 2 BPF_MAP_TYPE_PROG_ARRAY = 3 BPF_MAP_TYPE_PERF_EVENT_ARRAY = 4 BPF_MAP_TYPE_PERCPU_HASH = 5 BPF_MAP_TYPE_PERCPU_ARRAY = 6 BPF_MAP_TYPE_STACK_TRACE = 7 BPF_MAP_TYPE_CGROUP_ARRAY = 8 BPF_MAP_TYPE_LRU_HASH = 9 BPF_MAP_TYPE_LRU_PERCPU_HASH = 10 BPF_MAP_TYPE_LPM_TRIE = 11 BPF_MAP_TYPE_ARRAY_OF_MAPS = 12 BPF_MAP_TYPE_HASH_OF_MAPS = 13 BPF_MAP_TYPE_DEVMAP = 14 BPF_MAP_TYPE_SOCKMAP = 15 BPF_MAP_TYPE_CPUMAP = 16 BPF_MAP_TYPE_XSKMAP = 17 BPF_MAP_TYPE_SOCKHASH = 18 BPF_MAP_TYPE_CGROUP_STORAGE = 19 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY = 20 // BPF syscall command constants. Must match enum bpf_cmd from linux/bpf.h BPF_MAP_CREATE = 0 BPF_MAP_LOOKUP_ELEM = 1 BPF_MAP_UPDATE_ELEM = 2 BPF_MAP_DELETE_ELEM = 3 BPF_MAP_GET_NEXT_KEY = 4 BPF_PROG_LOAD = 5 BPF_OBJ_PIN = 6 BPF_OBJ_GET = 7 BPF_PROG_ATTACH = 8 BPF_PROG_DETACH = 9 BPF_PROG_TEST_RUN = 10 BPF_PROG_GET_NEXT_ID = 11 BPF_MAP_GET_NEXT_ID = 12 BPF_PROG_GET_FD_BY_ID = 13 BPF_MAP_GET_FD_BY_ID = 14 BPF_OBJ_GET_INFO_BY_FD = 15 BPF_PROG_QUERY = 16 BPF_RAW_TRACEPOINT_OPEN = 17 BPF_BTF_LOAD = 18 BPF_BTF_GET_FD_BY_ID = 19 BPF_TASK_FD_QUERY = 20 // Flags for BPF_MAP_UPDATE_ELEM. Must match values from linux/bpf.h BPF_ANY = 0 BPF_NOEXIST = 1 BPF_EXIST = 2 // Flags for BPF_MAP_CREATE. Must match values from linux/bpf.h BPF_F_NO_PREALLOC = 1 << 0 BPF_F_NO_COMMON_LRU = 1 << 1 BPF_F_NUMA_NODE = 1 << 2 // Flags for BPF_PROG_QUERY BPF_F_QUERY_EFFECTVE = 1 << 0 // Flags for accessing BPF object BPF_F_RDONLY = 1 << 3 BPF_F_WRONLY = 1 << 4 // Flag for stack_map, store build_id+offset instead of pointer BPF_F_STACK_BUILD_ID = 1 << 5 )
const ( EndpointKeyIPv4 uint8 = 1 EndpointKeyIPv6 uint8 = 2 )
Must be in sync with ENDPOINT_KEY_* in <bpf/lib/common.h>
const ( EventsMapName = "cilium_events" PERF_TYPE_HARDWARE = 0 PERF_TYPE_SOFTWARE = 1 PERF_TYPE_TRACEPOINT = 2 PERF_TYPE_HW_CACHE = 3 PERF_TYPE_RAW = 4 PERF_TYPE_BREAKPOINT = 5 PERF_SAMPLE_IP = 1 << 0 PERF_SAMPLE_TID = 1 << 1 PERF_SAMPLE_TIME = 1 << 2 PERF_SAMPLE_ADDR = 1 << 3 PERF_SAMPLE_READ = 1 << 4 PERF_SAMPLE_CALLCHAIN = 1 << 5 PERF_SAMPLE_ID = 1 << 6 PERF_SAMPLE_CPU = 1 << 7 PERF_SAMPLE_PERIOD = 1 << 8 PERF_SAMPLE_STREAM_ID = 1 << 9 PERF_SAMPLE_RAW = 1 << 10 PERF_SAMPLE_BRANCH_STACK = 1 << 11 PERF_SAMPLE_REGS_USER = 1 << 12 PERF_SAMPLE_STACK_USER = 1 << 13 PERF_SAMPLE_WEIGHT = 1 << 14 PERF_SAMPLE_DATA_SRC = 1 << 15 PERF_SAMPLE_IDENTIFIER = 1 << 16 PERF_SAMPLE_TRANSACTION = 1 << 17 PERF_SAMPLE_REGS_INTR = 1 << 18 PERF_COUNT_SW_BPF_OUTPUT = 10 )
const (
MAX_POLL_EVENTS = 32
)
Variables ¶
This section is empty.
Functions ¶
func CheckOrMountFS ¶ added in v1.5.0
func CheckOrMountFS(bpfRoot string)
CheckOrMountFS checks or mounts the BPF filesystem and then opens/creates/deletes all maps which have previously been scheduled to be opened/created/deleted.
func ConvertKeyValue ¶ added in v1.5.0
ConvertKeyValue converts key and value from bytes to given Golang struct pointers.
func CreateMap ¶
func CreateMap(mapType int, keySize, valueSize, maxEntries, flags, innerID uint32, path string) (int, error)
CreateMap creates a Map of type mapType, with key size keySize, a value size of valueSize and the maximum amount of entries of maxEntries. mapType should be one of the bpf_map_type in "uapi/linux/bpf.h" When mapType is the type HASH_OF_MAPS an innerID is required to point at a map fd which has the same type/keySize/valueSize/maxEntries as expected map entries. For all other mapTypes innerID is ignored and should be zeroed.
func DeleteElement ¶
DeleteElement deletes the map element with the given key.
func DisableMapPreAllocation ¶ added in v1.5.0
func DisableMapPreAllocation()
DisableMapPreAllocation disables BPF map pre-allocation as a default setting. Some map types enforces pre-alloc strategy so this does not take effect in that case. Also note that this does not take effect on existing map although could be recreated later when objCheck() runs.
func EnableMapPreAllocation ¶ added in v1.5.0
func EnableMapPreAllocation()
EnableMapPreAllocation enables BPF map pre-allocation on map types that support it. This does not take effect on existing map although some map types could be recreated later when objCheck() runs.
func Environment ¶ added in v1.5.0
func Environment() []string
Environment returns a list of environment variables which are needed to make BPF programs and tc aware of the actual BPFFS mount path.
func GetMapPrefix ¶
func GetMapPrefix() string
func GetMapRoot ¶
func GetMapRoot() string
func GetMtime ¶ added in v0.9.0
GetMtime returns monotonic time that can be used to compare values with ktime_get_ns() BPF helper, e.g. needed to check the timeout in sec for BPF entries. We return the raw nsec, although that is not quite usable for comparison. Go has runtime.nanotime() but doesn't expose it as API.
func GetNextKey ¶
GetNextKey stores, in nextKey, the next key after the key of the map in fd.
func GetOpenMaps ¶ added in v1.5.0
GetOpenMaps returns a slice of all open BPF maps. This is identical to calling GetMap() on all open maps.
func GetPreAllocateMapFlags ¶ added in v1.5.0
GetPreAllocateMapFlags returns the map flags for map which use conditional pre-allocation.
func GetProgFDByID ¶ added in v1.5.0
GetProgFDByID returns the file descriptor for the program id.
func GetProgNextID ¶ added in v1.5.0
GetProgNextID takes a current program ID and returns the next program ID.
func LocalMapName ¶ added in v1.5.0
LocalMapName returns the name for a BPF map that is local to the specified ID.
func LocalMapPath ¶ added in v1.5.0
LocalMapPath returns the path for a BPF map that is local to the specified ID.
func LookupElement ¶
LookupElement looks up for the map value stored in fd with the given key. The value is stored in the value unsafe.Pointer.
func MapFdFromID ¶ added in v1.5.0
MapFdFromID retrieves a file descriptor based on a map ID.
func MapPrefixPath ¶
func MapPrefixPath() string
func OpenOrCreateMap ¶
func ReadFeatureProbes ¶ added in v1.5.0
func ReadFeatureProbes(filename string)
ReadFeatureProbes reads the bpf_features.h file at the specified path (as generated by bpf/run_probes.sh), and stores the results of the kernel feature probing.
func SetMapPrefix ¶
func SetMapPrefix(path string)
func SetMapRoot ¶
func SetMapRoot(path string)
func UpdateElement ¶
UpdateElement updates the map in fd with the given value in the given key. The flags can have the following values: bpf.BPF_ANY to create new element or update existing; bpf.BPF_NOEXIST to create new element if it didn't exist; bpf.BPF_EXIST to update existing element.
Types ¶
type DesiredAction ¶ added in v1.5.0
type DesiredAction int
DesiredAction is the action to be performed on the BPF map
const ( // OK indicates that to further action is required and the entry is in // sync OK DesiredAction = iota // Insert indicates that the entry needs to be created or updated Insert // Delete indicates that the entry needs to be deleted Delete )
func (DesiredAction) String ¶ added in v1.5.0
func (d DesiredAction) String() string
type DumpCallback ¶
type DumpStats ¶ added in v1.5.0
type DumpStats struct { // Started is the timestamp when the gc run was started. Started time.Time // Finished is the timestamp when the gc run completed. Finished time.Time // Lookup is the number of key lookups performed. Lookup uint32 // LookupFailed is the number of key lookups that failed. LookupFailed uint32 // available. PrevKeyUnavailable uint32 // KeyFallback is the number of times the current key became invalid // while traversing and we had to fall back to the previous key. KeyFallback uint32 // MaxEntries is the maximum number of entries in the gc table. MaxEntries uint32 // Interrupted is the number of times the gc run was interrupted and // had to start from scratch. Interrupted uint32 // Completed is true when the gc run has been completed. Completed bool }
DumpStats tracks statistics over the dump of a map.
func NewDumpStats ¶ added in v1.5.0
NewDumpStats returns a new stats structure for collecting dump statistics.
type EndpointKey ¶ added in v1.5.0
type EndpointKey struct { // represents both IPv6 and IPv4 (in the lowest four bytes) IP types.IPv6 `align:"$union0"` Family uint8 `align:"family"` Key uint8 `align:"key"` Pad2 uint16 `align:"pad5"` }
EndpointKey represents the key value of the endpoints BPF map
Must be in sync with struct endpoint_key in <bpf/lib/common.h>
func NewEndpointKey ¶ added in v1.5.0
func NewEndpointKey(ip net.IP) EndpointKey
NewEndpointKey returns an EndpointKey based on the provided IP address. The address family is automatically detected.
func (*EndpointKey) GetKeyPtr ¶ added in v1.5.0
func (k *EndpointKey) GetKeyPtr() unsafe.Pointer
GetKeyPtr returns the unsafe pointer to the BPF key
func (*EndpointKey) GetValuePtr ¶ added in v1.5.0
func (k *EndpointKey) GetValuePtr() unsafe.Pointer
GetValuePtr returns the unsafe pointer to the BPF key for users that use EndpointKey as a value in bpf maps
func (EndpointKey) String ¶ added in v1.5.0
func (k EndpointKey) String() string
String provides a string representation of the EndpointKey.
func (EndpointKey) ToIP ¶ added in v1.5.0
func (k EndpointKey) ToIP() net.IP
ToIP converts the EndpointKey into a net.IP structure.
type ErrorFunc ¶ added in v1.5.0
type ErrorFunc func(msg *PerfEvent)
ErrorFunc is run when reading PerfEvent results in an error
type LostFunc ¶
type LostFunc func(msg *PerfEventLost, cpu int)
type Map ¶
type Map struct { MapInfo // NonPersistent is true if the map does not contain persistent data // and should be removed on startup. NonPersistent bool // contains filtered or unexported fields }
func GetMap ¶ added in v1.5.0
GetMap returns the registered map with the given name or absolute path
func NewMap ¶
func NewMap(name string, mapType MapType, keySize int, valueSize int, maxEntries int, flags uint32, innerID uint32, dumpParser DumpParser) *Map
NewMap creates a new Map instance - object representing a BPF map
func (*Map) CheckAndUpgrade ¶ added in v1.5.0
CheckAndUpgrade checks the received map's properties (for the map currently loaded into the kernel) against the desired properties, and if they do not match, deletes the map.
Returns true if the map was upgraded.
func (*Map) DeepEquals ¶ added in v1.5.0
DeepEquals compares the current map against another map to see that the attributes of the two maps are the same.
func (*Map) DeleteAll ¶
DeleteAll deletes all entries of a map by traversing the map and deleting individual entries. Note that if entries are added while the taversal is in progress, such entries may survive the deletion process.
func (*Map) DeleteWithErrno ¶ added in v1.5.0
func (*Map) Dump ¶
Dump returns the map (type map[string][]string) which contains all data stored in BPF map.
func (*Map) DumpIfExists ¶ added in v1.5.0
DumpIfExists dumps the contents of the map into hash via Dump() if the map file exists
func (*Map) DumpReliablyWithCallback ¶ added in v1.5.0
func (m *Map) DumpReliablyWithCallback(cb DumpCallback, stats *DumpStats) error
DumpReliablyWithCallback is similar to DumpWithCallback, but performs additional tracking of the current and recently seen keys, so that if an element is removed from the underlying kernel map during the dump, the dump can continue from a recently seen key rather than restarting from scratch. In addition, it caps the maximum number of map entry iterations by the maximum size of the map.
The caller must provide a callback for handling each entry, and a stats object initialized via a call to NewDumpStats().
func (*Map) DumpWithCallback ¶ added in v1.5.0
func (m *Map) DumpWithCallback(cb DumpCallback) error
DumpWithCallback iterates over the Map and calls the given callback function on each iteration. That callback function is receiving the actual key and value.
func (*Map) DumpWithCallbackIfExists ¶ added in v1.5.0
func (m *Map) DumpWithCallbackIfExists(cb DumpCallback) error
DumpWithCallbackIfExists is similar to DumpWithCallback, but returns earlier if the given map does not exist.
func (*Map) EndParallelMode ¶ added in v1.5.0
func (m *Map) EndParallelMode()
EndParallelMode ends the parallel mode of a map
func (*Map) GetModel ¶ added in v1.5.0
GetModel returns a BPF map in the representation served via the API
func (*Map) GetNextKey ¶ added in v0.9.0
GetNextKey returns the next key in the Map after key.
func (*Map) OpenOrCreate ¶
OpenOrCreate attempts to open the Map, or if it does not yet exist, create the Map. If the existing map's attributes such as map type, key/value size, capacity, etc. do not match the Map's attributes, then the map will be deleted and reopened without any attempt to retain its previous contents. If the map is marked as non-persistent, it will always be recreated.
If the map type is MapTypeLRUHash or MapTypeLPMTrie and the kernel lacks support for this map type, then the map will be opened as MapTypeHash instead. Note that the BPF code that interacts with this map *MUST* be structured in such a way that the map is declared as the same type based on the same probe logic (eg HAVE_LRU_MAP_TYPE, HAVE_LPM_MAP_TYPE).
For code that uses an LPMTrie, the BPF code must also use macros to retain the "longest prefix match" behaviour on top of the hash maps, for example via LPM_LOOKUP_FN() (see bpf/lib/maps.h).
To detect map type support properly, this function must be called after a call to ReadFeatureProbes(); failure to do so will result in LPM or LRU map types being unconditionally opened as hash maps.
Returns whether the map was deleted and recreated, or an optional error.
func (*Map) OpenParallel ¶ added in v1.5.0
OpenParallel is similar to OpenOrCreate() but prepares the existing map to be faded out while a new map is taking over. This can be used if a map is shared between multiple consumers and the context of the shared map is changing. Any update to the shared map would impact all consumers and consumers can only be updated one by one. Parallel mode allows for consumers to continue using the old version of the map until the consumer is updated to use the new version.
func (*Map) UnpinIfExists ¶ added in v1.5.0
UnpinIfExists tries to unpin (remove) the map only if it exists.
func (*Map) WithCache ¶ added in v1.5.0
WithCache enables use of a cache. This will store all entries inserted from user space in a local cache (map) and will indicate the status of each individual entry.
func (*Map) WithNonPersistent ¶ added in v0.10.0
WithNonPersistent turns the map non-persistent and returns the map
type MapInfo ¶
type MapType ¶
type MapType int
MapType is an enumeration for valid BPF map types
const ( MapTypeUnspec MapType = iota MapTypeHash MapTypeArray MapTypeProgArray MapTypePerfEventArray MapTypePerCPUHash MapTypePerCPUArray MapTypeStackTrace MapTypeCgroupArray MapTypeLRUHash MapTypeLRUPerCPUHash MapTypeLPMTrie MapTypeArrayOfMaps MapTypeHashOfMaps MapTypeDevMap MapTypeSockMap MapTypeCPUMap MapTypeXSKMap MapTypeSockHash // MapTypeMaximum is the maximum supported known map type. MapTypeMaximum )
This enumeration must be in sync with enum bpf_prog_type in <linux/bpf.h>
func GetMapType ¶ added in v1.5.0
GetMapType determines whether the specified map type is supported by the kernel (as determined by ReadFeatureProbes()), and if the map type is not supported, returns a more primitive map type that may be used to implement the map on older implementations. Otherwise, returns the specified map type.
type MapValidator ¶ added in v1.5.0
type PerCpuEvents ¶
type PerCpuEvents struct { Cpus int Npages int Pagesize int // contains filtered or unexported fields }
func NewPerCpuEvents ¶
func NewPerCpuEvents(config *PerfEventConfig) (*PerCpuEvents, error)
func (*PerCpuEvents) CloseAll ¶
func (e *PerCpuEvents) CloseAll() error
func (*PerCpuEvents) ReadAll ¶
func (e *PerCpuEvents) ReadAll(receive ReceiveFunc, lost LostFunc, handleError ErrorFunc) error
ReadAll reads perf events
type PerfEvent ¶
type PerfEvent struct { Fd int // contains filtered or unexported fields }
func PerfEventFromMemory ¶ added in v1.5.0
func PerfEventFromMemory(page *PerfEventMmapPage, buf []byte) *PerfEvent
PerfEventFromMemory creates an in-memory PerfEvent object for testing and analysis purposes. No kernel interaction is made.
The caller MUST eventually call Disable() to free event resources.
func PerfEventOpen ¶
func (*PerfEvent) Debug ¶ added in v1.5.0
Debug returns string with internal information about PerfEvent
func (*PerfEvent) Read ¶
func (e *PerfEvent) Read(receive ReceiveFunc, lostFn LostFunc, err ErrorFunc)
Read attempts to read all events from the perf event buffer, calling one of the receive / lost functions for each event. receiveFn is called when the event is a valid sample; lostFn is called when the kernel has attempted to write an event into the ringbuffer but ran out of space for the event.
If all events are not read within a time period (default 20s), it will call errFn() and stop reading events.
type PerfEventConfig ¶
type PerfEventConfig struct { NumCpus int NumPages int MapName string Type int Config int SampleType int WakeupEvents int }
func DefaultPerfEventConfig ¶
func DefaultPerfEventConfig() *PerfEventConfig
type PerfEventHeader ¶
PerfEventHeader must match 'struct perf_event_header in <linux/perf_event.h>.
type PerfEventLost ¶
type PerfEventLost struct { PerfEventHeader Id uint64 Lost uint64 }
PerfEventLost must match 'struct perf_event_lost in kernel sources.
type PerfEventMmapPage ¶ added in v1.5.0
type PerfEventMmapPage struct { Version uint32 // version number of this structure CompatVersion uint32 // lowest version this is compat with Lock uint32 // seqlock for synchronization Index uint32 // hardware event identifier Offset int64 // add to hardware event value TimeEnabled uint64 // time event active TimeRunning uint64 // time event on cpu //union { Capabilities uint64 // cap_user_rdpmc : 1, /* The RDPMC instruction can be used to read counts */ // cap_user_time : 1, /* The time_* fields are used */ // cap_user_time_zero : 1, /* The time_zero field is used */ // cap_____res : 59; //}; //}; PmcWidth uint16 TimeShift uint16 TimeMult uint32 TimeOffset uint64 TimeZero uint64 Size uint32 Reserved [118*8 + 4]uint8 // align to 1k. DataHead uint64 // head in the data section DataTail uint64 // user-space written tail DataOffset uint64 // where the buffer starts DataSize uint64 // data buffer size AuxHead uint64 AuxTail uint64 AuxOffset uint64 AuxSize uint64 }
PerfEventMmapPage reflects the Linux 'struct perf_event_mmap_page'
func (*PerfEventMmapPage) Decode ¶ added in v1.5.0
func (p *PerfEventMmapPage) Decode(reader io.ReadSeeker) error
Decode populates 'p' base on the bytes read from the specified reader.
This function should not be used from performance-sensitive code.
type PerfEventSample ¶
type PerfEventSample struct { PerfEventHeader Size uint32 // contains filtered or unexported fields }
PerfEventSample must match 'struct perf_event_sample in kernel sources.
func (*PerfEventSample) DataCopy ¶
func (e *PerfEventSample) DataCopy() []byte
func (*PerfEventSample) DataDirect ¶
func (e *PerfEventSample) DataDirect() []byte
type ProgInfo ¶ added in v1.5.0
type ProgInfo struct { ProgType uint32 ID uint32 Tag uint8 JitedProgLen uint32 XlatedProgLen uint32 JitedProgInsns uint64 XlatedProgInsns uint64 LoadTime uint64 // ns since boottime CreatedByUID uint32 NRMapIDs uint32 MapIDs []uint32 Name string IfIndex uint32 NetnsDev uint64 NetnsIno uint64 NrJitedKsyms uint32 NrJitedFuncLens uint32 JitedKsyms uint64 JitedFuncLens uint64 }
ProgInfo holds values from the upstream struct bpf_prog_info. From: https://github.com/torvalds/linux/blob/v4.19-rc2/include/uapi/linux/bpf.h#L2427
func GetProgInfoByFD ¶ added in v1.5.0
GetProgInfoByFD gets the bpf program info from its file descriptor.
type ProgType ¶ added in v0.10.0
type ProgType int
ProgType is an enumeration for valid BPF program types
const ( ProgTypeUnspec ProgType = iota ProgTypeSocketFilter ProgTypeKprobe ProgTypeSchedCls ProgTypeSchedAct ProgTypeTracepoint ProgTypeXdp ProgTypePerfEvent ProgTypeCgroupSkb ProgTypeCgroupSock ProgTypeLwtIn ProgTypeLwtOut ProgTypeLwtXmit ProgTypeSockOps ProgTypeSkSkb ProgTypeCgroupDevice ProgTypeSkMsg ProgTypeRawTracepoint ProgTypeCgroupSockAddr ProgTypeLwtSeg6Local ProgTypeLircMode2 ProgTypeSkReusePort )
This enumeration must be in sync with enum bpf_prog_type in <linux/bpf.h>
type ReceiveFunc ¶
type ReceiveFunc func(msg *PerfEventSample, cpu int)