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) > > + struct netlink_ext_ack *extack, bool *extack_set) > > Can't the extack_set be included in the struct netlink_ext_ack? One less > parameter to pass around and the NL_SET_* macros could check this on > their own.
No, I don't think it can or should. 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: deprecated command"); err = nla_parse(..., extack); and nla_parse() sets a new message. Thus, hiding all the logic in there already will not work, and is also IMHO rather unexpected. Normally, *later* messages should win, not *earlier* ones - and that doesn't require any tracking, just setting them unconditionally. It's just a side effect of how we do the recursive validation here that we want *earlier* messages to win (but only within this code piece - if a previous message was set, we want it to be overwritten by nla_parse!). 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. johannes