aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched/act_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r--net/sched/act_api.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 23b25f89e7e0..a606025814a1 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -26,11 +26,6 @@
26#include <net/act_api.h> 26#include <net/act_api.h>
27#include <net/netlink.h> 27#include <net/netlink.h>
28 28
29static void tcf_common_free_rcu(struct rcu_head *head)
30{
31 kfree(container_of(head, struct tcf_common, tcfc_rcu));
32}
33
34void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo) 29void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
35{ 30{
36 unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask); 31 unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask);
@@ -47,7 +42,7 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
47 * gen_estimator est_timer() might access p->tcfc_lock 42 * gen_estimator est_timer() might access p->tcfc_lock
48 * or bstats, wait a RCU grace period before freeing p 43 * or bstats, wait a RCU grace period before freeing p
49 */ 44 */
50 call_rcu(&p->tcfc_rcu, tcf_common_free_rcu); 45 kfree_rcu(p, tcfc_rcu);
51 return; 46 return;
52 } 47 }
53 } 48 }
@@ -78,7 +73,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
78 struct tc_action *a, struct tcf_hashinfo *hinfo) 73 struct tc_action *a, struct tcf_hashinfo *hinfo)
79{ 74{
80 struct tcf_common *p; 75 struct tcf_common *p;
81 int err = 0, index = -1,i = 0, s_i = 0, n_i = 0; 76 int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
82 struct nlattr *nest; 77 struct nlattr *nest;
83 78
84 read_lock_bh(hinfo->lock); 79 read_lock_bh(hinfo->lock);
@@ -126,7 +121,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
126{ 121{
127 struct tcf_common *p, *s_p; 122 struct tcf_common *p, *s_p;
128 struct nlattr *nest; 123 struct nlattr *nest;
129 int i= 0, n_i = 0; 124 int i = 0, n_i = 0;
130 125
131 nest = nla_nest_start(skb, a->order); 126 nest = nla_nest_start(skb, a->order);
132 if (nest == NULL) 127 if (nest == NULL)
@@ -138,7 +133,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
138 while (p != NULL) { 133 while (p != NULL) {
139 s_p = p->tcfc_next; 134 s_p = p->tcfc_next;
140 if (ACT_P_DELETED == tcf_hash_release(p, 0, hinfo)) 135 if (ACT_P_DELETED == tcf_hash_release(p, 0, hinfo))
141 module_put(a->ops->owner); 136 module_put(a->ops->owner);
142 n_i++; 137 n_i++;
143 p = s_p; 138 p = s_p;
144 } 139 }
@@ -447,7 +442,8 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
447 nest = nla_nest_start(skb, TCA_OPTIONS); 442 nest = nla_nest_start(skb, TCA_OPTIONS);
448 if (nest == NULL) 443 if (nest == NULL)
449 goto nla_put_failure; 444 goto nla_put_failure;
450 if ((err = tcf_action_dump_old(skb, a, bind, ref)) > 0) { 445 err = tcf_action_dump_old(skb, a, bind, ref);
446 if (err > 0) {
451 nla_nest_end(skb, nest); 447 nla_nest_end(skb, nest);
452 return err; 448 return err;
453 } 449 }
@@ -491,7 +487,7 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
491 struct tc_action *a; 487 struct tc_action *a;
492 struct tc_action_ops *a_o; 488 struct tc_action_ops *a_o;
493 char act_name[IFNAMSIZ]; 489 char act_name[IFNAMSIZ];
494 struct nlattr *tb[TCA_ACT_MAX+1]; 490 struct nlattr *tb[TCA_ACT_MAX + 1];
495 struct nlattr *kind; 491 struct nlattr *kind;
496 int err; 492 int err;
497 493
@@ -549,9 +545,9 @@ struct tc_action *tcf_action_init_1(struct nlattr *nla, struct nlattr *est,
549 goto err_free; 545 goto err_free;
550 546
551 /* module count goes up only when brand new policy is created 547 /* module count goes up only when brand new policy is created
552 if it exists and is only bound to in a_o->init() then 548 * if it exists and is only bound to in a_o->init() then
553 ACT_P_CREATED is not returned (a zero is). 549 * ACT_P_CREATED is not returned (a zero is).
554 */ 550 */
555 if (err != ACT_P_CREATED) 551 if (err != ACT_P_CREATED)
556 module_put(a_o->owner); 552 module_put(a_o->owner);
557 a->ops = a_o; 553 a->ops = a_o;
@@ -569,7 +565,7 @@ err_out:
569struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est, 565struct tc_action *tcf_action_init(struct nlattr *nla, struct nlattr *est,
570 char *name, int ovr, int bind) 566 char *name, int ovr, int bind)
571{ 567{
572 struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; 568 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
573 struct tc_action *head = NULL, *act, *act_prev = NULL; 569 struct tc_action *head = NULL, *act, *act_prev = NULL;
574 int err; 570 int err;
575 int i; 571 int i;
@@ -697,7 +693,7 @@ act_get_notify(struct net *net, u32 pid, struct nlmsghdr *n,
697static struct tc_action * 693static struct tc_action *
698tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid) 694tcf_action_get_1(struct nlattr *nla, struct nlmsghdr *n, u32 pid)
699{ 695{
700 struct nlattr *tb[TCA_ACT_MAX+1]; 696 struct nlattr *tb[TCA_ACT_MAX + 1];
701 struct tc_action *a; 697 struct tc_action *a;
702 int index; 698 int index;
703 int err; 699 int err;
@@ -770,7 +766,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
770 struct tcamsg *t; 766 struct tcamsg *t;
771 struct netlink_callback dcb; 767 struct netlink_callback dcb;
772 struct nlattr *nest; 768 struct nlattr *nest;
773 struct nlattr *tb[TCA_ACT_MAX+1]; 769 struct nlattr *tb[TCA_ACT_MAX + 1];
774 struct nlattr *kind; 770 struct nlattr *kind;
775 struct tc_action *a = create_a(0); 771 struct tc_action *a = create_a(0);
776 int err = -ENOMEM; 772 int err = -ENOMEM;
@@ -821,7 +817,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
821 nlh->nlmsg_flags |= NLM_F_ROOT; 817 nlh->nlmsg_flags |= NLM_F_ROOT;
822 module_put(a->ops->owner); 818 module_put(a->ops->owner);
823 kfree(a); 819 kfree(a);
824 err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, n->nlmsg_flags&NLM_F_ECHO); 820 err = rtnetlink_send(skb, net, pid, RTNLGRP_TC,
821 n->nlmsg_flags & NLM_F_ECHO);
825 if (err > 0) 822 if (err > 0)
826 return 0; 823 return 0;
827 824
@@ -842,14 +839,14 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
842 u32 pid, int event) 839 u32 pid, int event)
843{ 840{
844 int i, ret; 841 int i, ret;
845 struct nlattr *tb[TCA_ACT_MAX_PRIO+1]; 842 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
846 struct tc_action *head = NULL, *act, *act_prev = NULL; 843 struct tc_action *head = NULL, *act, *act_prev = NULL;
847 844
848 ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL); 845 ret = nla_parse_nested(tb, TCA_ACT_MAX_PRIO, nla, NULL);
849 if (ret < 0) 846 if (ret < 0)
850 return ret; 847 return ret;
851 848
852 if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { 849 if (event == RTM_DELACTION && n->nlmsg_flags & NLM_F_ROOT) {
853 if (tb[1] != NULL) 850 if (tb[1] != NULL)
854 return tca_action_flush(net, tb[1], n, pid); 851 return tca_action_flush(net, tb[1], n, pid);
855 else 852 else
@@ -892,7 +889,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
892 /* now do the delete */ 889 /* now do the delete */
893 tcf_action_destroy(head, 0); 890 tcf_action_destroy(head, 0);
894 ret = rtnetlink_send(skb, net, pid, RTNLGRP_TC, 891 ret = rtnetlink_send(skb, net, pid, RTNLGRP_TC,
895 n->nlmsg_flags&NLM_F_ECHO); 892 n->nlmsg_flags & NLM_F_ECHO);
896 if (ret > 0) 893 if (ret > 0)
897 return 0; 894 return 0;
898 return ret; 895 return ret;
@@ -936,7 +933,7 @@ static int tcf_add_notify(struct net *net, struct tc_action *a,
936 nlh->nlmsg_len = skb_tail_pointer(skb) - b; 933 nlh->nlmsg_len = skb_tail_pointer(skb) - b;
937 NETLINK_CB(skb).dst_group = RTNLGRP_TC; 934 NETLINK_CB(skb).dst_group = RTNLGRP_TC;
938 935
939 err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags&NLM_F_ECHO); 936 err = rtnetlink_send(skb, net, pid, RTNLGRP_TC, flags & NLM_F_ECHO);
940 if (err > 0) 937 if (err > 0)
941 err = 0; 938 err = 0;
942 return err; 939 return err;
@@ -967,7 +964,7 @@ tcf_action_add(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
967 964
968 /* dump then free all the actions after update; inserted policy 965 /* dump then free all the actions after update; inserted policy
969 * stays intact 966 * stays intact
970 * */ 967 */
971 ret = tcf_add_notify(net, act, pid, seq, RTM_NEWACTION, n->nlmsg_flags); 968 ret = tcf_add_notify(net, act, pid, seq, RTM_NEWACTION, n->nlmsg_flags);
972 for (a = act; a; a = act) { 969 for (a = act; a; a = act) {
973 act = a->next; 970 act = a->next;
@@ -993,17 +990,16 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
993 return -EINVAL; 990 return -EINVAL;
994 } 991 }
995 992
996 /* n->nlmsg_flags&NLM_F_CREATE 993 /* n->nlmsg_flags & NLM_F_CREATE */
997 * */
998 switch (n->nlmsg_type) { 994 switch (n->nlmsg_type) {
999 case RTM_NEWACTION: 995 case RTM_NEWACTION:
1000 /* we are going to assume all other flags 996 /* we are going to assume all other flags
1001 * imply create only if it doesnt exist 997 * imply create only if it doesn't exist
1002 * Note that CREATE | EXCL implies that 998 * Note that CREATE | EXCL implies that
1003 * but since we want avoid ambiguity (eg when flags 999 * but since we want avoid ambiguity (eg when flags
1004 * is zero) then just set this 1000 * is zero) then just set this
1005 */ 1001 */
1006 if (n->nlmsg_flags&NLM_F_REPLACE) 1002 if (n->nlmsg_flags & NLM_F_REPLACE)
1007 ovr = 1; 1003 ovr = 1;
1008replay: 1004replay:
1009 ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, pid, ovr); 1005 ret = tcf_action_add(net, tca[TCA_ACT_TAB], n, pid, ovr);
@@ -1028,7 +1024,7 @@ replay:
1028static struct nlattr * 1024static struct nlattr *
1029find_dump_kind(const struct nlmsghdr *n) 1025find_dump_kind(const struct nlmsghdr *n)
1030{ 1026{
1031 struct nlattr *tb1, *tb2[TCA_ACT_MAX+1]; 1027 struct nlattr *tb1, *tb2[TCA_ACT_MAX + 1];
1032 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1]; 1028 struct nlattr *tb[TCA_ACT_MAX_PRIO + 1];
1033 struct nlattr *nla[TCAA_MAX + 1]; 1029 struct nlattr *nla[TCAA_MAX + 1];
1034 struct nlattr *kind; 1030 struct nlattr *kind;
@@ -1071,9 +1067,8 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
1071 } 1067 }
1072 1068
1073 a_o = tc_lookup_action(kind); 1069 a_o = tc_lookup_action(kind);
1074 if (a_o == NULL) { 1070 if (a_o == NULL)
1075 return 0; 1071 return 0;
1076 }
1077 1072
1078 memset(&a, 0, sizeof(struct tc_action)); 1073 memset(&a, 0, sizeof(struct tc_action));
1079 a.ops = a_o; 1074 a.ops = a_o;