summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c99e8cb)
raw | patch | inline | side by side (parent: c99e8cb)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 15 Sep 2007 08:48:25 +0000 (10:48 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sat, 15 Sep 2007 08:48:25 +0000 (10:48 +0200) |
or generally older Linux versions.
ChangeLog | patch | blob | history | |
configure.in | patch | blob | history | |
src/netlink.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 66d339da6d8cd2d14c00448ed058a58576ce9e95..3f16c8efe49e0b456fdada3eb868a25d7d0c0864 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
yyyy-mm-dd, Version 4.1.2
* apcups plugin: Fix reporting of the `load percent' data.
+ * netlink plugin: Build issues under some older versions of the Linux
+ includes (i. e. Debian Sarge) have been fixed.
2007-09-12, Version 4.1.1
* Build system: The detection of `libnetlink' has been improved.
diff --git a/configure.in b/configure.in
index 38373ac0e5a036a0836acca6732f0f5fbbcf6c4f..44d7cfcc7c75fa6e6165ac04a16e43217d71f4f2 100644 (file)
--- a/configure.in
+++ b/configure.in
#include <sys/socket.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>])
+ AC_CHECK_HEADERS(linux/gen_stats.h linux/pkt_sched.h, [], [],
+[#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>])
+
+ AC_COMPILE_IFELSE(
+[#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+int main (void)
+{
+ int retval = TCA_STATS2;
+ return (retval);
+}],
+ [AC_DEFINE([HAVE_TCA_STATS2], 1, [True if the enum-member TCA_STATS2 exists])]
+ []);
+
+ AC_COMPILE_IFELSE(
+[#include <stdio.h>
+#include <sys/types.h>
+#include <asm/types.h>
+#include <sys/socket.h>
+#include <linux/netlink.h>
+#include <linux/rtnetlink.h>
+
+int main (void)
+{
+ int retval = TCA_STATS;
+ return (retval);
+}],
+ [AC_DEFINE([HAVE_TCA_STATS], 1, [True if the enum-member TCA_STATS exists])]
+ []);
CFLAGS="$SAVE_CFLAGS"
fi
diff --git a/src/netlink.c b/src/netlink.c
index 073efe9e9358bdff54c0f6706f41ef499ea73760..8c883f67179a9525d71dc0a1a04b11dbb9a3a1bd 100644 (file)
--- a/src/netlink.c
+++ b/src/netlink.c
#include <asm/types.h>
#include <sys/socket.h>
+
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
-#include <linux/gen_stats.h>
+#if HAVE_LINUX_GEN_STATS_H
+# include <linux/gen_stats.h>
+#endif
+#if HAVE_LINUX_PKT_SCHED_H
+# include <linux/pkt_sched.h>
+#endif
#if HAVE_LIBNETLINK_H
# include <libnetlink.h>
plugin_dispatch_values (type, &vl);
} /* void submit_two */
-static int link_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
- void *args)
+static int link_filter (const struct sockaddr_nl *sa,
+ const struct nlmsghdr *nmh, void *args)
{
struct ifinfomsg *msg;
int msg_len;
return (0);
} /* int link_filter */
-static int qos_filter (const struct sockaddr_nl *sa, struct nlmsghdr *nmh,
- void *args)
+static int qos_filter (const struct sockaddr_nl *sa,
+ const struct nlmsghdr *nmh, void *args)
{
struct tcmsg *msg;
int msg_len;
if (check_ignorelist (dev, tc_type, tc_inst))
return (0);
+#if HAVE_TCA_STATS2
if (attrs[TCA_STATS2])
{
struct rtattr *attrs_stats[TCA_STATS_MAX + 1];
submit_one (dev, "ipt_packets", type_instance, bs.packets);
}
}
+#endif /* TCA_STATS2 */
+#if HAVE_TCA_STATS && HAVE_TCA_STATS2
+ else
+#endif
+#if HAVE_TCA_STATS
+ if (attrs[TCA_STATS] != NULL)
+ {
+ struct tc_stats ts;
+ char type_instance[DATA_MAX_NAME_LEN];
+
+ snprintf (type_instance, sizeof (type_instance), "%s-%s",
+ tc_type, tc_inst);
+ type_instance[sizeof (type_instance) - 1] = '\0';
+
+ memset(&ts, '\0', sizeof (ts));
+ memcpy(&ts, RTA_DATA (attrs[TCA_STATS]),
+ MIN (RTA_PAYLOAD (attrs[TCA_STATS]), sizeof (ts)));
+
+ submit_one (dev, "ipt_bytes", type_instance, ts.bytes);
+ submit_one (dev, "ipt_packets", type_instance, ts.packets);
+ }
+#endif /* TCA_STATS */
+#if HAVE_TCA_STATS || HAVE_TCA_STATS2
+ else
+#endif
+ {
+ DEBUG ("netlink plugin: qos_filter: Have neither TCA_STATS2 nor "
+ "TCA_STATS.");
+ }
return (0);
} /* int qos_filter */