Skip to content

Commit 0c83c52

Browse files
tammeladavem330
authored andcommitted
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. Reviewed-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 5036034 commit 0c83c52

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

net/sched/act_pedit.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ static const struct nla_policy pedit_key_ex_policy[TCA_PEDIT_KEY_EX_MAX + 1] = {
3636
};
3737

3838
static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
39-
u8 n)
39+
u8 n, struct netlink_ext_ack *extack)
4040
{
4141
struct tcf_pedit_key_ex *keys_ex;
4242
struct tcf_pedit_key_ex *k;
@@ -57,12 +57,14 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
5757
struct nlattr *tb[TCA_PEDIT_KEY_EX_MAX + 1];
5858

5959
if (!n) {
60+
NL_SET_ERR_MSG_MOD(extack, "Can't parse more extended keys than requested");
6061
err = -EINVAL;
6162
goto err_out;
6263
}
6364
n--;
6465

6566
if (nla_type(ka) != TCA_PEDIT_KEY_EX) {
67+
NL_SET_ERR_MSG_ATTR(extack, ka, "Unknown attribute, expected extended key");
6668
err = -EINVAL;
6769
goto err_out;
6870
}
@@ -73,8 +75,14 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
7375
if (err)
7476
goto err_out;
7577

76-
if (!tb[TCA_PEDIT_KEY_EX_HTYPE] ||
77-
!tb[TCA_PEDIT_KEY_EX_CMD]) {
78+
if (NL_REQ_ATTR_CHECK(extack, nla, tb, TCA_PEDIT_KEY_EX_HTYPE)) {
79+
NL_SET_ERR_MSG(extack, "Missing required attribute");
80+
err = -EINVAL;
81+
goto err_out;
82+
}
83+
84+
if (NL_REQ_ATTR_CHECK(extack, nla, tb, TCA_PEDIT_KEY_EX_CMD)) {
85+
NL_SET_ERR_MSG(extack, "Missing required attribute");
7886
err = -EINVAL;
7987
goto err_out;
8088
}
@@ -86,6 +94,7 @@ static struct tcf_pedit_key_ex *tcf_pedit_keys_ex_parse(struct nlattr *nla,
8694
}
8795

8896
if (n) {
97+
NL_SET_ERR_MSG_MOD(extack, "Not enough extended keys to parse");
8998
err = -EINVAL;
9099
goto err_out;
91100
}
@@ -217,7 +226,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
217226
}
218227

219228
nparms->tcfp_keys_ex =
220-
tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys);
229+
tcf_pedit_keys_ex_parse(tb[TCA_PEDIT_KEYS_EX], parm->nkeys, extack);
221230
if (IS_ERR(nparms->tcfp_keys_ex)) {
222231
ret = PTR_ERR(nparms->tcfp_keys_ex);
223232
goto out_free;

0 commit comments

Comments
 (0)