From: JingPiao Chen Date: Tue, 15 Aug 2017 04:41:16 +0000 (+0800) Subject: netlink: add basic decoding of NETLINK_ROUTE tcmsg attributes X-Git-Tag: v4.19~96 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=52eccecda5abcf5fd12f8da929b1b286b2b68f10;p=strace netlink: add basic decoding of NETLINK_ROUTE tcmsg attributes * 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 --- diff --git a/rtnl_tc.c b/rtnl_tc.c index db06e556..74d9df2a 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 +#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 00000000..27f39e9a --- /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