All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Cc: mkubecek@suse.cz, dcaratti@redhat.com, dsahern@gmail.com,
	jakub.kicinski@netronome.com, johannes@sipsolutions.net,
	john.hurley@netronome.com, netdev@vger.kernel.org,
	paulb@mellanox.com, toke@redhat.com
Subject: Re: [RFC PATCH net-next] sched: act_ctinfo: use extack error reporting
Date: Thu, 13 Jun 2019 09:55:23 -0300	[thread overview]
Message-ID: <20190613125523.GG3436@localhost.localdomain> (raw)
In-Reply-To: <20190613111851.55795-1-ldir@darbyshire-bryant.me.uk>

On Thu, Jun 13, 2019 at 01:18:52PM +0200, Kevin Darbyshire-Bryant wrote:
> Use extack error reporting mechanism in addition to returning -EINVAL
> 
> Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>

Nice. LGTM!

> ---
>  net/sched/act_ctinfo.c | 23 ++++++++++++++++++-----
>  1 file changed, 18 insertions(+), 5 deletions(-)
> 
> diff --git a/net/sched/act_ctinfo.c b/net/sched/act_ctinfo.c
> index e78b60e47c0f..a7d3679d7e2e 100644
> --- a/net/sched/act_ctinfo.c
> +++ b/net/sched/act_ctinfo.c
> @@ -165,15 +165,20 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
>  	u8 dscpmaskshift;
>  	int ret = 0, err;
>  
> -	if (!nla)
> +	if (!nla) {
> +		NL_SET_ERR_MSG_MOD(extack, "ctinfo requires attributes to be passed");
>  		return -EINVAL;
> +	}
>  
> -	err = nla_parse_nested(tb, TCA_CTINFO_MAX, nla, ctinfo_policy, NULL);
> +	err = nla_parse_nested(tb, TCA_CTINFO_MAX, nla, ctinfo_policy, extack);
>  	if (err < 0)
>  		return err;
>  
> -	if (!tb[TCA_CTINFO_ACT])
> +	if (!tb[TCA_CTINFO_ACT]) {
> +		NL_SET_ERR_MSG_MOD(extack,
> +				   "Missing required TCA_CTINFO_ACT attribute");
>  		return -EINVAL;
> +	}
>  	actparm = nla_data(tb[TCA_CTINFO_ACT]);
>  
>  	/* do some basic validation here before dynamically allocating things */
> @@ -182,13 +187,21 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
>  		dscpmask = nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_MASK]);
>  		/* need contiguous 6 bit mask */
>  		dscpmaskshift = dscpmask ? __ffs(dscpmask) : 0;
> -		if ((~0 & (dscpmask >> dscpmaskshift)) != 0x3f)
> +		if ((~0 & (dscpmask >> dscpmaskshift)) != 0x3f) {
> +			NL_SET_ERR_MSG_ATTR(extack,
> +					    tb[TCA_CTINFO_PARMS_DSCP_MASK],
> +					    "dscp mask must be 6 contiguous bits");
>  			return -EINVAL;
> +		}
>  		dscpstatemask = tb[TCA_CTINFO_PARMS_DSCP_STATEMASK] ?
>  			nla_get_u32(tb[TCA_CTINFO_PARMS_DSCP_STATEMASK]) : 0;
>  		/* mask & statemask must not overlap */
> -		if (dscpmask & dscpstatemask)
> +		if (dscpmask & dscpstatemask) {
> +			NL_SET_ERR_MSG_ATTR(extack,
> +					    tb[TCA_CTINFO_PARMS_DSCP_STATEMASK],
> +					    "dscp statemask must not overlap dscp mask");
>  			return -EINVAL;
> +		}
>  	}
>  
>  	/* done the validation:now to the actual action allocation */
> -- 
> 2.20.1 (Apple Git-117)
> 

  reply	other threads:[~2019-06-13 15:20 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-28 17:03 [PATCH net-next v6] net: sched: Introduce act_ctinfo action Kevin 'ldir' Darbyshire-Bryant
2019-05-28 18:08 ` Toke Høiland-Jørgensen
2019-05-28 18:52   ` Kevin 'ldir' Darbyshire-Bryant
2019-05-28 19:38     ` Toke Høiland-Jørgensen
2019-05-28 22:06 ` Cong Wang
2019-05-30  4:44 ` David Miller
2019-05-30 12:01   ` Kevin 'ldir' Darbyshire-Bryant
2019-06-12 18:02 ` Marcelo Ricardo Leitner
2019-06-12 18:46   ` Jakub Kicinski
2019-06-12 18:52     ` Marcelo Ricardo Leitner
2019-06-12 18:56     ` Johannes Berg
2019-06-12 19:18       ` Michal Kubecek
2019-06-12 21:34         ` Jakub Kicinski
2019-06-13 20:12           ` Marcelo Ricardo Leitner
2019-06-13 11:18         ` [RFC PATCH net-next] sched: act_ctinfo: use extack error reporting Kevin Darbyshire-Bryant
2019-06-13 12:55           ` Marcelo Ricardo Leitner [this message]
2019-06-13  8:33     ` [PATCH net-next v6] net: sched: Introduce act_ctinfo action Simon Horman
2019-06-13  9:09       ` Kevin 'ldir' Darbyshire-Bryant
2019-06-13 10:47         ` Kevin 'ldir' Darbyshire-Bryant
2019-06-13 10:53         ` Toke Høiland-Jørgensen
2019-06-13 20:08         ` Marcelo Ricardo Leitner
2019-06-14  9:09           ` [PATCH net-next] sched: act_ctinfo: use extack error reporting Kevin Darbyshire-Bryant
2019-06-14 15:57             ` David Miller

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=20190613125523.GG3436@localhost.localdomain \
    --to=marcelo.leitner@gmail.com \
    --cc=dcaratti@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=johannes@sipsolutions.net \
    --cc=john.hurley@netronome.com \
    --cc=ldir@darbyshire-bryant.me.uk \
    --cc=mkubecek@suse.cz \
    --cc=netdev@vger.kernel.org \
    --cc=paulb@mellanox.com \
    --cc=toke@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.