[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230418234354.582693-2-pctammela@mojatatu.com>
Date: Tue, 18 Apr 2023 20:43:50 -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, simon.horman@...igine.com,
Pedro Tammela <pctammela@...atatu.com>
Subject: [PATCH net-next v4 1/5] net/sched: act_pedit: simplify 'ex' key parsing error propagation
'err' is returned -EINVAL most of the time.
Make the exception be the netlink parsing and remove the
redundant error assignments in the other code paths.
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..90f5214e679e 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -54,46 +54,39 @@ 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];
+ int ret;
- 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,
+ ret = nla_parse_nested_deprecated(tb, TCA_PEDIT_KEY_EX_MAX,
ka, pedit_key_ex_policy,
NULL);
- if (err)
+ if (ret) {
+ err = ret;
goto err_out;
+ }
if (!tb[TCA_PEDIT_KEY_EX_HTYPE] ||
- !tb[TCA_PEDIT_KEY_EX_CMD]) {
- err = -EINVAL;
+ !tb[TCA_PEDIT_KEY_EX_CMD])
goto err_out;
- }
k->htype = nla_get_u16(tb[TCA_PEDIT_KEY_EX_HTYPE]);
k->cmd = nla_get_u16(tb[TCA_PEDIT_KEY_EX_CMD]);
if (k->htype > TCA_PEDIT_HDR_TYPE_MAX ||
- k->cmd > TCA_PEDIT_CMD_MAX) {
- err = -EINVAL;
+ k->cmd > TCA_PEDIT_CMD_MAX)
goto err_out;
- }
k++;
}
- if (n) {
- err = -EINVAL;
+ if (n)
goto err_out;
- }
return keys_ex;
--
2.34.1
Powered by blists - more mailing lists