On Wed, Aug 23, 2017 at 09:57:37AM +0800, JingPiao Chen wrote:
> On Wed, Aug 23, 2017 at 04:30:28AM +0300, Dmitry V. Levin wrote:
> > On Wed, Aug 23, 2017 at 08:45:18AM +0800, JingPiao Chen wrote:
> > > * configure.ac (AC_CHECK_TYPES): Check for
> > > rta_mfc_stats and rtvia structures in <linux/rtnetlink.h>.
> > > * nlattr.c (decode_nla_ifindex): New function.
> > > * nlattr.h (decode_nla_ifindex): New prototype.
> > > * rtnl_route.c (decode_route_addr, decode_rta_metrics,
> > > decode_rta_multipath, decode_rta_cacheinfo,
> > > decode_rta_mfc_stats, decode_rtvia,
> > > decode_rta_encap_type): New functions.
> > > (rta_metrics_nla_decoders, rtmsg_nla_decoders): New arrays.
> > > (decode_rtmsg): Use rtmsg_nla_decoders.
> > > * xlat/lwtunnel_encap_types.in: New file.
> > > * xlat/route_nexthop_flags.in: Likewise.
> > > * xlat/rtnl_rta_metrics_attrs.in: Likewise.
> > [...]
> > > +static bool
> > > +decode_rtvia(struct tcb *const tcp,
> > > +      const kernel_ulong_t addr,
> > > +      const unsigned int len,
> > > +      const void *const opaque_data)
> > > +{
> > > +#ifdef HAVE_STRUCT_RTVIA
> > > + struct rtvia via;
> > > +
> > > + if (len < sizeof(via))
> > > +         return false;
> > > + else if (!umove_or_printaddr(tcp, addr, &via)) {
> > > +         PRINT_FIELD_XVAL("{", via, rtvia_family, addrfams, "AF_???");
> > > +
> > > +         if (len > sizeof(via)) {
> > > +                 tprints(", rtvia_addr=");
> > > +                 printstr_ex(tcp, addr + sizeof(via),
> > > +                             len - sizeof(via), QUOTE_FORCE_HEX);
> > 
> > Looks like decode_inet_addr would be more appropriate here than printstr_ex.
> > 
> > We might end up with renaming decode_inet_addr to something more generic
> > and extending it to handle AF_PACKET in addition to AF_INET and AF_INET6.
> 
> bool
> decode_proto_address(struct tcb *const tcp,
>                    const kernel_ulong_t addr,
>                    const unsigned int len,
>                    const int family,
>                    const char *const var_name)
> {
>       switch (family) {
>       case AF_INET:
>       case AF_INET6:
>               return decode_inet_addr(tcp, addr, len, family, var_name);
>       case AF_PACKET:
>               ....
>       }
> 
>       if (var_name)
>               tprintf("%s=", var_name);
>       printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
> 
>       return false;
> }
> 
> How about this?

I'd rather extend decode_inet_addr (and print_inet_addr) to handle
AF_PACKET and maybe other address families, but couldn't think of
a proper name for this extended decode_inet_addr function.


-- 
ldv

Attachment: 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

Reply via email to