Documentation
¶
Overview ¶
Package metricsmap represents the BPF metrics map in the BPF programs. It is implemented as a hash table containing an entry of different drop and forward counts for different drop/forward reasons and directions. +groupName=maps
Index ¶
Constants ¶
const ( // MaxEntries is the maximum number of keys that can be present in the // Metrics Map. // // Currently max. 2 bits of the Key.Dir member are used (unknown, // ingress or egress). Thus we can reduce from the theoretical max. size // of 2**16 (2 uint8) to 2**10 (1 uint8 + 2 bits). MaxEntries = 1024 )
Variables ¶
Functions ¶
func MetricDirection ¶
MetricDirection gets the direction in human readable string format
Types ¶
type IterateCallback ¶
IterateCallback represents the signature of the callback function expected by the IterateWithCallback method, which in turn is used to iterate all the keys/values of a metrics map.
type Key ¶
type Key struct {
Reason uint8 `align:"reason"`
Dir uint8 `align:"dir"`
// Line contains the line number of the metrics statement.
Line uint16 `align:"line"`
// File is the number of the source file containing the metrics statement.
File uint8 `align:"file"`
Reserved [3]uint8 `align:"reserved"`
}
Key must be in sync with struct metrics_key in <bpf/lib/metrics.h>
func (*Key) DropForwardReason ¶
DropForwardReason gets the forwarded/dropped reason in human readable string format
func (*Key) FileName ¶ added in v1.16.0
FileName returns the filename where the event occurred, in string format.
func (*Key) IsFragNeeded ¶ added in v1.19.0
IsFragNeeded checks if the reason is realted to a mtu error message (frag-needed or pkt-too-big).
func (*Key) IsFragmentedCount ¶ added in v1.19.0
IsFragmentedCount checks if the reason is forwarded packets with fragmentation.
type MetricsMap ¶
type MetricsMap interface {
IterateWithCallback(IterateCallback) error
Delete(*Key) error
}
MetricsMap interface represents a metrics map, and can be reused to implement mock maps for unit tests.
func LoadMetricsMap ¶ added in v1.19.0
func LoadMetricsMap(logger *slog.Logger) (MetricsMap, error)
LoadMetricsMap loads the pre-initialized metrics map for access. This should only be used from components which aren't capable of using hive - mainly the Cilium CLI. It needs to initialized beforehand via the Cilium Agent.