From 0efd7823750e283c0ee38ebe88668b9534b2b6a6 Mon Sep 17 00:00:00 2001 From: Yoann Ghigoff Date: Thu, 3 Sep 2026 15:02:14 +0200 Subject: [PATCH] Keep the cause attached to the TC filter failures The two failures raised when a TC filter is added to an interface, or read back from it, are built without keeping their cause attached, so callers are left with a message and nothing they can match on. Both of them carry the reason the interface could not be programmed, and a missing device is the common one: an interface handed over to the network namespace of a container disappears while its classifier is being attached. Callers that want to tell that apart from a real failure currently have no choice but to compare the text of the message. Every other failure of this file already keeps its cause, and the text these two produce is unchanged, so this only makes them behave the way callers expect. --- tc.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tc.go b/tc.go index fa0ccca..229dae8 100644 --- a/tc.go +++ b/tc.go @@ -137,13 +137,13 @@ func (p *Probe) attachTCCLS() error { return err } if err = ntl.Sock.FilterAdd(&p.tcFilter); err != nil { - return fmt.Errorf("couldn't add a %v filter to interface %s[%d]: %v", p.NetworkDirection, p.IfName, p.IfIndex, err) + return fmt.Errorf("couldn't add a %v filter to interface %s[%d]: %w", p.NetworkDirection, p.IfName, p.IfIndex, err) } // retrieve filter handle resp, err := ntl.Sock.FilterList(p.link, p.tcFilter.Parent) if err != nil { - return fmt.Errorf("couldn't list filters of interface %s[%d]: %v", p.IfName, p.IfIndex, err) + return fmt.Errorf("couldn't list filters of interface %s[%d]: %w", p.IfName, p.IfIndex, err) } var found bool