Menu

#4 Utilization always computed as half duplex

v1.0 (example)
open
Tim Cook
None
5
2014-09-23
2014-09-23
No

When utilization is calculated, nicp->duplex checks for the value of "2" for a full duplex link, but on Linux this value is "1" (see /usr/include/linux/ethtool.h). The simple fix is to use DUPLEX_FULL instead:

$ diff -u nicstat.c.orig nicstat.c                                                                 0
--- nicstat.c.orig  2014-09-22 17:03:05.152192303 -0700
+++ nicstat.c   2014-09-22 17:49:01.515033633 -0700
@@ -2124,7 +2124,7 @@
             */
            rutil = min(rbps * 800 / nicp->speed, 100);
            wutil = min(wbps * 800 / nicp->speed, 100);
-           if (nicp->duplex == 2) {
+           if (nicp->duplex == DUPLEX_FULL) {
                /* Full duplex */
                util = max(rutil, wutil);
            } else {

Discussion


Log in to post a comment.