From: Simon Horman <simon.horman@corigine.com>
To: Pedro Tammela <pctammela@mojatatu.com>
Cc: netdev@vger.kernel.org, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, jiri@resnulli.us, davem@davemloft.net,
edumazet@google.com, kuba@kernel.org, pabeni@redhat.com
Subject: Re: [PATCH net-next v2 1/4] net/sched: act_pedit: use extack in 'ex' parsing errors
Date: Wed, 15 Mar 2023 16:51:53 +0100 [thread overview]
Message-ID: <ZBHpmU+E0gXHRjB2@corigine.com> (raw)
In-Reply-To: <20230314202448.603841-2-pctammela@mojatatu.com>
On Tue, Mar 14, 2023 at 05:24:45PM -0300, Pedro Tammela wrote:
> We have extack available when parsing 'ex' keys, so pass it to
> tcf_pedit_keys_ex_parse and add more detailed error messages.
> While at it, remove redundant code from the 'err_out' label code path.
>
> Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
> ---
> net/sched/act_pedit.c | 22 +++++++++++-----------
> 1 file changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index 4559a1507ea5..be9e7e565551 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -35,7 +35,7 @@ static const struct nla_policy pedit_key_ex_policy[TCA_PEDIT_KEY_EX_MAX + 1] = {
> };
>
> static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
> - u8 n)
> + u8 n, struct netlink_ext_ack *extack)
> {
> struct tcf_pedit_key_ex *keys_ex;
> struct tcf_pedit_key_ex *k;
> @@ -56,25 +56,25 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
> struct nlattr *tb[TCA_PEDIT_KEY_EX_MAX + 1];
>
> if (!n) {
> - err = -EINVAL;
> + NL_SET_ERR_MSG_MOD(extack, "Can't parse more extended keys than requested");
> goto err_out;
> }
> +
> n--;
>
> if (nla_type(ka) != TCA_PEDIT_KEY_EX) {
> - err = -EINVAL;
> + NL_SET_ERR_MSG_MOD(extack, "Unknown attribute, expected extended key");
> goto err_out;
> }
>
> - err = nla_parse_nested_deprecated(tb, TCA_PEDIT_KEY_EX_MAX,
> - ka, pedit_key_ex_policy,
> - NULL);
> + err = nla_parse_nested_deprecated(tb, TCA_PEDIT_KEY_EX_MAX, ka,
> + pedit_key_ex_policy, extack);
> if (err)
> goto err_out;
err_out will return ERR_PTR(-EINVAL).
I.e. the value of is not propagated.
Are you sure it is always -EINVAL?
>
> if (!tb[TCA_PEDIT_KEY_EX_HTYPE] ||
> !tb[TCA_PEDIT_KEY_EX_CMD]) {
> - err = -EINVAL;
> + NL_SET_ERR_MSG_MOD(extack, "Extended Pedit missing required attributes");
> goto err_out;
> }
>
> @@ -83,7 +83,7 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
>
> if (k->htype > TCA_PEDIT_HDR_TYPE_MAX ||
> k->cmd > TCA_PEDIT_CMD_MAX) {
> - err = -EINVAL;
> + NL_SET_ERR_MSG_MOD(extack, "Extended Pedit key is malformed");
> goto err_out;
> }
>
> @@ -91,7 +91,7 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
> }
>
> if (n) {
> - err = -EINVAL;
> + NL_SET_ERR_MSG_MOD(extack, "Not enough extended keys to parse");
> goto err_out;
> }
>
> @@ -99,7 +99,7 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
>
> err_out:
> kfree(keys_ex);
> - return ERR_PTR(err);
> + return ERR_PTR(-EINVAL);
> }
>
> static int tcf_pedit_key_ex_dump(struct sk_buff *skb,
> @@ -222,7 +222,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
> }
>
> nparms->tcfp_keys_ex =
> - tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys);
> + tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys, extack);
> if (IS_ERR(nparms->tcfp_keys_ex)) {
> ret = PTR_ERR(nparms->tcfp_keys_ex);
> goto out_free;
> --
> 2.34.1
>
next prev parent reply other threads:[~2023-03-15 15:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 20:24 [PATCH net-next v2 0/4] net/sched: act_pedit: minor improvements Pedro Tammela
2023-03-14 20:24 ` [PATCH net-next v2 1/4] net/sched: act_pedit: use extack in 'ex' parsing errors Pedro Tammela
2023-03-15 15:51 ` Simon Horman [this message]
2023-03-17 19:15 ` Pedro Tammela
2023-03-14 20:24 ` [PATCH net-next v2 2/4] net/sched: act_pedit: check static offsets a priori Pedro Tammela
2023-03-15 15:52 ` Simon Horman
2023-03-14 20:24 ` [PATCH net-next v2 3/4] net/sched: act_pedit: remove extra check for key type Pedro Tammela
2023-03-15 15:53 ` Simon Horman
2023-03-14 20:24 ` [PATCH net-next v2 4/4] net/sched: act_pedit: rate limit datapath messages Pedro Tammela
2023-03-15 15:53 ` Simon Horman
2023-03-14 21:24 ` [PATCH net-next v2 0/4] net/sched: act_pedit: minor improvements Pedro Tammela
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=ZBHpmU+E0gXHRjB2@corigine.com \
--to=simon.horman@corigine.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pctammela@mojatatu.com \
--cc=xiyou.wangcong@gmail.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.