Skip to main content

dropreason

Counts number of packets/bytes dropped on a Node, along with the direction and reason for drop.

Capabilities

The dropreason plugin requires the CAP_SYS_ADMIN capability.

  • CAP_SYS_ADMIN is used to increase the memory lock limits, enabling the allocation of additional memory for eBPF programs and maps - LoadAndAssign() method at dropreason_linux.go:135

Architecture

The plugin utilizes eBPF to gather data. The plugin generates Basic metrics from an eBPF result. In Advanced mode (see Metric Modes), the plugin turns this eBPF result into an enriched Flow (adding Pod information based on IP), then sends the Flow to an external channel so that a drops module can create extra Pod-Level metrics.

Code locations

  • Plugin and eBPF code: pkg/plugin/dropreason/
  • Module for extra Advanced metrics: pkg/module/metrics/drops.go

Metrics

See metrics for Basic Mode or Advanced Mode.

Data sources

This plugin reads data from variable eBPF progs writing into the same eBPF map called metrics_map. It aggregates data for basic metrics at a node level and then control plane of the plugin converts into Prometheus metrics.

See pkg/plugin/dropreason/drop_reason.c:

struct
{
__uint(type, BPF_MAP_TYPE_PERCPU_HASH);
__uint(max_entries, 512);
__type(key, struct metrics_map_key);
__type(value, struct metrics_map_value);
} retina_dropreason_metrics SEC(".maps");

struct metrics_map_key
{
__u32 drop_type;
__u32 return_val;
};

struct metrics_map_value
{
__u64 count;
__u64 bytes;
};

eBPF Hook Points for Drop Reason

ReasonDescriptioneBPF Hook Point
IPTABLE_RULE_DROPPackets dropped by iptables rulekprobe/nf_hook_slow
IPTABLE_NAT_DROPPackets dropped by iptables NAT rulekretprobe/nf_nat_inet_fn
TCP_CONNECT_BASICPackets dropped by TCP connectkretprobe/tcp_v4_connect
TCP_ACCEPT_BASICPackets dropped by TCP acceptkretprobe/inet_csk_accept
TCP_CLOSE_BASICPackets dropped by TCP closeTBD
CONNTRACK_ADD_DROPPackets dropped by conntrack addkretprobe/__nf_conntrack_confirm
UNKNOWN_DROPPackets dropped by unknown reasonNA

This list will keep on growing as we add support for more reasons.