diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2017-08-29 10:09:04 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-08-29 10:09:04 +0000 |
commit | c95b9cb23b879c6875c2b5f8c3a1aad96bf20c84 (patch) | |
tree | 8d8971d6dbacd9f310e9fd78ce389f5536be9cdd | |
parent | a6a1bc9abcb22ed01bf9ffd6dbf8ccbadf79ba7d (diff) | |
download | strace-c95b9cb23b879c6875c2b5f8c3a1aad96bf20c84.tar.gz |
rtnl_rule: enhance FRA_TABLE decoding
The attribute of FRA_TABLE is not just a 32-bit integer, some constants
have well-known symbolic names like RT_TABLE_DEFAULT.
* rtnl_rule.c (fib_rule_hdr_nla_decoders) <FRA_TABLE>:
Use decode_nla_rt_class.
* tests/nlattr_fib_rule_hdr.c (FRA_TABLE): New macro.
(main): Check FRA_TABLE decoding.
-rw-r--r-- | rtnl_rule.c | 2 | ||||
-rw-r--r-- | tests/nlattr_fib_rule_hdr.c | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/rtnl_rule.c b/rtnl_rule.c index 6bc49f517..bd955ea6e 100644 --- a/rtnl_rule.c +++ b/rtnl_rule.c @@ -90,7 +90,7 @@ static const nla_decoder_t fib_rule_hdr_nla_decoders[] = { [FRA_TUN_ID] = decode_nla_be64, [FRA_SUPPRESS_IFGROUP] = decode_nla_u32, [FRA_SUPPRESS_PREFIXLEN] = decode_nla_u32, - [FRA_TABLE] = decode_nla_u32, + [FRA_TABLE] = decode_nla_rt_class, [FRA_FWMASK] = decode_nla_u32, [FRA_OIFNAME] = decode_nla_str, [FRA_PAD] = NULL, diff --git a/tests/nlattr_fib_rule_hdr.c b/tests/nlattr_fib_rule_hdr.c index d7a48d678..394ab1031 100644 --- a/tests/nlattr_fib_rule_hdr.c +++ b/tests/nlattr_fib_rule_hdr.c @@ -38,6 +38,7 @@ # include <linux/rtnetlink.h> #define FRA_TUN_ID 12 +#define FRA_TABLE 15 #define FRA_UID_RANGE 20 static void @@ -98,6 +99,12 @@ main(void) FRA_DST, 4, pattern, 4, print_quoted_hex(pattern, 4)); + const uint32_t table_id = RT_TABLE_DEFAULT; + TEST_NLATTR_OBJECT(fd, nlh0, hdrlen, + init_rtmsg, print_rtmsg, + FRA_TABLE, pattern, table_id, + printf("RT_TABLE_DEFAULT")); + #ifdef HAVE_STRUCT_FIB_RULE_UID_RANGE static const struct fib_rule_uid_range range = { .start = 0xabcdedad, |