From 50b2249877f24f5a7400ee221f8a1867a19b0f57 Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Sun, 13 Aug 2017 10:22:24 +0800 Subject: [PATCH] tests: check decoding of rtnetlink rule messages * tests/netlink_route.c: Include . (test_rtnl_rule): New function. (main): Use it. Co-authored-by: Fabien Siron --- tests/netlink_route.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/netlink_route.c b/tests/netlink_route.c index ff68579b..9996f948 100644 --- a/tests/netlink_route.c +++ b/tests/netlink_route.c @@ -32,6 +32,9 @@ #include #include #include "test_netlink.h" +#ifdef HAVE_LINUX_FIB_RULES_H +# include +#endif #ifdef HAVE_LINUX_IF_ADDR_H # include #endif @@ -263,6 +266,33 @@ test_rtnl_route(const int fd) ", rtm_flags=RTM_F_NOTIFY}")); } +#ifdef HAVE_LINUX_FIB_RULES_H +static void +test_rtnl_rule(const int fd) +{ + void *const nlh0 = tail_alloc(NLMSG_HDRLEN); + struct rtmsg msg = { + .rtm_family = AF_UNIX, + .rtm_dst_len = 0xaf, + .rtm_src_len = 0xda, + .rtm_tos = IPTOS_LOWDELAY, + .rtm_table = RT_TABLE_UNSPEC, + .rtm_type = FR_ACT_TO_TBL, + .rtm_flags = FIB_RULE_INVERT + }; + + TEST_NL_ROUTE(fd, nlh0, RTM_GETRULE, msg, + printf("{family=AF_UNIX"), + printf(", dst_len=%u, src_len=%u" + ", tos=IPTOS_LOWDELAY" + ", table=RT_TABLE_UNSPEC" + ", action=FR_ACT_TO_TBL" + ", flags=FIB_RULE_INVERT}", + msg.rtm_dst_len, + msg.rtm_src_len)); +} +#endif + int main(void) { skip_if_unavailable("/proc/self/fd/"); @@ -276,6 +306,9 @@ int main(void) test_rtnl_link(fd); test_rtnl_addr(fd); test_rtnl_route(fd); +#ifdef HAVE_LINUX_FIB_RULES_H + test_rtnl_rule(fd); +#endif printf("+++ exited with 0 +++\n"); -- 2.40.0