aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorJamal Hadi Salim <jhs@mojatatu.com>2013-12-23 08:02:12 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-06 16:46:32 -0500
commit63acd6807c50bfb6a526713c640076ae2226c12a (patch)
tree850fdfff2c18c165c8cb6d7fd4b750074d5fc967 /net/sched
parentfbf2671bb8e9c3329c52dae34b06e975a061d0a0 (diff)
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>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/act_api.c46
-rw-r--r--net/sched/cls_api.c2
2 files changed, 16 insertions, 32 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 6f103fd76c17..2b69e537baa9 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -352,18 +352,16 @@ int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
352 } 352 }
353 list_for_each_entry(a, actions, list) { 353 list_for_each_entry(a, actions, list) {
354repeat: 354repeat:
355 if (a->ops) { 355 ret = a->ops->act(skb, a, res);
356 ret = a->ops->act(skb, a, res); 356 if (TC_MUNGED & skb->tc_verd) {
357 if (TC_MUNGED & skb->tc_verd) { 357 /* copied already, allow trampling */
358 /* copied already, allow trampling */ 358 skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd);
359 skb->tc_verd = SET_TC_OK2MUNGE(skb->tc_verd); 359 skb->tc_verd = CLR_TC_MUNGED(skb->tc_verd);
360 skb->tc_verd = CLR_TC_MUNGED(skb->tc_verd);
361 }
362 if (ret == TC_ACT_REPEAT)
363 goto repeat; /* we need a ttl - JHS */
364 if (ret != TC_ACT_PIPE)
365 goto exec_done;
366 } 360 }
361 if (ret == TC_ACT_REPEAT)
362 goto repeat; /* we need a ttl - JHS */
363 if (ret != TC_ACT_PIPE)
364 goto exec_done;
367 } 365 }
368exec_done: 366exec_done:
369 return ret; 367 return ret;
@@ -375,27 +373,16 @@ void tcf_action_destroy(struct list_head *actions, int bind)
375 struct tc_action *a, *tmp; 373 struct tc_action *a, *tmp;
376 374
377 list_for_each_entry_safe(a, tmp, actions, list) { 375 list_for_each_entry_safe(a, tmp, actions, list) {
378 if (a->ops) { 376 if (a->ops->cleanup(a, bind) == ACT_P_DELETED)
379 if (a->ops->cleanup(a, bind) == ACT_P_DELETED) 377 module_put(a->ops->owner);
380 module_put(a->ops->owner); 378 list_del(&a->list);
381 list_del(&a->list); 379 kfree(a);
382 kfree(a);
383 } else {
384 /*FIXME: Remove later - catch insertion bugs*/
385 WARN(1, "tcf_action_destroy: BUG? destroying NULL ops\n");
386 list_del(&a->list);
387 kfree(a);
388 }
389 } 380 }
390} 381}
391 382
392int 383int
393tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref) 384tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
394{ 385{
395 int err = -EINVAL;
396
397 if (a->ops == NULL)
398 return err;
399 return a->ops->dump(skb, a, bind, ref); 386 return a->ops->dump(skb, a, bind, ref);
400} 387}
401 388
@@ -406,9 +393,6 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
406 unsigned char *b = skb_tail_pointer(skb); 393 unsigned char *b = skb_tail_pointer(skb);
407 struct nlattr *nest; 394 struct nlattr *nest;
408 395
409 if (a->ops == NULL)
410 return err;
411
412 if (nla_put_string(skb, TCA_KIND, a->ops->kind)) 396 if (nla_put_string(skb, TCA_KIND, a->ops->kind))
413 goto nla_put_failure; 397 goto nla_put_failure;
414 if (tcf_action_copy_stats(skb, a, 0)) 398 if (tcf_action_copy_stats(skb, a, 0))
@@ -684,7 +668,7 @@ tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 portid)
684 INIT_LIST_HEAD(&a->list); 668 INIT_LIST_HEAD(&a->list);
685 err = -EINVAL; 669 err = -EINVAL;
686 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]); 670 a->ops = tc_lookup_action(tb[TCA_ACT_KIND]);
687 if (a->ops == NULL) 671 if (a->ops == NULL) /* could happen in batch of actions */
688 goto err_free; 672 goto err_free;
689 err = -ENOENT; 673 err = -ENOENT;
690 if (a->ops->lookup(a, index) == 0) 674 if (a->ops->lookup(a, index) == 0)
@@ -760,7 +744,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
760 err = -EINVAL; 744 err = -EINVAL;
761 kind = tb[TCA_ACT_KIND]; 745 kind = tb[TCA_ACT_KIND];
762 a->ops = tc_lookup_action(kind); 746 a->ops = tc_lookup_action(kind);
763 if (a->ops == NULL) 747 if (a->ops == NULL) /*some idjot trying to flush unknown action */
764 goto err_out; 748 goto err_out;
765 749
766 nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0); 750 nlh = nlmsg_put(skb, portid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t), 0);
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 12e882ef596b..d8c42b1b88e5 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -577,7 +577,7 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts)
577 } else if (exts->police) { 577 } else if (exts->police) {
578 struct tc_action *act = tcf_exts_first_act(exts); 578 struct tc_action *act = tcf_exts_first_act(exts);
579 nest = nla_nest_start(skb, exts->police); 579 nest = nla_nest_start(skb, exts->police);
580 if (nest == NULL) 580 if (nest == NULL || !act)
581 goto nla_put_failure; 581 goto nla_put_failure;
582 if (tcf_action_dump_old(skb, act, 0, 0) < 0) 582 if (tcf_action_dump_old(skb, act, 0, 0) < 0)
583 goto nla_put_failure; 583 goto nla_put_failure;