[PATCH 1/2] rtnl_route: decode rtmsg netlink attributes

Dmitry V. Levin ldv at altlinux.org
Wed Aug 23 01:30:28 UTC 2017


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.


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170823/52d3f2bc/attachment.bin>


More information about the Strace-devel mailing list