Make every failed check and unreadable counter fatal instead of degrading
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -25,7 +25,7 @@ func setBufForce(fd, forceOpt, opt, size int) error {
|
||||
func sockBufSize(fd, opt int) int {
|
||||
v, err := unix.GetsockoptInt(fd, unix.SOL_SOCKET, opt)
|
||||
if err != nil {
|
||||
return -1
|
||||
panic(fmt.Sprintf("reading socket buffer size: %v", err))
|
||||
}
|
||||
return v
|
||||
}
|
||||
@@ -117,7 +117,7 @@ func newMmsghdrs(bufs [][]byte) ([]mmsghdr, []unix.Iovec) {
|
||||
func packetDrops(fd int) uint64 {
|
||||
st, err := unix.GetsockoptTpacketStats(fd, unix.SOL_PACKET, unix.PACKET_STATISTICS)
|
||||
if err != nil {
|
||||
return 0
|
||||
panic(fmt.Sprintf("reading packet drop statistics: %v", err))
|
||||
}
|
||||
return uint64(st.Drops)
|
||||
}
|
||||
|
||||
@@ -462,6 +462,7 @@ func checkGovernor(want string) checkResult {
|
||||
paths, err := filepath.Glob("/sys/devices/system/cpu/cpu*/cpufreq/scaling_governor")
|
||||
if err != nil || len(paths) == 0 {
|
||||
res.err = fmt.Errorf("no cpufreq governors found")
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
var wrong []string
|
||||
@@ -470,6 +471,7 @@ func checkGovernor(want string) checkResult {
|
||||
b, err := os.ReadFile(p)
|
||||
if err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
got := strings.TrimSpace(string(b))
|
||||
@@ -490,6 +492,7 @@ func checkGovernor(want string) checkResult {
|
||||
if err := os.WriteFile(p, []byte(want), 0o644); err != nil {
|
||||
res.err = err
|
||||
res.state = fmt.Sprintf("could not set %s", p)
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
}
|
||||
@@ -532,6 +535,7 @@ func checkCoalesce(fd int, ifname string, rxUsecs, txUsecs uint32) checkResult {
|
||||
ec, err := getCoalesce(fd, ifname)
|
||||
if err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
desc := func(e ethtoolCoalesce) string {
|
||||
@@ -552,6 +556,7 @@ func checkCoalesce(fd int, ifname string, rxUsecs, txUsecs uint32) checkResult {
|
||||
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&ec)); err != nil {
|
||||
res.err = err
|
||||
res.state = "could not set"
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
res.fixed = true
|
||||
@@ -564,6 +569,7 @@ func checkRings(fd int, ifname string, rxWant, txWant uint32) checkResult {
|
||||
rp, err := getRings(fd, ifname)
|
||||
if err != nil {
|
||||
res.err = err
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
rx := min(rxWant, rp.rxMaxPending)
|
||||
@@ -579,6 +585,7 @@ func checkRings(fd int, ifname string, rxWant, txWant uint32) checkResult {
|
||||
if err := ethtoolCall(fd, ifname, unsafe.Pointer(&rp)); err != nil {
|
||||
res.err = err
|
||||
res.state = "could not set"
|
||||
res.fatal = true
|
||||
return res
|
||||
}
|
||||
res.fixed = true
|
||||
|
||||
Reference in New Issue
Block a user