From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [RFC 2/5] netlink: set extack error message in nla_validate() Date: Tue, 18 Sep 2018 10:18:05 -0700 Message-ID: References: <20180918131212.20266-1-johannes@sipsolutions.net> <20180918131212.20266-2-johannes@sipsolutions.net> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Johannes Berg To: Johannes Berg , netdev@vger.kernel.org Return-path: Received: from mail-pf1-f180.google.com ([209.85.210.180]:38982 "EHLO mail-pf1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730137AbeIRWvl (ORCPT ); Tue, 18 Sep 2018 18:51:41 -0400 Received: by mail-pf1-f180.google.com with SMTP id j8-v6so1332395pff.6 for ; Tue, 18 Sep 2018 10:18:08 -0700 (PDT) In-Reply-To: <20180918131212.20266-2-johannes@sipsolutions.net> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 9/18/18 6:12 AM, Johannes Berg wrote: > diff --git a/lib/nlattr.c b/lib/nlattr.c > index 120ad569e13d..efbd6c1aff29 100644 > --- a/lib/nlattr.c > +++ b/lib/nlattr.c > @@ -181,9 +181,13 @@ int nla_validate(const struct nlattr *head, int len, int maxtype, > int rem; > > nla_for_each_attr(nla, head, len, rem) { > - int err = validate_nla(nla, maxtype, policy, NULL); > + static const char _msg[] = "Attribute failed policy validation"; > + const char *msg = _msg; > + int err = validate_nla(nla, maxtype, policy, &msg); > > if (err < 0) { > + if (extack) > + extack->_msg = msg; > NL_SET_BAD_ATTR(extack, nla); > return err; > } > I take it this set is on top of another set - the NLA_REJECT?