collectd.conf: Added an example write_riemann TTLFactor option.
[collectd.git] / src / netlink.c
index 4ea4fce..422dc8c 100644 (file)
@@ -1,6 +1,9 @@
 /**
  * collectd - src/netlink.c
  * Copyright (C) 2007-2010  Florian octo Forster
+ * Copyright (C) 2008-2012  Sebastian Harl
+ * Copyright (C) 2013       Andreas Henriksson
+ * Copyright (C) 2013       Marc Fournier
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License as published by the
@@ -17,6 +20,9 @@
  *
  * Authors:
  *   Florian octo Forster <octo at collectd.org>
+ *   Sebastian Harl <sh at tokkee.org>
+ *   Andreas Henriksson <andreas at fatal.se>
+ *   Marc Fournier <marc.fournier at camptocamp.com>
  **/
 
 #include "collectd.h"
 # include <linux/pkt_sched.h>
 #endif
 
-#include <time.h>
 #include <libmnl/libmnl.h>
-//#include <linux/if.h>
-//#include <linux/if_link.h>
 
 typedef struct ir_ignorelist_s
 {
@@ -229,7 +232,7 @@ static int update_iflist (struct ifinfomsg *msg, const char *dev)
   }
 
   return (0);
-}
+} /* int update_iflist */
 
 static void check_ignorelist_and_submit (const char *dev,
     struct rtnl_link_stats *stats)
@@ -270,10 +273,10 @@ static void check_ignorelist_and_submit (const char *dev,
     DEBUG ("netlink plugin: Ignoring %s/if_detail.", dev);
   }
 
-}
+} /* void check_ignorelist_and_submit */
 
 static int link_filter_cb (const struct nlmsghdr *nlh,
-    void __attribute__((unused)) *args)
+    void *args __attribute__((unused)))
 {
   struct ifinfomsg *ifm = mnl_nlmsg_get_payload (nlh);
   struct nlattr *attr;
@@ -287,6 +290,7 @@ static int link_filter_cb (const struct nlmsghdr *nlh,
     return MNL_CB_ERROR;
   }
 
+  /* Scan attribute list for device name. */
   mnl_attr_for_each (attr, nlh, sizeof (*ifm))
   {
     if (mnl_attr_get_type (attr) != IFLA_IFNAME)
@@ -338,7 +342,7 @@ static int link_filter_cb (const struct nlmsghdr *nlh,
 #if HAVE_TCA_STATS2
 static int qos_attr_cb (const struct nlattr *attr, void *data)
 {
-  struct gnet_stats_basic *bs = *(struct gnet_stats_basic **)data;
+  struct gnet_stats_basic **bs = (struct gnet_stats_basic **)data;
 
   /* skip unsupported attribute in user-space */
   if (mnl_attr_type_valid (attr, TCA_STATS_MAX) < 0)
@@ -346,12 +350,12 @@ static int qos_attr_cb (const struct nlattr *attr, void *data)
 
   if (mnl_attr_get_type (attr) == TCA_STATS_BASIC)
   {
-    if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (*bs)) < 0)
+    if (mnl_attr_validate2 (attr, MNL_TYPE_UNSPEC, sizeof (**bs)) < 0)
     {
       ERROR ("netlink plugin: qos_attr_cb: TCA_STATS_BASIC mnl_attr_validate2 failed.");
       return MNL_CB_ERROR;
     }
-    bs = mnl_attr_get_payload (attr);
+    *bs = mnl_attr_get_payload (attr);
     return MNL_CB_STOP;
   }
 
@@ -373,7 +377,7 @@ static int qos_filter_cb (const struct nlmsghdr *nlh, void *args)
   char *tc_type;
   char tc_inst[DATA_MAX_NAME_LEN];
 
-  int __attribute__((unused)) stats_submitted = 0;
+  _Bool stats_submitted = 0;
 
   if (nlh->nlmsg_type == RTM_NEWQDISC)
     tc_type = "qdisc";
@@ -434,7 +438,7 @@ static int qos_filter_cb (const struct nlmsghdr *nlh, void *args)
     return (-1);
   }
 
-  { /* The the ID */
+  { /* The ID */
     uint32_t numberic_id;
 
     numberic_id = tm->tcm_handle;