[PATCH 2/4] netlink: adjust decode_nlmsgerr for extended ACK reporting

Dmitry V. Levin ldv at altlinux.org
Tue Jul 18 21:39:03 UTC 2017


On Mon, Jul 17, 2017 at 11:07:44PM +0800, JingPiao Chen wrote:
> Extended ACK reporting introduced by linux kernel commit
> v4.11-rc5-1382-g2d4bc93.
> 
> * netlink.h (NLM_F_CAPPED): New macro.
> * netlink.c (decode_payload): Pass nlmsghdr to decode_nlmsgerr.
> (decode_nlmsgerr): Adjust the length pass to
> decode_nlmsghdr_with_payload.
> ---
>  netlink.c | 14 +++++++++++---
>  netlink.h |  4 ++++
>  2 files changed, 15 insertions(+), 3 deletions(-)
> 
> diff --git a/netlink.c b/netlink.c
> index 9d480d3..6184008 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -297,6 +297,7 @@ static void
>  decode_nlmsgerr(struct tcb *const tcp,
>  		const int fd,
>  		const int family,
> +		const struct nlmsghdr *const nlmsghdr,
>  		kernel_ulong_t addr,
>  		kernel_ulong_t len)
>  {
> @@ -321,10 +322,17 @@ decode_nlmsgerr(struct tcb *const tcp,
>  	len -= offsetof(struct nlmsgerr, msg);
>  
>  	if (len) {
> +		unsigned int payload =
> +			len > nlmsghdr->nlmsg_len ? nlmsghdr->nlmsg_len : len;

As len == nlmsghdr->nlmsg_len - NLMSG_HDRLEN (unless nlmsghdr->nlmsg_len
exceeds "len" argument passed to decode_nlmsghdr_with_payload),
I don't see why this check is needed.

> +
> +		if (nlmsghdr->nlmsg_flags & NLM_F_CAPPED &&

Alternatively, you can pass (nlmsghdr->nlmsg_flags & NLM_F_CAPPED) as an
argument to decode_nlmsgerr instead of the whole nlmsghdr.


-- 
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/20170719/208be229/attachment.bin>


More information about the Strace-devel mailing list