From: JingPiao Chen Date: Sun, 13 Aug 2017 02:22:20 +0000 (+0800) Subject: tests: check decoding of rtnetlink addr messages X-Git-Tag: v4.19~144 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0a3ebb0443168ab64b6e8236422c1d6133d5af9a;p=strace tests: check decoding of rtnetlink addr messages * tests/netlink_route.c: Include . (test_rtnl_addr): New function. (main): Use it. Co-authored-by: Fabien Siron --- diff --git a/tests/netlink_route.c b/tests/netlink_route.c index 0a52dbc5..872c236d 100644 --- a/tests/netlink_route.c +++ b/tests/netlink_route.c @@ -32,6 +32,9 @@ #include #include #include "test_netlink.h" +#ifdef HAVE_LINUX_IF_ADDR_H +# include +#endif #include #include @@ -210,6 +213,27 @@ test_rtnl_link(const int fd) printf("}")); } +static void +test_rtnl_addr(const int fd) +{ + void *const nlh0 = tail_alloc(NLMSG_HDRLEN); + const struct ifaddrmsg msg = { + .ifa_family = AF_UNIX, + .ifa_prefixlen = 0xde, + .ifa_flags = IFA_F_SECONDARY, + .ifa_scope = RT_SCOPE_UNIVERSE, + .ifa_index = IFINDEX_LO + }; + + TEST_NL_ROUTE(fd, nlh0, RTM_GETADDR, msg, + printf("{ifa_family=AF_UNIX"), + PRINT_FIELD_U(", ", msg, ifa_prefixlen); + printf(", ifa_flags=IFA_F_SECONDARY" + ", ifa_scope=RT_SCOPE_UNIVERSE" + ", ifa_index=if_nametoindex(\"lo\")"); + printf("}")); +} + int main(void) { skip_if_unavailable("/proc/self/fd/"); @@ -221,6 +245,7 @@ int main(void) test_nlmsg_done(fd); test_rtnl_unspec(fd); test_rtnl_link(fd); + test_rtnl_addr(fd); printf("+++ exited with 0 +++\n");