#include "collectd.h"
-#include "common.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <asm/types.h>
};
static int ir_ignorelist_invert = 1;
-static ir_ignorelist_t *ir_ignorelist_head = NULL;
+static ir_ignorelist_t *ir_ignorelist_head;
static struct mnl_socket *nl;
-static char **iflist = NULL;
-static size_t iflist_len = 0;
+static char **iflist;
+static size_t iflist_len;
static const char *config_keys[] = {"Interface", "VerboseInterface",
"QDisc", "Class",
const char *tc_type;
char tc_inst[DATA_MAX_NAME_LEN];
- _Bool stats_submitted = 0;
+ bool stats_submitted = false;
if (nlh->nlmsg_type == RTM_NEWQDISC)
tc_type = "qdisc";
if (q_stats.bs != NULL || q_stats.qs != NULL) {
char type_instance[DATA_MAX_NAME_LEN];
- stats_submitted = 1;
+ stats_submitted = true;
- snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, tc_inst);
+ int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
+ tc_inst);
+ if ((size_t)r >= sizeof(type_instance)) {
+ ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d",
+ sizeof(type_instance), r);
+ return MNL_CB_ERROR;
+ }
if (q_stats.bs != NULL) {
submit_one(dev, "ipt_bytes", type_instance, q_stats.bs->bytes);
if (!stats_submitted && ts != NULL) {
char type_instance[DATA_MAX_NAME_LEN];
- snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type, tc_inst);
+ int r = snprintf(type_instance, sizeof(type_instance), "%s-%s", tc_type,
+ tc_inst);
+ if ((size_t)r >= sizeof(type_instance)) {
+ ERROR("netlink plugin: type_instance truncated to %zu bytes, need %d",
+ sizeof(type_instance), r);
+ return MNL_CB_ERROR;
+ }
submit_one(dev, "ipt_bytes", type_instance, ts->bytes);
submit_one(dev, "ipt_packets", type_instance, ts->packets);