mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
net_sched: Remove unnecessary checks for act->ops
Remove unnecessary checks for act->ops (suggested by Eric Dumazet). Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
fbf2671bb8
commit
63acd6807c
2 changed files with 16 additions and 32 deletions
|
@ -352,7 +352,6 @@ int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
|
||||||
}
|
}
|
||||||
list_for_each_entry(a, actions, list) {
|
list_for_each_entry(a, actions, list) {
|
||||||
repeat:
|
repeat:
|
||||||
if (a->ops) {
|
|
||||||
ret = a->ops->act(skb, a, res);
|
ret = a->ops->act(skb, a, res);
|
||||||
if (TC_MUNGED & skb->tc_verd) {
|
if (TC_MUNGED & skb->tc_verd) {
|
||||||
/* copied already, allow trampling */
|
/* copied already, allow trampling */
|
||||||
|
@ -364,7 +363,6 @@ repeat:
|
||||||
if (ret != TC_ACT_PIPE)
|
if (ret != TC_ACT_PIPE)
|
||||||
goto exec_done;
|
goto exec_done;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
exec_done:
|
exec_done:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -375,27 +373,16 @@ void tcf_action_destroy(struct list_head *actions, int bind)
|
||||||
struct tc_action *a, *tmp;
|
struct tc_action *a, *tmp;
|
||||||
|
|
||||||
list_for_each_entry_safe(a, tmp, actions, list) {
|
list_for_each_entry_safe(a, tmp, actions, list) {
|
||||||
if (a->ops) {
|
|
||||||
if (a->ops->cleanup(a, bind) == ACT_P_DELETED)
|
if (a->ops->cleanup(a, bind) == ACT_P_DELETED)
|
||||||
module_put(a->ops->owner);
|
module_put(a->ops->owner);
|
||||||
list_del(&a->list);
|
list_del(&a->list);
|
||||||
kfree(a);
|
kfree(a);
|
||||||
} else {
|
|
||||||
/*FIXME: Remove later - catch insertion bugs*/
|
|
||||||
WARN(1, "tcf_action_destroy: BUG? destroying NULL ops\n");
|
|
||||||
list_del(&a->list);
|
|
||||||
kfree(a);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
|
tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
|
||||||
{
|
{
|
||||||
int err = -EINVAL;
|
|
||||||
|
|
||||||
if (a->ops == NULL)
|
|
||||||
return err;
|
|
||||||
return a->ops->dump(skb, a, bind, ref);
|
return a->ops->dump(skb, a, bind, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -406,9 +393,6 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
|
||||||
unsigned char *b = skb_tail_pointer(skb);
|
unsigned char *b = skb_tail_pointer(skb);
|
||||||
struct nlattr *nest;
|
struct nlattr *nest;
|
||||||
|
|
||||||
if (a->ops == NULL)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
if (nla_put_string(skb, TCA_KIND, a->ops->kind))
|
if (nla_put_string(skb, TCA_KIND, a->ops->kind))
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
if (tcf_action_copy_stats(skb, a, 0))
|
if (tcf_action_copy_stats(skb, a, 0))
|
||||||
|
@ -684,7 +668,7 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid)
|
||||||
INIT_LIST_HEAD(&a->list);
|
INIT_LIST_HEAD(&a->list);
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
|
a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
|
||||||
if (a->ops == NULL)
|
if (a->ops == NULL) /* could happen in batch of actions */
|
||||||
goto err_free;
|
goto err_free;
|
||||||
err = -ENOENT;
|
err = -ENOENT;
|
||||||
if (a->ops->lookup(a, index) == 0)
|
if (a->ops->lookup(a, index) == 0)
|
||||||
|
@ -760,7 +744,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
kind = tb[TCA_ACT_KIND];
|
kind = tb[TCA_ACT_KIND];
|
||||||
a->ops = tc_lookup_action(kind);
|
a->ops = tc_lookup_action(kind);
|
||||||
if (a->ops == NULL)
|
if (a->ops == NULL) /*some idjot trying to flush unknown action */
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
|
nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
|
||||||
|
|
|
@ -577,7 +577,7 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts)
|
||||||
} else if (exts->police) {
|
} else if (exts->police) {
|
||||||
struct tc_action *act = tcf_exts_first_act(exts);
|
struct tc_action *act = tcf_exts_first_act(exts);
|
||||||
nest = nla_nest_start(skb, exts->police);
|
nest = nla_nest_start(skb, exts->police);
|
||||||
if (nest == NULL)
|
if (nest == NULL || !act)
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
if (tcf_action_dump_old(skb, act, 0, 0) < 0)
|
if (tcf_action_dump_old(skb, act, 0, 0) < 0)
|
||||||
goto nla_put_failure;
|
goto nla_put_failure;
|
||||||
|
|
Loading…
Add table
Reference in a new issue