From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Berg Subject: Re: [RFC 4/5] netlink: prepare validate extack setting for recursion Date: Wed, 19 Sep 2018 11:15:25 +0200 Message-ID: <1537348525.10305.15.camel@sipsolutions.net> References: <20180918131212.20266-1-johannes@sipsolutions.net> <20180918131212.20266-4-johannes@sipsolutions.net> <20180919111048.092376b2@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Jiri Benc Return-path: Received: from s3.sipsolutions.net ([144.76.43.62]:51174 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728059AbeISOwe (ORCPT ); Wed, 19 Sep 2018 10:52:34 -0400 In-Reply-To: <20180919111048.092376b2@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: 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