On Thu, Aug 10, 2017 at 09:04:54AM +0800, JingPiao Chen wrote: > * netlink_route.c: New file. > * Makefile.am (strace_SOURCES): Add it > * netlink_route.h (decode_rtmsg): New prototype. > * netlink_route.c (route_decoders): Add RTM_DELROUTE, > RTM_GETROUTE, and RTM_NEWROUTE. > * xlat/ip_type_of_services.in: New file. > * xlat/rtm_flags.in: Likewise. > * xlat/rtm_protocol.in: Likewise. > * xlat/rtm_scope.in: Likewise. > * xlat/rtm_table.in: Likewise. > * xlat/rtm_types.in: Likewise. [...] > +DECL_NETLINK_ROUTE_DECODER(decode_rtmsg) > +{ > + struct rtmsg rtmsg = { .rtm_family = family }; > + const size_t offset = sizeof(rtmsg.rtm_family); > + > + PRINT_FIELD_XVAL("{", rtmsg, rtm_family, addrfams, "AF_???"); > + > + tprints(", "); > + if (len >= sizeof(rtmsg)) { > + if (!umoven_or_printaddr(tcp, addr + offset, > + sizeof(rtmsg) - offset, > + (void *) &rtmsg + offset)) { > + PRINT_FIELD_U("", rtmsg, rtm_dst_len); > + PRINT_FIELD_U(", ", rtmsg, rtm_src_len); > + PRINT_FIELD_FLAGS(", ", rtmsg, rtm_tos, > + ip_type_of_services, "IPTOS_TOS_???"); > + PRINT_FIELD_XVAL(", ", rtmsg, rtm_table, > + rtm_table, "RT_TABLE_???"); > + PRINT_FIELD_XVAL(", ", rtmsg, rtm_protocol, > + rtm_protocol, "RTPROT_???"); > + PRINT_FIELD_XVAL(", ", rtmsg, rtm_scope, > + rtm_scope, "RT_SCOPE_???");
Both rtmsg.rtm_table and rtmsg.rtm_scope can legitimately contain values defined by user, see comments in definitions of enum rt_scope_t and enum rt_class_t in <linux/rtnetlink.h>. I think specifying NULL instead of "RT_TABLE_???" and "RT_SCOPE_???" would result to more appropriate decoding of these fields. -- ldv
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ 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