[PATCH 4/5] netlink: add a basic rtnetlink parser of link messages

JingPiao Chen chenjingpiao at gmail.com
Wed Jul 26 07:59:20 UTC 2017


On Tue, Jul 25, 2017 at 10:30:02PM +0800, JingPiao Chen wrote:
> * defs.h (arp_hardware_types, iffflags): New xlat prototypes.
> * netlink_route.c: Include "print_fields.h" and <linux/rtnetlink.h>.
> (decode_ifinfomsg): New function.
> (netlink_route_decoder_t): New typedef.
> (route_decoders): New array.
> (decode_netlink_route): Use it.
> 
> Co-authored-by: Fabien Siron <fabien.siron at epita.fr>
> ---
[...]
>  bool
>  decode_netlink_route(struct tcb *const tcp,
>  		     const struct nlmsghdr *const nlmsghdr,
>  		     const kernel_ulong_t addr,
>  		     const unsigned int len)
>  {
> +	unsigned int type = nlmsghdr->nlmsg_type;
>  	uint8_t family;
>  
>  	if (nlmsghdr->nlmsg_type == NLMSG_DONE)
>  		return false;
>  
> -	if (!umove_or_printaddr(tcp, addr, &family))
> -		decode_family(tcp, family, addr, len);
> +	if (!umove_or_printaddr(tcp, addr, &family)) {
> +		if (type > RTM_BASE
> +		    && type - RTM_BASE < ARRAY_SIZE(route_decoders)
> +		    && route_decoders[type - RTM_BASE]) {

A mistake, type >= RTM_BASE instead of type > RTM_BASE.
Version 2 will send after these patches are reviewed.

> +			route_decoders[type - RTM_BASE](tcp, nlmsghdr,
> +							family, addr, len);
> +		} else
> +			decode_family(tcp, family, addr, len);
> +	}
>  
>  	return true;
>  }
> -- 
> 2.7.4
> 

--
JingPiao Chen




More information about the Strace-devel mailing list