From c95b9cb23b879c6875c2b5f8c3a1aad96bf20c84 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Tue, 29 Aug 2017 10:09:04 +0000 Subject: [PATCH] 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) : Use decode_nla_rt_class. * tests/nlattr_fib_rule_hdr.c (FRA_TABLE): New macro. (main): Check FRA_TABLE decoding. --- rtnl_rule.c | 2 +- tests/nlattr_fib_rule_hdr.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rtnl_rule.c b/rtnl_rule.c index 6bc49f51..bd955ea6 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 d7a48d67..394ab103 100644 --- a/tests/nlattr_fib_rule_hdr.c +++ b/tests/nlattr_fib_rule_hdr.c @@ -38,6 +38,7 @@ # include #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, -- 2.40.0