]> granicus.if.org Git - strace/commitdiff
tests: check decoding of rtnetlink netconf messages
authorJingPiao Chen <chenjingpiao@gmail.com>
Sun, 13 Aug 2017 02:27:29 +0000 (10:27 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Mon, 14 Aug 2017 01:09:59 +0000 (01:09 +0000)
* tests/netlink_route.c: Include <linux/netconf.h>.
(test_rtnl_netconf): New function.
(main): Use it.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
tests/netlink_route.c

index 0cdb945a7a94645dacd30d72e43eb80059aa0078..2b20d33946a94d1fa706b85452463dadd021072a 100644 (file)
@@ -49,6 +49,9 @@
 #ifdef HAVE_LINUX_NEIGHBOUR_H
 # include <linux/neighbour.h>
 #endif
+#ifdef HAVE_STRUCT_NETCONFMSG
+# 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");