Commit 6bb16e7a authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

sched: move err set right before goto errout in tc_ctl_tfilter

This makes the reader to know right away what is the error value.
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 33a48927
...@@ -293,9 +293,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n) ...@@ -293,9 +293,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
/* And the last stroke */ /* And the last stroke */
chain = cops->tcf_chain(q, cl); chain = cops->tcf_chain(q, cl);
err = -EINVAL; if (chain == NULL) {
if (chain == NULL) err = -EINVAL;
goto errout; goto errout;
}
if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) { if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) {
tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER); tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
tcf_destroy_chain(chain); tcf_destroy_chain(chain);
...@@ -310,8 +311,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n) ...@@ -310,8 +311,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
if (tp->prio >= prio) { if (tp->prio >= prio) {
if (tp->prio == prio) { if (tp->prio == prio) {
if (!nprio || if (!nprio ||
(tp->protocol != protocol && protocol)) (tp->protocol != protocol && protocol)) {
err = -EINVAL;
goto errout; goto errout;
}
} else } else
tp = NULL; tp = NULL;
break; break;
...@@ -321,13 +324,16 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n) ...@@ -321,13 +324,16 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
if (tp == NULL) { if (tp == NULL) {
/* Proto-tcf does not exist, create new one */ /* Proto-tcf does not exist, create new one */
if (tca[TCA_KIND] == NULL || !protocol) if (tca[TCA_KIND] == NULL || !protocol) {
err = -EINVAL;
goto errout; goto errout;
}
err = -ENOENT;
if (n->nlmsg_type != RTM_NEWTFILTER || if (n->nlmsg_type != RTM_NEWTFILTER ||
!(n->nlmsg_flags & NLM_F_CREATE)) !(n->nlmsg_flags & NLM_F_CREATE)) {
err = -ENOENT;
goto errout; goto errout;
}
if (!nprio) if (!nprio)
nprio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back))); nprio = TC_H_MAJ(tcf_auto_prio(rtnl_dereference(*back)));
...@@ -339,8 +345,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n) ...@@ -339,8 +345,10 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
goto errout; goto errout;
} }
tp_created = 1; tp_created = 1;
} else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) } else if (tca[TCA_KIND] && nla_strcmp(tca[TCA_KIND], tp->ops->kind)) {
err = -EINVAL;
goto errout; goto errout;
}
fh = tp->ops->get(tp, t->tcm_handle); fh = tp->ops->get(tp, t->tcm_handle);
...@@ -357,17 +365,18 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n) ...@@ -357,17 +365,18 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
goto errout; goto errout;
} }
err = -ENOENT;
if (n->nlmsg_type != RTM_NEWTFILTER || if (n->nlmsg_type != RTM_NEWTFILTER ||
!(n->nlmsg_flags & NLM_F_CREATE)) !(n->nlmsg_flags & NLM_F_CREATE)) {
err = -ENOENT;
goto errout; goto errout;
}
} else { } else {
switch (n->nlmsg_type) { switch (n->nlmsg_type) {
case RTM_NEWTFILTER: case RTM_NEWTFILTER:
err = -EEXIST;
if (n->nlmsg_flags & NLM_F_EXCL) { if (n->nlmsg_flags & NLM_F_EXCL) {
if (tp_created) if (tp_created)
tcf_proto_destroy(tp, true); tcf_proto_destroy(tp, true);
err = -EEXIST;
goto errout; goto errout;
} }
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment