summaryrefslogtreecommitdiffstats
path: root/net/sched/act_api.c
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2016-02-22 15:57:52 -0800
committerDavid S. Miller <davem@davemloft.net>2016-02-25 14:16:21 -0500
commit1d4150c02c5709fdfd80f10368a31867de35e72e (patch)
treea92e0f4c5d2199012a1c9135ef564640d1d10d74 /net/sched/act_api.c
parent555d5b70f1597906dc2e31085f5e70b49d03a536 (diff)
downloadlinux-stable-1d4150c02c5709fdfd80f10368a31867de35e72e.tar.gz
linux-stable-1d4150c02c5709fdfd80f10368a31867de35e72e.tar.bz2
linux-stable-1d4150c02c5709fdfd80f10368a31867de35e72e.zip
net_sched: prepare tcf_hashinfo_destroy() for netns support
We only release the memory of the hashtable itself, not its entries inside. This is not a problem yet since we only call it in module release path, and module is refcount'ed by actions. This would be a problem after we move the per module hinfo into per netns in the latter patch. Cc: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Acked-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.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 06e7c4a37245..acafaf7434fc 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -69,7 +69,7 @@ int __tcf_hash_release(struct tc_action *a, bool bind, bool strict)
if (a->ops->cleanup)
a->ops->cleanup(a, bind);
tcf_hash_destroy(a);
- ret = 1;
+ ret = ACT_P_DELETED;
}
}
@@ -302,6 +302,32 @@ void tcf_hash_insert(struct tc_action *a)
}
EXPORT_SYMBOL(tcf_hash_insert);
+static void tcf_hashinfo_destroy(const struct tc_action_ops *ops)
+{
+ struct tcf_hashinfo *hinfo = ops->hinfo;
+ struct tc_action a = {
+ .ops = ops,
+ };
+ int i;
+
+ for (i = 0; i < hinfo->hmask + 1; i++) {
+ struct tcf_common *p;
+ struct hlist_node *n;
+
+ hlist_for_each_entry_safe(p, n, &hinfo->htab[i], tcfc_head) {
+ int ret;
+
+ a.priv = p;
+ ret = __tcf_hash_release(&a, false, true);
+ if (ret == ACT_P_DELETED)
+ module_put(ops->owner);
+ else if (ret < 0)
+ return;
+ }
+ }
+ kfree(hinfo->htab);
+}
+
static LIST_HEAD(act_base);
static DEFINE_RWLOCK(act_mod_lock);
@@ -333,7 +359,7 @@ int tcf_register_action(struct tc_action_ops *act, unsigned int mask)
list_for_each_entry(a, &act_base, head) {
if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
write_unlock(&act_mod_lock);
- tcf_hashinfo_destroy(act->hinfo);
+ tcf_hashinfo_destroy(act);
kfree(act->hinfo);
return -EEXIST;
}
@@ -353,7 +379,7 @@ int tcf_unregister_action(struct tc_action_ops *act)
list_for_each_entry(a, &act_base, head) {
if (a == act) {
list_del(&act->head);
- tcf_hashinfo_destroy(act->hinfo);
+ tcf_hashinfo_destroy(act);
kfree(act->hinfo);
err = 0;
break;