[PATCH v2 2/4] netlink: adjust decode_nlmsgerr for extended ACK reporting
Dmitry V. Levin
ldv at altlinux.org
Wed Jul 19 02:29:26 UTC 2017
On Wed, Jul 19, 2017 at 10:21:10AM +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->nlmsg_flags & NLM_F_CAPPED to decode_nlmsgerr.
> (decode_nlmsgerr): Adjust the length pass to
> decode_nlmsghdr_with_payload.
> ---
> netlink.c | 16 ++++++++++++----
> netlink.h | 4 ++++
> 2 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/netlink.c b/netlink.c
> index d3ad8b0..fc440da 100644
> --- a/netlink.c
> +++ b/netlink.c
> @@ -297,7 +297,8 @@ decode_nlmsgerr(struct tcb *const tcp,
> const int fd,
> const int family,
> kernel_ulong_t addr,
> - kernel_ulong_t len)
> + kernel_ulong_t len,
> + const bool capped)
> {
> struct nlmsgerr err;
>
> @@ -320,10 +321,16 @@ decode_nlmsgerr(struct tcb *const tcp,
> len -= offsetof(struct nlmsgerr, msg);
>
> if (len) {
> + unsigned int payload =
> + len > err.msg.nlmsg_len ? err.msg.nlmsg_len : len;
err.msg is not initialized at this point so err.msg.nlmsg_len cannot be used, ...
> +
> + if (capped && payload > sizeof(err.msg))
> + payload = sizeof(err.msg);
> +
> tprints(", msg=");
> - if (fetch_nlmsghdr(tcp, &err.msg, addr, len)) {
> + if (fetch_nlmsghdr(tcp, &err.msg, addr, payload)) {
... err.msg is valid only if fetch_nlmsghdr returned true.
--
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/acd497cb/attachment.bin>
More information about the Strace-devel
mailing list