* 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.si...@epita.fr>
---
 rtnl_tc.c             | 14 +++++++++++++-
 xlat/rtnl_tc_attrs.in | 12 ++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 xlat/rtnl_tc_attrs.in

diff --git a/rtnl_tc.c b/rtnl_tc.c
index db06e55..74d9df2 100644
--- a/rtnl_tc.c
+++ b/rtnl_tc.c
@@ -29,15 +29,19 @@
 
 #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
index 0000000..27f39e9
--- /dev/null
+++ b/xlat/rtnl_tc_attrs.in
@@ -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
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to