public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri-rHqAuBHg3fBzbRFIqnYvSA@public.gmane.org>
To: Johannes Berg <johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	pablo-Cap9r6Oaw4JrovVCs/uTlw@public.gmane.org,
	Jamal Hadi Salim <jhs-jkUAjuhPggJWk0Htik3J/w@public.gmane.org>,
	Jiri Benc <jbenc-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	David Ahern
	<dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>,
	Johannes Berg
	<johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH net-next v5 4/5] netlink: pass extended ACK struct to parsing functions
Date: Wed, 12 Apr 2017 15:56:08 +0200	[thread overview]
Message-ID: <20170412135608.GG1952@nanopsycho> (raw)
In-Reply-To: <20170412123408.22012-5-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>

Wed, Apr 12, 2017 at 02:34:07PM CEST, johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org wrote:
>From: Johannes Berg <johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>
>Pass the new extended ACK reporting struct to all of the
>generic netlink parsing functions. For now, pass NULL in
>almost all callers (except for some in the core.)
>
>Signed-off-by: Johannes Berg <johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
>---

[...]

>diff --git a/lib/nlattr.c b/lib/nlattr.c
>index b42b8577fc23..a7e0b16078df 100644
>--- a/lib/nlattr.c
>+++ b/lib/nlattr.c
>@@ -112,6 +112,7 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
>  * @len: length of attribute stream
>  * @maxtype: maximum attribute type to be expected
>  * @policy: validation policy
>+ * @extack: extended ACK report struct
>  *
>  * Validates all attributes in the specified attribute stream against the
>  * specified policy. Attributes with a type exceeding maxtype will be
>@@ -120,20 +121,23 @@ static int validate_nla(const struct nlattr *nla, int maxtype,
>  * Returns 0 on success or a negative error code.
>  */
> int nla_validate(const struct nlattr *head, int len, int maxtype,
>-		 const struct nla_policy *policy)
>+		 const struct nla_policy *policy,
>+		 struct netlink_ext_ack *extack)
> {
> 	const struct nlattr *nla;
>-	int rem, err;
>+	int rem;
> 
> 	nla_for_each_attr(nla, head, len, rem) {
>-		err = validate_nla(nla, maxtype, policy);
>-		if (err < 0)
>-			goto errout;
>+		int err = validate_nla(nla, maxtype, policy);
>+
>+		if (err < 0) {

		You can just check:
	 	if (err)
		while you are at it. validate_nla never returns positive
		value.

Btw, unrelated to this patch, I find it odd to have 2 functions:
nla_validate
validate_nla
Confusing :)


>+			if (extack)
>+				extack->bad_attr = nla;
>+			return err;
>+		}
> 	}
> 
>-	err = 0;
>-errout:
>-	return err;
>+	return 0;
> }
> EXPORT_SYMBOL(nla_validate);
> 
>@@ -180,7 +184,8 @@ EXPORT_SYMBOL(nla_policy_len);
>  * Returns 0 on success or a negative error code.
>  */
> int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
>-	      int len, const struct nla_policy *policy)
>+	      int len, const struct nla_policy *policy,
>+	      struct netlink_ext_ack *extack)
> {
> 	const struct nlattr *nla;
> 	int rem, err;
>@@ -193,8 +198,11 @@ int nla_parse(struct nlattr **tb, int maxtype, const struct nlattr *head,
> 		if (type > 0 && type <= maxtype) {
> 			if (policy) {
> 				err = validate_nla(nla, maxtype, policy);
>-				if (err < 0)
>+				if (err < 0) {

Same here.



>+					if (extack)
>+						extack->bad_attr = nla;
> 					goto errout;
>+				}
> 			}
> 
> 			tb[type] = (struct nlattr *)nla;

  parent reply	other threads:[~2017-04-12 13:56 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12 12:34 [PATCH net-next v5 0/5] netlink extended ACK reporting Johannes Berg
2017-04-12 12:34 ` [PATCH net-next v5 1/5] netlink: " Johannes Berg
2017-04-12 15:06   ` David Ahern
     [not found]     ` <dbc81431-487b-f218-a4c6-2caa44783d97-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org>
2017-04-12 15:13       ` Jiri Pirko
2017-04-12 15:28         ` David Miller
2017-04-12 15:21     ` Johannes Berg
     [not found]       ` <1492010503.2855.14.camel-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2017-04-12 15:30         ` David Miller
     [not found]   ` <20170412123408.22012-2-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2017-04-12 13:41     ` Jiri Pirko
2017-04-12 15:32     ` David Ahern
2017-04-12 12:34 ` [PATCH net-next v5 2/5] genetlink: pass extended ACK report down Johannes Berg
2017-04-12 14:01   ` Jiri Pirko
2017-04-12 12:34 ` [PATCH net-next v5 3/5] netlink: allow sending extended ACK with cookie on success Johannes Berg
     [not found]   ` <20170412123408.22012-4-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2017-04-12 13:47     ` Jiri Pirko
2017-04-12 13:54       ` Johannes Berg
     [not found] ` <20170412123408.22012-1-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2017-04-12 12:34   ` [PATCH net-next v5 4/5] netlink: pass extended ACK struct to parsing functions Johannes Berg
2017-04-12 13:17     ` Jiri Pirko
2017-04-12 13:20       ` Johannes Berg
2017-04-12 13:24         ` Jiri Pirko
2017-04-12 14:02       ` Kalle Valo
2017-04-12 14:08         ` Jiri Pirko
     [not found]     ` <20170412123408.22012-5-johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org>
2017-04-12 13:56       ` Jiri Pirko [this message]
2017-04-12 12:34   ` [PATCH net-next v5 5/5] netlink: pass extended ACK struct where available Johannes Berg
2017-04-12 14:00     ` Jiri Pirko
2017-04-12 14:55       ` David Ahern
2017-04-12 15:15         ` Jiri Pirko
2017-04-12 15:29           ` David Miller
2017-04-12 14:57 ` [PATCH net-next v5 0/5] netlink extended ACK reporting 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=20170412135608.GG1952@nanopsycho \
    --to=jiri-rhqaubhg3fbzbrfiqnyvsa@public.gmane.org \
    --cc=dsa-qUQiAmfTcIp+XZJcv9eMoEEOCMrvLtNR@public.gmane.org \
    --cc=jbenc-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=jhs-jkUAjuhPggJWk0Htik3J/w@public.gmane.org \
    --cc=johannes-cdvu00un1VgdHxzADdlk8Q@public.gmane.org \
    --cc=johannes.berg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pablo-Cap9r6Oaw4JrovVCs/uTlw@public.gmane.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