]> granicus.if.org Git - strace/commitdiff
rtnl_rule: enhance FRA_TABLE decoding
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 29 Aug 2017 10:09:04 +0000 (10:09 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 29 Aug 2017 10:09:04 +0000 (10:09 +0000)
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.

rtnl_rule.c
tests/nlattr_fib_rule_hdr.c

index 6bc49f517a87b6881f7bc40db2667adb4e822dc0..bd955ea6e0cfd32ba967f5599d33e7efaefbd7cc 100644 (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,
index d7a48d6788ad43d31798bc9e5e230d17612e1ab1..394ab10313e6676667718b259f85d0c65b8d0b77 100644 (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,