Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-20 Thread Marcelo Ricardo Leitner
On Thu, Sep 20, 2018 at 10:14:10AM +0200, Johannes Berg wrote: > Anyway - we got into this discussion because of all the extra recursion > stuff I was adding. With the change suggested by David we don't need > that now at all, so I guess it'd be better to propose a patch if you (or > perhaps I will

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-20 Thread Johannes Berg
On Wed, 2018-09-19 at 18:10 -0300, Marcelo Ricardo Leitner wrote: > > FWIW, if you do think that there's a need for distinguishing this, then > > I'd argue that perhaps the right way to address this would be to extend > > this all the way to userspace and have two separate attributes for > > error

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Marcelo Ricardo Leitner
On Wed, Sep 19, 2018 at 09:19:31PM +0200, Johannes Berg wrote: > On Wed, 2018-09-19 at 15:46 -0300, Marcelo Ricardo Leitner wrote: > > > > NL_SET_ERR_MSG(extack, "warning: deprecated command"); > > > err = nla_parse(..., extack); > > > if (err) > > > return err; > > > /* do somet

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Johannes Berg
On Wed, 2018-09-19 at 15:46 -0300, Marcelo Ricardo Leitner wrote: > > NL_SET_ERR_MSG(extack, "warning: deprecated command"); > > err = nla_parse(..., extack); > > if (err) > > return err; > > /* do something */ > > return 0; > > > > Here you could consider the mess

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Marcelo Ricardo Leitner
On Wed, Sep 19, 2018 at 11:25:17AM +0200, Johannes Berg wrote: > On Wed, 2018-09-19 at 00:37 -0300, Marcelo Ricardo Leitner wrote: > > > Did you consider indicating the message level, and only overwrite the > > message that is already in there if the new message level is higher > > than the curren

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Johannes Berg
On Wed, 2018-09-19 at 11:28 +0200, Jiri Benc wrote: > > It might be possible to do this differently, in theory, but all the ways > > I've tried to come up with so far made the code vastly more complex. > > Wouldn't still make sense to store the flag in the struct > netlink_ext_ack, though? Does

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Jiri Benc
On Wed, 19 Sep 2018 11:25:17 +0200, Johannes Berg wrote: > Now, with this patch, all I'm doing is changing the internal behaviour > of nla_parse/nla_validate - externally, it still overwrites any existing > message if an error occurs, but internally it keeps the inner-most > error. Ah, okay, that

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Jiri Benc
On Wed, 19 Sep 2018 11:15:25 +0200, Johannes Berg wrote: > For one, having the NL_SET_* macros check it on their own will already > not work - as we discussed over in the NLA_REJECT thread, we do need to > be able to override the data, e.g. if somebody does > > NL_SET_ERR_MSG(extack, "warning: dep

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Johannes Berg
On Wed, 2018-09-19 at 00:37 -0300, Marcelo Ricardo Leitner wrote: > Did you consider indicating the message level, and only overwrite the > message that is already in there if the new message level is higher > than the current one? Hmm, no, I guess I didn't - I'm not even sure I understand what y

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Johannes Berg
On Wed, 2018-09-19 at 11:10 +0200, Jiri Benc wrote: > On Tue, 18 Sep 2018 15:12:11 +0200, Johannes Berg wrote: > > static int validate_nla(const struct nlattr *nla, int maxtype, > > const struct nla_policy *policy, > > - const char **error_msg) > > +

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-19 Thread Jiri Benc
On Tue, 18 Sep 2018 15:12:11 +0200, Johannes Berg wrote: > static int validate_nla(const struct nlattr *nla, int maxtype, > const struct nla_policy *policy, > - const char **error_msg) > + struct netlink_ext_ack *extack, bool *extack_se

Re: [RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-18 Thread Marcelo Ricardo Leitner
On Tue, Sep 18, 2018 at 03:12:11PM +0200, Johannes Berg wrote: > From: Johannes Berg > > In one of my previous patches in this area I introduced code > to pass out just the error message to store in the extack, for > use in NLA_REJECT. > > Change this code now to set both the error message and t

[RFC 4/5] netlink: prepare validate extack setting for recursion

2018-09-18 Thread Johannes Berg
From: Johannes Berg In one of my previous patches in this area I introduced code to pass out just the error message to store in the extack, for use in NLA_REJECT. Change this code now to set both the error message and the bad attribute pointer, and carry around a boolean indicating that the valu