mirror of
https://github.com/livekit/livekit.git
synced 2026-07-17 03:22:06 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
2bd3b9d67f
commit
2c9eee4c54
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user