Make every failed check and unreadable counter fatal instead of degrading

This commit is contained in:
flamingcow
2026-08-04 13:03:07 -07:00
parent fb6a0d2c1b
commit 66bfb88dd7
3 changed files with 16 additions and 9 deletions
+7 -7
View File
@@ -211,11 +211,14 @@ func lookupEndpoint(name string) (endpoint, error) {
}
var mac [6]byte
copy(mac[:], ifi.HardwareAddr)
e := endpoint{name: name, idx: ifi.Index, mac: mac, mtu: ifi.MTU}
if v, ok := readUint("/sys/class/net/" + name + "/speed"); ok {
e.speed = float64(v) / 1000
// The rate columns are graded against this, so a guessed speed would silently
// grade every reading against the wrong target.
v, ok := readUint("/sys/class/net/" + name + "/speed")
if !ok || v == 0 {
return endpoint{}, fmt.Errorf("%s: cannot read link speed", name)
}
return e, nil
return endpoint{name: name, idx: ifi.Index, mac: mac, mtu: ifi.MTU,
speed: float64(v) / 1000}, nil
}
func parseSizes(s string) ([]int, error) {
@@ -707,9 +710,6 @@ func run(aName, bName, sizesArg string,
[]bool{false, false, false, true, true}, linkRows))
target := a.speed
if target <= 0 {
target = 10
}
sizeStrs := make([]string, len(sizes))
for i, s := range sizes {
sizeStrs[i] = fmt.Sprintf("%d", s)