[PATCH v2 08/25] tests: check decoding of rtnetlink neigh messages

JingPiao Chen chenjingpiao at gmail.com
Sun Aug 13 02:22:26 UTC 2017


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

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

diff --git a/tests/netlink_route.c b/tests/netlink_route.c
index 9996f94..62d5570 100644
--- a/tests/netlink_route.c
+++ b/tests/netlink_route.c
@@ -40,6 +40,9 @@
 #endif
 #include <linux/if_arp.h>
 #include <linux/ip.h>
+#ifdef HAVE_LINUX_NEIGHBOUR_H
+# include <linux/neighbour.h>
+#endif
 #include <linux/rtnetlink.h>
 
 #ifdef HAVE_IF_INDEXTONAME
@@ -293,6 +296,26 @@ test_rtnl_rule(const int fd)
 }
 #endif
 
+static void
+test_rtnl_neigh(const int fd)
+{
+	void *const nlh0 = tail_alloc(NLMSG_HDRLEN);
+	const struct ndmsg msg = {
+		.ndm_family = AF_UNIX,
+		.ndm_ifindex = IFINDEX_LO,
+		.ndm_state = NUD_PERMANENT,
+		.ndm_flags = NTF_PROXY,
+		.ndm_type = NDA_UNSPEC
+	};
+
+	TEST_NL_ROUTE(fd, nlh0, RTM_GETNEIGH, msg,
+		      printf("{ndm_family=AF_UNIX"),
+		      printf(", ndm_ifindex=if_nametoindex(\"lo\")"
+			     ", ndm_state=NUD_PERMANENT"
+			     ", ndm_flags=NTF_PROXY"
+			     ", ndm_type=NDA_UNSPEC}"));
+}
+
 int main(void)
 {
 	skip_if_unavailable("/proc/self/fd/");
@@ -309,6 +332,7 @@ int main(void)
 #ifdef HAVE_LINUX_FIB_RULES_H
 	test_rtnl_rule(fd);
 #endif
+	test_rtnl_neigh(fd);
 
 	printf("+++ exited with 0 +++\n");
 
-- 
2.7.4





More information about the Strace-devel mailing list