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

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

index 5b6b49b749fde0723a8226d8e180d720e6dbcc2a..ca0b72be3b23ae3f4e5ddf81b48c4523f254896d 100644 (file)
 
 #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_action_attrs.h"
+
 DECL_NETLINK_ROUTE_DECODER(decode_tcamsg)
 {
        struct tcamsg tca = { .tca_family = family };
 
        PRINT_FIELD_XVAL("{", tca, tca_family, addrfams, "AF_???");
        tprints("}");
+
+       const size_t offset = NLMSG_ALIGN(sizeof(tca));
+       if (len > offset) {
+               tprints(", ");
+               decode_nlattr(tcp, addr + offset, len - offset,
+                             rtnl_tc_action_attrs, "TCA_ACT_???",
+                             NULL, 0, NULL);
+       }
 }
diff --git a/xlat/rtnl_tc_action_attrs.in b/xlat/rtnl_tc_action_attrs.in
new file mode 100644 (file)
index 0000000..ebb3dd4
--- /dev/null
@@ -0,0 +1,7 @@
+TCA_ACT_UNSPEC         0
+TCA_ACT_KIND           1
+TCA_ACT_OPTIONS                2
+TCA_ACT_INDEX          3
+TCA_ACT_STATS          4
+TCA_ACT_PAD            5
+TCA_ACT_COOKIE         6