[PATCH v2 20/25] tests: check decoding of rtnetlink netconf messages

JingPiao Chen chenjingpiao at gmail.com
Sun Aug 13 02:27:29 UTC 2017


* tests/netlink_route.c: Include <linux/netconf.h>.
(test_rtnl_netconf): New function.
(main): Use it.

Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
 tests/netlink_route.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/tests/netlink_route.c b/tests/netlink_route.c
index e69d06d..99ab7d7 100644
--- a/tests/netlink_route.c
+++ b/tests/netlink_route.c
@@ -49,6 +49,9 @@
 #ifdef HAVE_LINUX_NEIGHBOUR_H
 # include <linux/neighbour.h>
 #endif
+#ifdef HAVE_LINUX_NETCONF_H
+# include <linux/netconf.h>
+#endif
 #include <linux/rtnetlink.h>
 
 #ifdef HAVE_IF_INDEXTONAME
@@ -410,6 +413,22 @@ test_rtnl_dcb(const int fd)
 }
 #endif
 
+#ifdef HAVE_STRUCT_NETCONFMSG
+static void
+test_rtnl_netconf(const int fd)
+{
+	void *const nlh0 = tail_alloc(NLMSG_HDRLEN);
+	static const struct netconfmsg msg = {
+		.ncm_family = AF_INET
+	};
+
+	TEST_NETLINK(fd, nlh0,
+		     RTM_GETNETCONF, NLM_F_REQUEST,
+		     sizeof(msg), &msg, sizeof(msg),
+		     printf("{ncm_family=AF_INET}"));
+}
+#endif
+
 int main(void)
 {
 	skip_if_unavailable("/proc/self/fd/");
@@ -436,6 +455,9 @@ int main(void)
 #ifdef HAVE_STRUCT_DCBMSG
 	test_rtnl_dcb(fd);
 #endif
+#ifdef HAVE_STRUCT_NETCONFMSG
+	test_rtnl_netconf(fd);
+#endif
 
 	printf("+++ exited with 0 +++\n");
 
-- 
2.7.4





More information about the Strace-devel mailing list