diff options
author | WANG Cong <xiyou.wangcong@gmail.com> | 2014-02-11 20:07:31 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-02-12 19:23:32 -0500 |
commit | 86062033feb8a1692f7a3d570c652f1b4a4b4b52 (patch) | |
tree | 1f17c34b7d610f666ffd9e20adbe998d846c7b9b /net/sched/act_api.c | |
parent | 7282ec8cb4f82287c2aef20a24328b42c630f7cb (diff) |
net_sched: act: hide struct tcf_common from API
Now we can totally hide it from modules. tcf_hash_*() API's
will operate on struct tc_action, modules don't need to care about
the details.
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sched/act_api.c')
-rw-r--r-- | net/sched/act_api.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 72bdc7166345..4f2b807b3621 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -27,8 +27,11 @@ | |||
27 | #include <net/act_api.h> | 27 | #include <net/act_api.h> |
28 | #include <net/netlink.h> | 28 | #include <net/netlink.h> |
29 | 29 | ||
30 | void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo) | 30 | void tcf_hash_destroy(struct tc_action *a) |
31 | { | 31 | { |
32 | struct tcf_common *p = a->priv; | ||
33 | struct tcf_hashinfo *hinfo = a->ops->hinfo; | ||
34 | |||
32 | spin_lock_bh(&hinfo->lock); | 35 | spin_lock_bh(&hinfo->lock); |
33 | hlist_del(&p->tcfc_head); | 36 | hlist_del(&p->tcfc_head); |
34 | spin_unlock_bh(&hinfo->lock); | 37 | spin_unlock_bh(&hinfo->lock); |
@@ -42,9 +45,9 @@ void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo) | |||
42 | } | 45 | } |
43 | EXPORT_SYMBOL(tcf_hash_destroy); | 46 | EXPORT_SYMBOL(tcf_hash_destroy); |
44 | 47 | ||
45 | int tcf_hash_release(struct tcf_common *p, int bind, | 48 | int tcf_hash_release(struct tc_action *a, int bind) |
46 | struct tcf_hashinfo *hinfo) | ||
47 | { | 49 | { |
50 | struct tcf_common *p = a->priv; | ||
48 | int ret = 0; | 51 | int ret = 0; |
49 | 52 | ||
50 | if (p) { | 53 | if (p) { |
@@ -53,7 +56,7 @@ int tcf_hash_release(struct tcf_common *p, int bind, | |||
53 | 56 | ||
54 | p->tcfc_refcnt--; | 57 | p->tcfc_refcnt--; |
55 | if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) { | 58 | if (p->tcfc_bindcnt <= 0 && p->tcfc_refcnt <= 0) { |
56 | tcf_hash_destroy(p, hinfo); | 59 | tcf_hash_destroy(a); |
57 | ret = 1; | 60 | ret = 1; |
58 | } | 61 | } |
59 | } | 62 | } |
@@ -127,7 +130,8 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a) | |||
127 | for (i = 0; i < (hinfo->hmask + 1); i++) { | 130 | for (i = 0; i < (hinfo->hmask + 1); i++) { |
128 | head = &hinfo->htab[tcf_hash(i, hinfo->hmask)]; | 131 | head = &hinfo->htab[tcf_hash(i, hinfo->hmask)]; |
129 | hlist_for_each_entry_safe(p, n, head, tcfc_head) { | 132 | hlist_for_each_entry_safe(p, n, head, tcfc_head) { |
130 | if (ACT_P_DELETED == tcf_hash_release(p, 0, hinfo)) { | 133 | a->priv = p; |
134 | if (ACT_P_DELETED == tcf_hash_release(a, 0)) { | ||
131 | module_put(a->ops->owner); | 135 | module_put(a->ops->owner); |
132 | n_i++; | 136 | n_i++; |
133 | } | 137 | } |
@@ -198,7 +202,7 @@ int tcf_hash_search(struct tc_action *a, u32 index) | |||
198 | } | 202 | } |
199 | EXPORT_SYMBOL(tcf_hash_search); | 203 | EXPORT_SYMBOL(tcf_hash_search); |
200 | 204 | ||
201 | struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind) | 205 | int tcf_hash_check(u32 index, struct tc_action *a, int bind) |
202 | { | 206 | { |
203 | struct tcf_hashinfo *hinfo = a->ops->hinfo; | 207 | struct tcf_hashinfo *hinfo = a->ops->hinfo; |
204 | struct tcf_common *p = NULL; | 208 | struct tcf_common *p = NULL; |
@@ -207,19 +211,30 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind) | |||
207 | p->tcfc_bindcnt++; | 211 | p->tcfc_bindcnt++; |
208 | p->tcfc_refcnt++; | 212 | p->tcfc_refcnt++; |
209 | a->priv = p; | 213 | a->priv = p; |
214 | return 1; | ||
210 | } | 215 | } |
211 | return p; | 216 | return 0; |
212 | } | 217 | } |
213 | EXPORT_SYMBOL(tcf_hash_check); | 218 | EXPORT_SYMBOL(tcf_hash_check); |
214 | 219 | ||
215 | struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, | 220 | void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est) |
216 | struct tc_action *a, int size, int bind) | 221 | { |
222 | struct tcf_common *pc = a->priv; | ||
223 | if (est) | ||
224 | gen_kill_estimator(&pc->tcfc_bstats, | ||
225 | &pc->tcfc_rate_est); | ||
226 | kfree_rcu(pc, tcfc_rcu); | ||
227 | } | ||
228 | EXPORT_SYMBOL(tcf_hash_cleanup); | ||
229 | |||
230 | int tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a, | ||
231 | int size, int bind) | ||
217 | { | 232 | { |
218 | struct tcf_hashinfo *hinfo = a->ops->hinfo; | 233 | struct tcf_hashinfo *hinfo = a->ops->hinfo; |
219 | struct tcf_common *p = kzalloc(size, GFP_KERNEL); | 234 | struct tcf_common *p = kzalloc(size, GFP_KERNEL); |
220 | 235 | ||
221 | if (unlikely(!p)) | 236 | if (unlikely(!p)) |
222 | return ERR_PTR(-ENOMEM); | 237 | return -ENOMEM; |
223 | p->tcfc_refcnt = 1; | 238 | p->tcfc_refcnt = 1; |
224 | if (bind) | 239 | if (bind) |
225 | p->tcfc_bindcnt = 1; | 240 | p->tcfc_bindcnt = 1; |
@@ -234,17 +249,19 @@ struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est, | |||
234 | &p->tcfc_lock, est); | 249 | &p->tcfc_lock, est); |
235 | if (err) { | 250 | if (err) { |
236 | kfree(p); | 251 | kfree(p); |
237 | return ERR_PTR(err); | 252 | return err; |
238 | } | 253 | } |
239 | } | 254 | } |
240 | 255 | ||
241 | a->priv = (void *) p; | 256 | a->priv = (void *) p; |
242 | return p; | 257 | return 0; |
243 | } | 258 | } |
244 | EXPORT_SYMBOL(tcf_hash_create); | 259 | EXPORT_SYMBOL(tcf_hash_create); |
245 | 260 | ||
246 | void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo) | 261 | void tcf_hash_insert(struct tc_action *a) |
247 | { | 262 | { |
263 | struct tcf_common *p = a->priv; | ||
264 | struct tcf_hashinfo *hinfo = a->ops->hinfo; | ||
248 | unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask); | 265 | unsigned int h = tcf_hash(p->tcfc_index, hinfo->hmask); |
249 | 266 | ||
250 | spin_lock_bh(&hinfo->lock); | 267 | spin_lock_bh(&hinfo->lock); |