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.
This commit is contained in:
Дмитрий Левин 2017-08-29 10:09:04 +00:00
parent a6a1bc9abc
commit c95b9cb23b
2 changed files with 8 additions and 1 deletions

View File

@ -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,

View File

@ -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,