From: JingPiao Chen Date: Tue, 15 Aug 2017 04:41:12 +0000 (+0800) Subject: netlink: add basic decoding of NETLINK_ROUTE rtmsg attributes X-Git-Tag: v4.19~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=955b69cb798154518814877cde73047ff8a73314;p=strace netlink: add basic decoding of NETLINK_ROUTE rtmsg attributes * rtnl_route.c: Include "nlattr.h" and "xlat/rtnl_route_attrs.h". (decode_rtmsg): Call decode_nlattr. * xlat/rtnl_route_attrs.in: New file. Co-authored-by: Fabien Siron --- diff --git a/rtnl_route.c b/rtnl_route.c index f25d0382..7b997f8f 100644 --- a/rtnl_route.c +++ b/rtnl_route.c @@ -29,6 +29,7 @@ #include "defs.h" #include "netlink_route.h" +#include "nlattr.h" #include "print_fields.h" #include @@ -40,11 +41,13 @@ #include "xlat/routing_protocols.h" #include "xlat/routing_table_ids.h" #include "xlat/routing_types.h" +#include "xlat/rtnl_route_attrs.h" DECL_NETLINK_ROUTE_DECODER(decode_rtmsg) { struct rtmsg rtmsg = { .rtm_family = family }; - const size_t offset = sizeof(rtmsg.rtm_family); + size_t offset = sizeof(rtmsg.rtm_family); + bool decode_nla = false; PRINT_FIELD_XVAL("{", rtmsg, rtm_family, addrfams, "AF_???"); @@ -67,8 +70,16 @@ DECL_NETLINK_ROUTE_DECODER(decode_rtmsg) routing_types, "RTN_???"); PRINT_FIELD_FLAGS(", ", rtmsg, rtm_flags, routing_flags, "RTM_F_???"); + decode_nla = true; } } else tprints("..."); tprints("}"); + + offset = NLMSG_ALIGN(sizeof(rtmsg)); + if (decode_nla && len > offset) { + tprints(", "); + decode_nlattr(tcp, addr + offset, len - offset, + rtnl_route_attrs, "RTA_???", NULL, 0, NULL); + } } diff --git a/xlat/rtnl_route_attrs.in b/xlat/rtnl_route_attrs.in new file mode 100644 index 00000000..f5fa5592 --- /dev/null +++ b/xlat/rtnl_route_attrs.in @@ -0,0 +1,27 @@ +RTA_UNSPEC 0 +RTA_DST 1 +RTA_SRC 2 +RTA_IIF 3 +RTA_OIF 4 +RTA_GATEWAY 5 +RTA_PRIORITY 6 +RTA_PREFSRC 7 +RTA_METRICS 8 +RTA_MULTIPATH 9 +RTA_PROTOINFO 10 +RTA_FLOW 11 +RTA_CACHEINFO 12 +RTA_SESSION 13 +RTA_MP_ALGO 14 +RTA_TABLE 15 +RTA_MARK 16 +RTA_MFC_STATS 17 +RTA_VIA 18 +RTA_NEWDST 19 +RTA_PREF 20 +RTA_ENCAP_TYPE 21 +RTA_ENCAP 22 +RTA_EXPIRES 23 +RTA_PAD 24 +RTA_UID 25 +RTA_TTL_PROPAGATE 26