only use kernel modules error as context to an actual error, not as a requirement since some systems don't show what they support reliably

This commit is contained in:
Quentin McGaw
2026-02-26 20:49:28 +00:00
parent f654dece66
commit 302f1f11f7
2 changed files with 33 additions and 19 deletions
+6 -4
View File
@@ -12,12 +12,11 @@ import (
var ErrConntrackNetlinkNotSupported = errors.New("nf_conntrack_netlink is not supported by the kernel")
func (n *NetLink) FlushConntrack() error {
if !n.conntrackNetlink {
return fmt.Errorf("%w", ErrConntrackNetlinkNotSupported)
}
conn, err := netfilter.Dial(nil)
if err != nil {
if !n.conntrackNetlink {
err = fmt.Errorf("%w: %w", err, ErrConntrackNetlinkNotSupported)
}
return fmt.Errorf("dialing netfilter: %w", err)
}
defer conn.Close()
@@ -36,6 +35,9 @@ func (n *NetLink) FlushConntrack() error {
_, err = conn.Query(request)
if err != nil {
if !n.conntrackNetlink {
err = fmt.Errorf("%w: %w", err, ErrConntrackNetlinkNotSupported)
}
return fmt.Errorf("querying netlink request: %w", err)
}
return nil