netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Jiri Benc <jbenc@redhat.com>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC 4/5] netlink: prepare validate extack setting for recursion
Date: Wed, 19 Sep 2018 11:15:25 +0200	[thread overview]
Message-ID: <1537348525.10305.15.camel@sipsolutions.net> (raw)
In-Reply-To: <20180919111048.092376b2@redhat.com>

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

  reply	other threads:[~2018-09-19 14:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-18 13:12 [RFC 1/5] netlink: remove NLA_NESTED_COMPAT Johannes Berg
2018-09-18 13:12 ` [RFC 2/5] netlink: set extack error message in nla_validate() Johannes Berg
2018-09-18 17:18   ` David Ahern
2018-09-18 17:36     ` Johannes Berg
2018-09-18 13:12 ` [RFC 3/5] netlink: combine validate/parse functions Johannes Berg
2018-09-18 13:12 ` [RFC 4/5] netlink: prepare validate extack setting for recursion Johannes Berg
2018-09-19  3:37   ` Marcelo Ricardo Leitner
2018-09-19  9:25     ` Johannes Berg
2018-09-19  9:44       ` Jiri Benc
2018-09-19 18:46       ` Marcelo Ricardo Leitner
2018-09-19 19:19         ` Johannes Berg
2018-09-19 21:10           ` Marcelo Ricardo Leitner
2018-09-20  8:14             ` Johannes Berg
2018-09-20 17:48               ` Marcelo Ricardo Leitner
2018-09-19  9:10   ` Jiri Benc
2018-09-19  9:15     ` Johannes Berg [this message]
2018-09-19  9:28       ` Jiri Benc
2018-09-19  9:44         ` Johannes Berg
2018-09-18 13:12 ` [RFC 5/5] netlink: allow NLA_NESTED to specify nested policy to validate Johannes Berg
2018-09-18 17:18 ` [RFC 1/5] netlink: remove NLA_NESTED_COMPAT David Ahern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1537348525.10305.15.camel@sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=jbenc@redhat.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).