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

Fabien Siron fabien.siron at epita.fr
Wed Jun 22 12:18:38 UTC 2016


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?

--
Fabien Siron




More information about the Strace-devel mailing list