]> granicus.if.org Git - strace/commitdiff
netlink: add basic decoding of NETLINK_ROUTE tcmsg attributes
authorJingPiao Chen <chenjingpiao@gmail.com>
Tue, 15 Aug 2017 04:41:16 +0000 (12:41 +0800)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 15 Aug 2017 22:34:46 +0000 (22:34 +0000)
* rtnl_tc.c: Include "nlattr.h" and "xlat/rtnl_tc_attrs.h".
(decode_tcmsg): Call decode_nlattr.
* xlat/rtnl_tc_attrs.in: New file.

Co-authored-by: Fabien Siron <fabien.siron@epita.fr>
rtnl_tc.c
xlat/rtnl_tc_attrs.in [new file with mode: 0644]

index db06e55626af1224c79fa97630e78bf88015b840..74d9df2ac10be50a776be82ebd422d24fd8aeb39 100644 (file)
--- a/rtnl_tc.c
+++ b/rtnl_tc.c
 
 #include "defs.h"
 #include "netlink_route.h"
+#include "nlattr.h"
 #include "print_fields.h"
 
 #include "netlink.h"
 #include <linux/rtnetlink.h>
 
+#include "xlat/rtnl_tc_attrs.h"
+
 DECL_NETLINK_ROUTE_DECODER(decode_tcmsg)
 {
        struct tcmsg tcmsg = { .tcm_family = family };
-       const size_t offset = sizeof(tcmsg.tcm_family);
+       size_t offset = sizeof(tcmsg.tcm_family);
+       bool decode_nla = false;
 
        PRINT_FIELD_XVAL("{", tcmsg, tcm_family, addrfams, "AF_???");
 
@@ -50,8 +54,16 @@ DECL_NETLINK_ROUTE_DECODER(decode_tcmsg)
                        PRINT_FIELD_U(", ", tcmsg, tcm_handle);
                        PRINT_FIELD_U(", ", tcmsg, tcm_parent);
                        PRINT_FIELD_U(", ", tcmsg, tcm_info);
+                       decode_nla = true;
                }
        } else
                tprints("...");
        tprints("}");
+
+       offset = NLMSG_ALIGN(sizeof(tcmsg));
+       if (decode_nla && len > offset) {
+               tprints(", ");
+               decode_nlattr(tcp, addr + offset, len - offset,
+                             rtnl_tc_attrs, "TCA_???", NULL, 0, NULL);
+       }
 }
diff --git a/xlat/rtnl_tc_attrs.in b/xlat/rtnl_tc_attrs.in
new file mode 100644 (file)
index 0000000..27f39e9
--- /dev/null
@@ -0,0 +1,12 @@
+TCA_UNSPEC             0
+TCA_KIND               1
+TCA_OPTIONS            2
+TCA_STATS              3
+TCA_XSTATS             4
+TCA_RATE               5
+TCA_FCNT               6
+TCA_STATS2             7
+TCA_STAB               8
+TCA_PAD                        9
+TCA_DUMP_INVISIBLE     10
+TCA_CHAIN              11