[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230309185158.310994-2-pctammela@mojatatu.com>
Date: Thu, 9 Mar 2023 15:51:56 -0300
From: Pedro Tammela <pctammela@...atatu.com>
To: netdev@...r.kernel.org
Cc: jhs@...atatu.com, xiyou.wangcong@...il.com, jiri@...nulli.us,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, Pedro Tammela <pctammela@...atatu.com>
Subject: [PATCH net-next 1/3] net/sched: act_pedit: use extack in 'ex' parsing errors
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@...atatu.com>
Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
---
net/sched/act_pedit.c | 27 ++++++++++-----------------
1 file changed, 10 insertions(+), 17 deletions(-)
diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index 4559a1507ea5..f4ebe06aeaf2 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;
@@ -55,26 +55,21 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
nla_for_each_nested(ka, nla, rem) {
struct nlattr *tb[TCA_PEDIT_KEY_EX_MAX + 1];
- if (!n) {
- err = -EINVAL;
+ if (!n)
goto err_out;
- }
n--;
- if (nla_type(ka) != TCA_PEDIT_KEY_EX) {
- err = -EINVAL;
+ if (nla_type(ka) != TCA_PEDIT_KEY_EX)
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;
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,23 +78,21 @@ 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;
}
k++;
}
- if (n) {
- err = -EINVAL;
+ if (n)
goto err_out;
- }
return keys_ex;
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 +215,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
Powered by blists - more mailing lists