[PATCH 09/26] tests: check decoding of rtnetlink neigh messages

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


* tests/netlink_route.c (test_rtnl_neigh): New function.
(main): Use it.

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

diff --git a/tests/netlink_route.c b/tests/netlink_route.c
index 0c62584..3aba2a0 100644
--- a/tests/netlink_route.c
+++ b/tests/netlink_route.c
@@ -290,6 +290,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/");
@@ -306,6 +326,7 @@ int main(void)
 #ifdef HAVE_STRUCT_FIB_RULE_HDR
 	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