[PATCH 17/26] tests: check decoding of rtnetlink addrlabel messages

JingPiao Chen chenjingpiao at gmail.com
Thu Aug 10 01:08:33 UTC 2017


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

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

diff --git a/tests/netlink_route.c b/tests/netlink_route.c
index b921655..1df09c8 100644
--- a/tests/netlink_route.c
+++ b/tests/netlink_route.c
@@ -38,6 +38,9 @@
 #ifdef HAVE_LINUX_IF_ADDR_H
 # include <linux/if_addr.h>
 #endif
+#ifdef HAVE_LINUX_IF_ADDRLABEL_H
+# include <linux/if_addrlabel.h>
+#endif
 #include <linux/if_arp.h>
 #include <linux/ip.h>
 #ifdef HAVE_LINUX_NEIGHBOUR_H
@@ -362,6 +365,29 @@ test_rtnl_tca(const int fd)
 		     printf("{tca_family=AF_INET}"));
 }
 
+#ifdef HAVE_STRUCT_IFADDRLBLMSG
+static void
+test_rtnl_addrlabel(const int fd)
+{
+	void *const nlh0 = tail_alloc(NLMSG_HDRLEN);
+	const struct ifaddrlblmsg msg = {
+		.ifal_family = AF_UNIX,
+		.ifal_prefixlen = 0xaf,
+		.ifal_flags = 0xbd,
+		.ifal_index = IFINDEX_LO,
+		.ifal_seq = 0xfadcdafb
+	};
+
+	TEST_NL_ROUTE(fd, nlh0, RTM_GETADDRLABEL, msg,
+		      printf("{ifal_family=AF_UNIX"),
+		      PRINT_FIELD_U(", ", msg, ifal_prefixlen);
+		      PRINT_FIELD_U(", ", msg, ifal_flags);
+		      printf(", ifal_index=if_nametoindex(\"lo\")");
+		      PRINT_FIELD_U(", ", msg, ifal_seq);
+		      printf("}"));
+}
+#endif
+
 int main(void)
 {
 	skip_if_unavailable("/proc/self/fd/");
@@ -382,6 +408,9 @@ int main(void)
 	test_rtnl_neightbl(fd);
 	test_rtnl_tc(fd);
 	test_rtnl_tca(fd);
+#ifdef HAVE_STRUCT_IFADDRLBLMSG
+	test_rtnl_addrlabel(fd);
+#endif
 
 	printf("+++ exited with 0 +++\n");
 
-- 
2.7.4





More information about the Strace-devel mailing list