From 2c9eee4c5404c18dd1f3eece897d4603efe87b11 Mon Sep 17 00:00:00 2001 From: Benjamin Pracht Date: Mon, 13 Jul 2026 14:30:44 +0200 Subject: [PATCH] Guard against nil TC qdisc stats to prevent SIGSEGV (#4668) Newer kernels report qdisc stats via TCA_STATS2 (Stats2) while older kernels only populate the legacy TCA_STATS attribute (Stats). Whichever is unused is left nil, so unconditionally dereferencing Stats crashed with a SIGSEGV during telemetry init. Prefer Stats2 and fall back to Stats, skipping when both are nil. Co-authored-by: Claude Opus 4.8 (1M context) --- pkg/telemetry/prometheus/node_linux.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/telemetry/prometheus/node_linux.go b/pkg/telemetry/prometheus/node_linux.go index baa6919f8..e88dedbe2 100644 --- a/pkg/telemetry/prometheus/node_linux.go +++ b/pkg/telemetry/prometheus/node_linux.go @@ -38,8 +38,17 @@ func getTCStats() (packets, drops uint32, err error) { } for _, qdisc := range qdiscs { - packets = packets + qdisc.Stats.Packets - drops = drops + qdisc.Stats.Drops + // Newer kernels report stats via TCA_STATS2 (Stats2), while older kernels + // only populate the legacy TCA_STATS attribute (Stats). Prefer Stats2 and + // fall back to Stats so counters are collected on both. + switch { + case qdisc.Stats2 != nil: + packets = packets + qdisc.Stats2.Packets + drops = drops + qdisc.Stats2.Drops + case qdisc.Stats != nil: + packets = packets + qdisc.Stats.Packets + drops = drops + qdisc.Stats.Drops + } } return