[PATCH] netlink: decode NLMSG_DONE message

JingPiao Chen chenjingpiao at gmail.com
Sun Jun 4 10:50:50 UTC 2017


On 4 June 2017 at 17:56, Dmitry V. Levin <ldv at altlinux.org> wrote:
> On Sun, Jun 04, 2017 at 03:57:08PM +0800, JingPiao Chen wrote:
> > On Fri, Jun 02, 2017 at 06:25:28PM +0300, Dmitry V. Levin wrote:
> > > On Fri, May 05, 2017 at 06:21:17PM +0800, JingPiao Chen wrote:
[...]
> > > I suggest implementing a default decoder of NLMSG_DONE messages that
> > > would print the integer in case of len == sizeof(int) and fall back
> > > to  printstrn for other lengths.
> >
> > I updated the patch. default decoder[1]:
>
> Thanks.
>
> > diff --git a/netlink.c b/netlink.c
> > index 678343c..104a65f 100644
> > --- a/netlink.c
> > +++ b/netlink.c
> > @@ -120,6 +120,12 @@ decode_payload(struct tcb *const tcp,
> >   if (nlmsghdr->nlmsg_type == NLMSG_ERROR) {
> >   decode_nlmsgerr(tcp, addr, len);
> >   return;
> > + } else if (nlmsghdr->nlmsg_type == NLMSG_DONE && len == sizeof(int)) {
> > + int total_len;
>
> btw, why do you call it total_len?  This integer can contain anything.

My mistake, now total_len is not a good name, I renamed it to num.

--
JingPiao Chen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20170604/c95fb336/attachment.html>


More information about the Strace-devel mailing list