From: JingPiao Chen Date: Sun, 27 Aug 2017 16:37:33 +0000 (+0800) Subject: tests: check decoding of fib_rule_hdr netlink attributes X-Git-Tag: v4.19~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=65ad4f2cce08b32918832214101bc606910db011;p=strace tests: check decoding of fib_rule_hdr netlink attributes * tests/nlattr_fib_rule_hdr.c: Include . (FRA_TUN_ID, FRA_UID_RANGE): New macros. (main): Check decoding of FRA_DST, FRA_UID_RANGE and FRA_TUN_ID. --- diff --git a/tests/nlattr_fib_rule_hdr.c b/tests/nlattr_fib_rule_hdr.c index 5bb9d53f..d7a48d67 100644 --- a/tests/nlattr_fib_rule_hdr.c +++ b/tests/nlattr_fib_rule_hdr.c @@ -31,11 +31,15 @@ #ifdef HAVE_LINUX_FIB_RULES_H # include +# include # include "test_nlattr.h" # include # include # include +#define FRA_TUN_ID 12 +#define FRA_UID_RANGE 20 + static void init_rtmsg(struct nlmsghdr *const nlh, const unsigned int msg_len) { @@ -89,6 +93,31 @@ main(void) 4, pattern, 4, print_quoted_hex(pattern, 4)); + TEST_NLATTR(fd, nlh0, hdrlen, + init_rtmsg, print_rtmsg, + FRA_DST, 4, pattern, 4, + print_quoted_hex(pattern, 4)); + +#ifdef HAVE_STRUCT_FIB_RULE_UID_RANGE + static const struct fib_rule_uid_range range = { + .start = 0xabcdedad, + .end = 0xbcdeadba + }; + TEST_NLATTR_OBJECT(fd, nlh0, hdrlen, + init_rtmsg, print_rtmsg, + FRA_UID_RANGE, pattern, range, + PRINT_FIELD_U("{", range, start); + PRINT_FIELD_U(", ", range, end); + printf("}")); +#endif +#if defined HAVE_BE64TOH || defined be64toh + const uint64_t tun_id = 0xabcdcdbeedabadef; + TEST_NLATTR_OBJECT(fd, nlh0, hdrlen, + init_rtmsg, print_rtmsg, + FRA_TUN_ID, pattern, tun_id, + printf("htobe64(%" PRIu64 ")", be64toh(tun_id))); +#endif + puts("+++ exited with 0 +++"); return 0; }