summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4def66d)
raw | patch | inline | side by side (parent: 4def66d)
author | Andreas Henriksson <andreas@fatal.se> | |
Mon, 10 Jun 2013 21:18:04 +0000 (23:18 +0200) | ||
committer | Marc Fournier <marc.fournier@camptocamp.com> | |
Thu, 18 Jul 2013 10:04:23 +0000 (12:04 +0200) |
We want to compile with all combinations of
HAVE_TCA_STATS(2) set/unset and at the same time
protect against submitting the stats twice (if both
are supported).
Introduce "stats_found" and set and attribute on it
to avoid having the compiler complain about it.
This allows us to bury the specific structs under
each HAVE_TCA_STATS(2) #if ...
HAVE_TCA_STATS(2) set/unset and at the same time
protect against submitting the stats twice (if both
are supported).
Introduce "stats_found" and set and attribute on it
to avoid having the compiler complain about it.
This allows us to bury the specific structs under
each HAVE_TCA_STATS(2) #if ...
src/netlink.c | patch | blob | history |
diff --git a/src/netlink.c b/src/netlink.c
index 5aaa25bd3c3d9b43c5de51f183c110cd2215e950..65fc0d99e3c5de72ca1f7618f859c339a66581aa 100644 (file)
--- a/src/netlink.c
+++ b/src/netlink.c
const char *dev;
const char *kind = NULL;
- struct gnet_stats_basic *bs = NULL;
- struct tc_stats *ts = NULL;
/* char *type_instance; */
char *tc_type;
char tc_inst[DATA_MAX_NAME_LEN];
+ int __attribute__((unused)) stats_found = 0;
+
if (tm->tcm_ifindex != wanted_ifindex)
{
DEBUG ("netlink plugin: qos_filter_cb: Got %s for interface #%i, "
#if HAVE_TCA_STATS2
mnl_attr_for_each (attr, nlh, sizeof (*tm))
{
+ struct gnet_stats_basic *bs = NULL;
+
if (mnl_attr_get_type(attr) != TCA_STATS2)
continue;
mnl_attr_parse_nested(attr, qos_attr_cb, &bs);
+ if (bs != NULL)
+ stats_found = 1;
+
break;
}
- if (bs != NULL)
+ if (stats_found)
{
char type_instance[DATA_MAX_NAME_LEN];
#if HAVE_TCA_STATS
mnl_attr_for_each (attr, nlh, sizeof (*tm))
{
+ struct tc_stats *ts = NULL;
+
if (mnl_attr_get_type(attr) != TCA_STATS)
continue;
return MNL_CB_ERROR;
}
ts = mnl_attr_get_payload(attr);
- break;
- }
- if (bs == NULL && ts != NULL)
- {
- char type_instance[DATA_MAX_NAME_LEN];
+ if (!stats_found && ts != NULL)
+ {
+ char type_instance[DATA_MAX_NAME_LEN];
- ssnprintf (type_instance, sizeof (type_instance), "%s-%s",
- tc_type, tc_inst);
+ ssnprintf (type_instance, sizeof (type_instance), "%s-%s",
+ tc_type, tc_inst);
- submit_one (dev, "ipt_bytes", type_instance, ts->bytes);
- submit_one (dev, "ipt_packets", type_instance, ts->packets);
+ submit_one (dev, "ipt_bytes", type_instance, ts->bytes);
+ submit_one (dev, "ipt_packets", type_instance, ts->packets);
+ }
+
+ break;
}
+
#endif /* TCA_STATS */
#if !(HAVE_TCA_STATS && HAVE_TCA_STATS2)