netlink: fix segfault & make advanced options work again
authorMarc Fournier <marc.fournier@camptocamp.com>
Fri, 19 Jul 2013 14:23:56 +0000 (16:23 +0200)
committerMarc Fournier <marc.fournier@camptocamp.com>
Fri, 19 Jul 2013 14:33:48 +0000 (16:33 +0200)
A type mismatch and offset mistake was preventing the interface list
from getting iterated. This was making collectd segfault when the
"QDisc", "Class" or "Filter" options were enabled.

src/netlink.c

index 0c06e78..ca8f7c5 100644 (file)
@@ -663,10 +663,9 @@ static int ir_read (void)
 
   /* `link_filter_cb' will update `iflist' which is used here to iterate
    * over all interfaces. */
-  for (ifindex = 0; ifindex < iflist_len; ifindex++)
+  for (ifindex = 1; ifindex < iflist_len; ifindex++)
   {
     struct tcmsg *tm;
-    int ifindex;
     size_t type_index;
 
     if (iflist[ifindex] == NULL)
@@ -681,7 +680,7 @@ static int ir_read (void)
        continue;
       }
 
-      DEBUG ("netlink plugin: ir_read: querying %s from %s (%i).",
+      DEBUG ("netlink plugin: ir_read: querying %s from %s (%lu).",
          type_name[type_index], iflist[ifindex], ifindex);
 
       nlh = mnl_nlmsg_put_header (buf);