From 32c12cbe0312ea51c55b3a6dcee72204845afb59 Mon Sep 17 00:00:00 2001 From: JingPiao Chen Date: Sun, 13 Aug 2017 10:27:25 +0800 Subject: [PATCH] tests: check decoding of rtnetlink addrlabel messages * tests/netlink_route.c: Include . (test_rtnl_addrlabel): New function. (main): Use it. Co-authored-by: Fabien Siron --- tests/netlink_route.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tests/netlink_route.c b/tests/netlink_route.c index b45eb39f..f0ec9384 100644 --- a/tests/netlink_route.c +++ b/tests/netlink_route.c @@ -38,6 +38,9 @@ #ifdef HAVE_LINUX_IF_ADDR_H # include #endif +#ifdef HAVE_STRUCT_IFADDRLBLMSG +# include +#endif #include #include #ifdef HAVE_LINUX_NEIGHBOUR_H @@ -365,6 +368,29 @@ test_rtnl_tca(const int fd) printf("{tca_family=AF_INET}")); } +#ifdef HAVE_STRUCT_IFADDRLBLMSG +static void +test_rtnl_addrlabel(const int fd) +{ + void *const nlh0 = tail_alloc(NLMSG_HDRLEN); + const struct ifaddrlblmsg msg = { + .ifal_family = AF_UNIX, + .ifal_prefixlen = 0xaf, + .ifal_flags = 0xbd, + .ifal_index = IFINDEX_LO, + .ifal_seq = 0xfadcdafb + }; + + TEST_NL_ROUTE(fd, nlh0, RTM_GETADDRLABEL, msg, + printf("{ifal_family=AF_UNIX"), + PRINT_FIELD_U(", ", msg, ifal_prefixlen); + PRINT_FIELD_U(", ", msg, ifal_flags); + printf(", ifal_index=if_nametoindex(\"lo\")"); + PRINT_FIELD_U(", ", msg, ifal_seq); + printf("}")); +} +#endif + int main(void) { skip_if_unavailable("/proc/self/fd/"); @@ -385,6 +411,9 @@ int main(void) test_rtnl_neightbl(fd); test_rtnl_tc(fd); test_rtnl_tca(fd); +#ifdef HAVE_STRUCT_IFADDRLBLMSG + test_rtnl_addrlabel(fd); +#endif printf("+++ exited with 0 +++\n");