Documentation ¶
Index ¶
- Constants
- func CreateMap(mapType int, keySize, valueSize, maxEntries uint32) (int, error)
- func DeleteElement(fd int, key unsafe.Pointer) error
- func GetMapPrefix() string
- func GetMapRoot() string
- func GetMtime() (uint64, error)
- func GetNextKey(fd int, key, nextKey unsafe.Pointer) error
- func LookupElement(fd int, key, value unsafe.Pointer) error
- func MapPath(name string) string
- func MapPrefixPath() string
- func MountFS() error
- 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 uint32) (int, bool, error)
- func SetMapPrefix(path string)
- func SetMapRoot(path string)
- func UpdateElement(fd int, key, value unsafe.Pointer, flags uint64) error
- type DumpCallback
- type DumpParser
- type EPoll
- type EventMap
- type LostFunc
- type Map
- func (m *Map) Close() error
- func (m *Map) Delete(key MapKey) error
- func (m *Map) DeleteAll() error
- func (m *Map) Dump(parser DumpParser, cb DumpCallback) error
- func (m *Map) GetFd() int
- func (m *Map) GetNextKey(key MapKey, nextKey MapKey) error
- func (m *Map) Lookup(key MapKey) (MapValue, error)
- func (m *Map) Open() error
- func (m *Map) OpenOrCreate() (bool, error)
- func (m *Map) Update(key MapKey, value MapValue) error
- type MapInfo
- type MapKey
- type MapType
- type MapValue
- type PerCpuEvents
- type PerfEvent
- type PerfEventConfig
- type PerfEventHeader
- type PerfEventLost
- type PerfEventSample
- type ReceiveFunc
Constants ¶
const ( EventsMapName = "cilium_events" MAX_POLL_EVENTS = 32 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 )
Variables ¶
This section is empty.
Functions ¶
func CreateMap ¶
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"
func DeleteElement ¶
DeleteElement deletes the map element with the given key.
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 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 MapPrefixPath ¶
func MapPrefixPath() string
func OpenOrCreateMap ¶
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 (if you include "uapi/linux/bpf.h"): C.BPF_ANY to create new element or update existing; C.BPF_NOEXIST to create new element if it didn't exist; C.BPF_EXIST to update existing element.
Types ¶
type DumpCallback ¶
type LostFunc ¶
type LostFunc func(msg *PerfEventLost, cpu int)
type Map ¶
type Map struct { MapInfo // contains filtered or unexported fields }
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) Dump ¶
func (m *Map) Dump(parser DumpParser, cb DumpCallback) error
func (*Map) GetNextKey ¶ added in v0.9.0
GetNextKey returns the next key in the Map after key.
func (*Map) OpenOrCreate ¶
type MapInfo ¶
type MapType ¶
type MapType int
const ( MapTypeUnspec MapType = iota MapTypeHash MapTypeArray MapTypeProgArray MapTypePerfEventArray MapTypePerCPUHash MapTypePerCPUArray MapTypeStackTrace MapTypeCgroupArray MapTypeLRUHash MapTypeLRUPerCPUHash MapTypeLPMTrie MapTypeArrayOfMaps MapTypeHashOfMaps )
This enumeration must be in sync with <linux/bpf.h>
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) error
func (*PerCpuEvents) Stats ¶
func (e *PerCpuEvents) Stats() (uint64, uint64)
type PerfEvent ¶
type PerfEvent struct { Fd int // contains filtered or unexported fields }
func PerfEventOpen ¶
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 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 ReceiveFunc ¶
type ReceiveFunc func(msg *PerfEventSample, cpu int)