Package: nicstat
Version: 1.95-1
Tags: patch
On a system with a large number of interfaces, for example >30
interfaces in a VM, nicstat is unable to list all interfaces. It does
not crash or report any errors, it simply omits some interfaces.
I was able to reproduce this in a VM with >30 vNICs. nicstat output
showed less than 30 lines of output. After applying a patch to
increase the buffer size all interfaces showed up as expected.
The patch below comes from [1] and increases the buffer size to allow
for a greater number of interfaces to be supported.
--- nicstat.c 2016-12-06 05:43:16.000000000 -0700
+++ nicstat.c 2016-12-06 05:53:16.035042326 -0700
@@ -1637,8 +1637,11 @@
*/
if (lseek(net_dev, 0, SEEK_SET) != 0)
die(1, "lseek: %s", PROC_NET_DEV_PATH);
- bufsiz = read(net_dev, (void *) proc_net_buffer,
- sizeof (proc_net_buffer));
+ bufsiz = 0;
+ while ((n = read(net_dev, (void *) proc_net_buffer +
bufsiz,
+ sizeof (proc_net_buffer) - bufsiz)) > 0) {
+ bufsiz += n;
+ }
if (bufsiz < 0)
die(1, "read: %s", PROC_NET_DEV_PATH);
else if (bufsiz < 200)
[1]
https://github.com/jjo/nicstat/commit/3c2407da66c2fd2914e7f362f41f729cc21ff1e4
--
Joshua Powers
Ubuntu Server
Canonical Ltd