[PATCH 07/26] tests: check decoding of rtnetlink rule messages
JingPiao Chen
chenjingpiao at gmail.com
Thu Aug 10 01:07:05 UTC 2017
* tests/netlink_route.c: Include <linux/fib_rules.h>.
(test_rtnl_rule): New function.
(main): Use it.
Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
---
tests/netlink_route.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/tests/netlink_route.c b/tests/netlink_route.c
index cd10df3..0c62584 100644
--- a/tests/netlink_route.c
+++ b/tests/netlink_route.c
@@ -32,6 +32,9 @@
#include <unistd.h>
#include <sys/socket.h>
#include "test_netlink.h"
+#ifdef HAVE_LINUX_FIB_RULES_H
+# include <linux/fib_rules.h>
+#endif
#ifdef HAVE_LINUX_IF_ADDR_H
# include <linux/if_addr.h>
#endif
@@ -263,6 +266,30 @@ test_rtnl_route(const int fd)
", rtm_flags=RTM_F_NOTIFY}"));
}
+#ifdef HAVE_STRUCT_FIB_RULE_HDR
+static void
+test_rtnl_rule(const int fd)
+{
+ void *const nlh0 = tail_alloc(NLMSG_HDRLEN);
+ struct fib_rule_hdr frh = {
+ .family = AF_UNIX,
+ .dst_len = 0xaf,
+ .src_len = 0xda,
+ .tos = IPTOS_LOWDELAY,
+ .action = FR_ACT_TO_TBL,
+ .flags = FIB_RULE_INVERT
+ };
+
+ TEST_NL_ROUTE(fd, nlh0, RTM_GETRULE, frh,
+ printf("{family=AF_UNIX"),
+ PRINT_FIELD_U(", ", frh, dst_len);
+ PRINT_FIELD_U(", ", frh, src_len);
+ printf(", tos=IPTOS_LOWDELAY"
+ ", action=FR_ACT_TO_TBL"
+ ", flags=FIB_RULE_INVERT}"));
+}
+#endif
+
int main(void)
{
skip_if_unavailable("/proc/self/fd/");
@@ -276,6 +303,9 @@ int main(void)
test_rtnl_link(fd);
test_rtnl_addr(fd);
test_rtnl_route(fd);
+#ifdef HAVE_STRUCT_FIB_RULE_HDR
+ test_rtnl_rule(fd);
+#endif
printf("+++ exited with 0 +++\n");
--
2.7.4
More information about the Strace-devel
mailing list