aboutsummaryrefslogtreecommitdiffstats
path: root/net/sched
diff options
context:
space:
mode:
authorJohn Fastabend <john.fastabend@gmail.com>2014-10-06 00:27:53 -0400
committerDavid S. Miller <davem@davemloft.net>2014-10-06 18:02:32 -0400
commit82a470f1119eb7d2e4941b915bf9cd6fd8d54494 (patch)
treed16362829e33070f8367876205659fbf271ecfc2 /net/sched
parentfcbeb976d7ce783fd58e63e61c196d9a8912b3be (diff)
net: sched: remove tcf_proto from ematch calls
This removes the tcf_proto argument from the ematch code paths that only need it to reference the net namespace. This allows simplifying qdisc code paths especially when we need to tear down the ematch from an RCU callback. In this case we can not guarentee that the tcf_proto structure is still valid. Signed-off-by: John Fastabend <john.r.fastabend@intel.com> Acked-by: Cong Wang <cwang@twopensource.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched')
-rw-r--r--net/sched/cls_basic.c2
-rw-r--r--net/sched/cls_cgroup.c4
-rw-r--r--net/sched/cls_flow.c4
-rw-r--r--net/sched/em_canid.c4
-rw-r--r--net/sched/em_ipset.c7
-rw-r--r--net/sched/em_meta.c4
-rw-r--r--net/sched/em_nbyte.c2
-rw-r--r--net/sched/em_text.c4
-rw-r--r--net/sched/ematch.c10
9 files changed, 21 insertions, 20 deletions
diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index fe20826a79e7..90647a8af8ca 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -95,7 +95,7 @@ static void basic_delete_filter(struct rcu_head *head)
95 95
96 tcf_unbind_filter(tp, &f->res); 96 tcf_unbind_filter(tp, &f->res);
97 tcf_exts_destroy(&f->exts); 97 tcf_exts_destroy(&f->exts);
98 tcf_em_tree_destroy(tp, &f->ematches); 98 tcf_em_tree_destroy(&f->ematches);
99 kfree(f); 99 kfree(f);
100} 100}
101 101
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c
index 3409f168225f..2f77a89655dc 100644
--- a/net/sched/cls_cgroup.c
+++ b/net/sched/cls_cgroup.c
@@ -87,7 +87,7 @@ static void cls_cgroup_destroy_rcu(struct rcu_head *root)
87 rcu); 87 rcu);
88 88
89 tcf_exts_destroy(&head->exts); 89 tcf_exts_destroy(&head->exts);
90 tcf_em_tree_destroy(head->tp, &head->ematches); 90 tcf_em_tree_destroy(&head->ematches);
91 kfree(head); 91 kfree(head);
92} 92}
93 93
@@ -157,7 +157,7 @@ static void cls_cgroup_destroy(struct tcf_proto *tp)
157 157
158 if (head) { 158 if (head) {
159 tcf_exts_destroy(&head->exts); 159 tcf_exts_destroy(&head->exts);
160 tcf_em_tree_destroy(tp, &head->ematches); 160 tcf_em_tree_destroy(&head->ematches);
161 RCU_INIT_POINTER(tp->root, NULL); 161 RCU_INIT_POINTER(tp->root, NULL);
162 kfree_rcu(head, rcu); 162 kfree_rcu(head, rcu);
163 } 163 }
diff --git a/net/sched/cls_flow.c b/net/sched/cls_flow.c
index f18d27f7b5f2..a5d2b20db560 100644
--- a/net/sched/cls_flow.c
+++ b/net/sched/cls_flow.c
@@ -355,7 +355,7 @@ static void flow_destroy_filter(struct rcu_head *head)
355 355
356 del_timer_sync(&f->perturb_timer); 356 del_timer_sync(&f->perturb_timer);
357 tcf_exts_destroy(&f->exts); 357 tcf_exts_destroy(&f->exts);
358 tcf_em_tree_destroy(f->tp, &f->ematches); 358 tcf_em_tree_destroy(&f->ematches);
359 kfree(f); 359 kfree(f);
360} 360}
361 361
@@ -530,7 +530,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
530 return 0; 530 return 0;
531 531
532err2: 532err2:
533 tcf_em_tree_destroy(tp, &t); 533 tcf_em_tree_destroy(&t);
534 kfree(fnew); 534 kfree(fnew);
535err1: 535err1:
536 tcf_exts_destroy(&e); 536 tcf_exts_destroy(&e);
diff --git a/net/sched/em_canid.c b/net/sched/em_canid.c
index 7c292d474f47..ddd883ca55b2 100644
--- a/net/sched/em_canid.c
+++ b/net/sched/em_canid.c
@@ -120,7 +120,7 @@ static int em_canid_match(struct sk_buff *skb, struct tcf_ematch *m,
120 return match; 120 return match;
121} 121}
122 122
123static int em_canid_change(struct tcf_proto *tp, void *data, int len, 123static int em_canid_change(struct net *net, void *data, int len,
124 struct tcf_ematch *m) 124 struct tcf_ematch *m)
125{ 125{
126 struct can_filter *conf = data; /* Array with rules */ 126 struct can_filter *conf = data; /* Array with rules */
@@ -183,7 +183,7 @@ static int em_canid_change(struct tcf_proto *tp, void *data, int len,
183 return 0; 183 return 0;
184} 184}
185 185
186static void em_canid_destroy(struct tcf_proto *tp, struct tcf_ematch *m) 186static void em_canid_destroy(struct tcf_ematch *m)
187{ 187{
188 struct canid_match *cm = em_canid_priv(m); 188 struct canid_match *cm = em_canid_priv(m);
189 189
diff --git a/net/sched/em_ipset.c b/net/sched/em_ipset.c
index 527aeb7a3ff0..5b4a4efe468c 100644
--- a/net/sched/em_ipset.c
+++ b/net/sched/em_ipset.c
@@ -19,12 +19,11 @@
19#include <net/ip.h> 19#include <net/ip.h>
20#include <net/pkt_cls.h> 20#include <net/pkt_cls.h>
21 21
22static int em_ipset_change(struct tcf_proto *tp, void *data, int data_len, 22static int em_ipset_change(struct net *net, void *data, int data_len,
23 struct tcf_ematch *em) 23 struct tcf_ematch *em)
24{ 24{
25 struct xt_set_info *set = data; 25 struct xt_set_info *set = data;
26 ip_set_id_t index; 26 ip_set_id_t index;
27 struct net *net = dev_net(qdisc_dev(tp->q));
28 27
29 if (data_len != sizeof(*set)) 28 if (data_len != sizeof(*set))
30 return -EINVAL; 29 return -EINVAL;
@@ -42,11 +41,11 @@ static int em_ipset_change(struct tcf_proto *tp, void *data, int data_len,
42 return -ENOMEM; 41 return -ENOMEM;
43} 42}
44 43
45static void em_ipset_destroy(struct tcf_proto *p, struct tcf_ematch *em) 44static void em_ipset_destroy(struct tcf_ematch *em)
46{ 45{
47 const struct xt_set_info *set = (const void *) em->data; 46 const struct xt_set_info *set = (const void *) em->data;
48 if (set) { 47 if (set) {
49 ip_set_nfnl_put(dev_net(qdisc_dev(p->q)), set->index); 48 ip_set_nfnl_put(em->net, set->index);
50 kfree((void *) em->data); 49 kfree((void *) em->data);
51 } 50 }
52} 51}
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c
index 9b8c0b0e60d7..c8f8c399b99a 100644
--- a/net/sched/em_meta.c
+++ b/net/sched/em_meta.c
@@ -856,7 +856,7 @@ static const struct nla_policy meta_policy[TCA_EM_META_MAX + 1] = {
856 [TCA_EM_META_HDR] = { .len = sizeof(struct tcf_meta_hdr) }, 856 [TCA_EM_META_HDR] = { .len = sizeof(struct tcf_meta_hdr) },
857}; 857};
858 858
859static int em_meta_change(struct tcf_proto *tp, void *data, int len, 859static int em_meta_change(struct net *net, void *data, int len,
860 struct tcf_ematch *m) 860 struct tcf_ematch *m)
861{ 861{
862 int err; 862 int err;
@@ -908,7 +908,7 @@ errout:
908 return err; 908 return err;
909} 909}
910 910
911static void em_meta_destroy(struct tcf_proto *tp, struct tcf_ematch *m) 911static void em_meta_destroy(struct tcf_ematch *m)
912{ 912{
913 if (m) 913 if (m)
914 meta_delete((struct meta_match *) m->data); 914 meta_delete((struct meta_match *) m->data);
diff --git a/net/sched/em_nbyte.c b/net/sched/em_nbyte.c
index a3bed07a008b..df3110d69585 100644
--- a/net/sched/em_nbyte.c
+++ b/net/sched/em_nbyte.c
@@ -23,7 +23,7 @@ struct nbyte_data {
23 char pattern[0]; 23 char pattern[0];
24}; 24};
25 25
26static int em_nbyte_change(struct tcf_proto *tp, void *data, int data_len, 26static int em_nbyte_change(struct net *net, void *data, int data_len,
27 struct tcf_ematch *em) 27 struct tcf_ematch *em)
28{ 28{
29 struct tcf_em_nbyte *nbyte = data; 29 struct tcf_em_nbyte *nbyte = data;
diff --git a/net/sched/em_text.c b/net/sched/em_text.c
index 15d353d2e4be..f03c3de16c27 100644
--- a/net/sched/em_text.c
+++ b/net/sched/em_text.c
@@ -45,7 +45,7 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
45 return skb_find_text(skb, from, to, tm->config, &state) != UINT_MAX; 45 return skb_find_text(skb, from, to, tm->config, &state) != UINT_MAX;
46} 46}
47 47
48static int em_text_change(struct tcf_proto *tp, void *data, int len, 48static int em_text_change(struct net *net, void *data, int len,
49 struct tcf_ematch *m) 49 struct tcf_ematch *m)
50{ 50{
51 struct text_match *tm; 51 struct text_match *tm;
@@ -100,7 +100,7 @@ retry:
100 return 0; 100 return 0;
101} 101}
102 102
103static void em_text_destroy(struct tcf_proto *tp, struct tcf_ematch *m) 103static void em_text_destroy(struct tcf_ematch *m)
104{ 104{
105 if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config) 105 if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config)
106 textsearch_destroy(EM_TEXT_PRIV(m)->config); 106 textsearch_destroy(EM_TEXT_PRIV(m)->config);
diff --git a/net/sched/ematch.c b/net/sched/ematch.c
index ad57f4444b9c..8250c36543d8 100644
--- a/net/sched/ematch.c
+++ b/net/sched/ematch.c
@@ -178,6 +178,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
178 struct tcf_ematch_hdr *em_hdr = nla_data(nla); 178 struct tcf_ematch_hdr *em_hdr = nla_data(nla);
179 int data_len = nla_len(nla) - sizeof(*em_hdr); 179 int data_len = nla_len(nla) - sizeof(*em_hdr);
180 void *data = (void *) em_hdr + sizeof(*em_hdr); 180 void *data = (void *) em_hdr + sizeof(*em_hdr);
181 struct net *net = dev_net(qdisc_dev(tp->q));
181 182
182 if (!TCF_EM_REL_VALID(em_hdr->flags)) 183 if (!TCF_EM_REL_VALID(em_hdr->flags))
183 goto errout; 184 goto errout;
@@ -240,7 +241,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
240 goto errout; 241 goto errout;
241 242
242 if (em->ops->change) { 243 if (em->ops->change) {
243 err = em->ops->change(tp, data, data_len, em); 244 err = em->ops->change(net, data, data_len, em);
244 if (err < 0) 245 if (err < 0)
245 goto errout; 246 goto errout;
246 } else if (data_len > 0) { 247 } else if (data_len > 0) {
@@ -271,6 +272,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
271 em->matchid = em_hdr->matchid; 272 em->matchid = em_hdr->matchid;
272 em->flags = em_hdr->flags; 273 em->flags = em_hdr->flags;
273 em->datalen = data_len; 274 em->datalen = data_len;
275 em->net = net;
274 276
275 err = 0; 277 err = 0;
276errout: 278errout:
@@ -378,7 +380,7 @@ errout:
378 return err; 380 return err;
379 381
380errout_abort: 382errout_abort:
381 tcf_em_tree_destroy(tp, tree); 383 tcf_em_tree_destroy(tree);
382 return err; 384 return err;
383} 385}
384EXPORT_SYMBOL(tcf_em_tree_validate); 386EXPORT_SYMBOL(tcf_em_tree_validate);
@@ -393,7 +395,7 @@ EXPORT_SYMBOL(tcf_em_tree_validate);
393 * tcf_em_tree_validate()/tcf_em_tree_change(). You must ensure that 395 * tcf_em_tree_validate()/tcf_em_tree_change(). You must ensure that
394 * the ematch tree is not in use before calling this function. 396 * the ematch tree is not in use before calling this function.
395 */ 397 */
396void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree) 398void tcf_em_tree_destroy(struct tcf_ematch_tree *tree)
397{ 399{
398 int i; 400 int i;
399 401
@@ -405,7 +407,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
405 407
406 if (em->ops) { 408 if (em->ops) {
407 if (em->ops->destroy) 409 if (em->ops->destroy)
408 em->ops->destroy(tp, em); 410 em->ops->destroy(em);
409 else if (!tcf_em_is_simple(em)) 411 else if (!tcf_em_is_simple(em))
410 kfree((void *) em->data); 412 kfree((void *) em->data);
411 module_put(em->ops->owner); 413 module_put(em->ops->owner);