Small issue seen in nicstat 1.90 - I noted the utilization column wasn’t reporting correctly for 10Gbps interfaces; the issue seems to be the precision of the edata.speed –this is defined in linux/ethtool.h as
/* This should work for both 32 and 64 bit userland. */ struct ethtool_cmd {
__u32 cmd;
__u32 supported; /* Features this interface supports */
__u32 advertising; /* Features this interface advertises */
__u16 speed; /* The forced speed, 10Mb, 100Mb, gigabit */
But in get_speed_duplex() we:
nicp->speed = edata.speed * 1000000;
Which causes an overflow; solution is to cast to 64 bit before the multiplication; patch is below:
$ diff -u nicstat.c.orig nicstat.c
--- nicstat.c.orig 2011-11-23 15:48:17.861165615 +0000
+++ nicstat.c 2011-11-23 15:48:43.222199968 +0000
@@ -1575,7 +1575,7 @@
get_speed_duplex(nicp);
return;
}
- nicp->speed = edata.speed * 1000000;
+ nicp->speed = (long long) edata.speed * 1000000;
nicp->duplex = edata.duplex;
}
#endif /* OS_LINUX */
Regards,
Darren
I can confirm this bug. A 10Gbps interface ends up with nicp->speed having the value 1410065408.
This cannot be worked around by specifying the -S option either, as -S only takes effect if the SIOCETHTOOL call fails - this also seems to be a bug which I hacked around by simply returning at the beginning of get_speed_duplex() if find_interface_speed(nicp) return true;
Last edit: Scott Emmons 2014-09-22