[PATCH v6 4/4] Netlink: handle multi netlink messages

Dmitry V. Levin ldv at altlinux.org
Wed Jun 22 12:45:58 UTC 2016


On Wed, Jun 22, 2016 at 12:18:38PM +0000, Fabien Siron wrote:
> Quoting Dmitry V. Levin (2016-06-22 11:13:42)
> > On Wed, Jun 22, 2016 at 10:19:03AM +0000, Fabien Siron wrote:
> > > Quoting Dmitry V. Levin (2016-06-21 17:43:49)
> > > > On Tue, Jun 21, 2016 at 02:42:46PM +0000, Fabien Siron wrote:
> [...]
> > > > > +     if (nlmsghdr.nlmsg_len != (unsigned) -1 &&
> > > > > +         nlmsghdr.nlmsg_len != 0 &&
> > > > > +         NLMSG_ALIGN(nlmsghdr.nlmsg_len) < total_size) {
> > > > > +             tprints("]");
> > > > > +     }
> > > > > +}
> > > > 
> > > > This check doesn't look obvious; is it correct?
> > > > Is there a more clear way to implement this?
> > > 
> > > If nlmsghdr.nlmsg_len is equal to -1, it means that umoven had failed.
> > 
> > No.
> > 
> > > If nlmsghdr.nlmsg_len is equal to 0, it means that nlmsg_fetch had failed.
> > > I am not 100% sure of the last test but it seems that it's a correct way to
> > > detect if there were several messages. 
> > > 
> > > Have you got another idea to do this test?
> > 
> > Just set a flag if "[" has been printed, and test it afterwards.
> > 
> > Also, nlmsg_fetch returns 0 when nlmsghdr->nlmsg_len doesn't look sane.
> > Shouldn't strace print something meaningful in tis case, rather than
> > silently ignore invalid nlmsghdr?
> 
> It already prints a string if the data is longer than 0 (instead of printing
> the header), does strace have to print something else?

Only if len < sizeof(struct nlmsghdr).
When len < nlmsghdr->nlmsg_len, it silently returns 0.

I think that if struct nlmsghdr has been successfully fetched,
the header should be printed regardless of its nlmsg_len.


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


More information about the Strace-devel mailing list