Commit ed7aa879 authored by Alexei Starovoitov's avatar Alexei Starovoitov Committed by David S. Miller

net_sched: convert tcindex to call tcf_exts_destroy from rcu callback

Adjust destroy path of cls_tcindex to call tcf_exts_destroy() after
rcu grace period.
Signed-off-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
Acked-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent faa54be4
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
struct tcindex_filter_result { struct tcindex_filter_result {
struct tcf_exts exts; struct tcf_exts exts;
struct tcf_result res; struct tcf_result res;
struct rcu_head rcu;
}; };
struct tcindex_filter { struct tcindex_filter {
...@@ -133,8 +134,23 @@ static int tcindex_init(struct tcf_proto *tp) ...@@ -133,8 +134,23 @@ static int tcindex_init(struct tcf_proto *tp)
return 0; return 0;
} }
static int static void tcindex_destroy_rexts(struct rcu_head *head)
tcindex_delete(struct tcf_proto *tp, unsigned long arg) {
struct tcindex_filter_result *r;
r = container_of(head, struct tcindex_filter_result, rcu);
tcf_exts_destroy(&r->exts);
}
static void tcindex_destroy_fexts(struct rcu_head *head)
{
struct tcindex_filter *f = container_of(head, struct tcindex_filter, rcu);
tcf_exts_destroy(&f->result.exts);
kfree(f);
}
static int tcindex_delete(struct tcf_proto *tp, unsigned long arg)
{ {
struct tcindex_data *p = rtnl_dereference(tp->root); struct tcindex_data *p = rtnl_dereference(tp->root);
struct tcindex_filter_result *r = (struct tcindex_filter_result *) arg; struct tcindex_filter_result *r = (struct tcindex_filter_result *) arg;
...@@ -162,9 +178,14 @@ tcindex_delete(struct tcf_proto *tp, unsigned long arg) ...@@ -162,9 +178,14 @@ tcindex_delete(struct tcf_proto *tp, unsigned long arg)
rcu_assign_pointer(*walk, rtnl_dereference(f->next)); rcu_assign_pointer(*walk, rtnl_dereference(f->next));
} }
tcf_unbind_filter(tp, &r->res); tcf_unbind_filter(tp, &r->res);
tcf_exts_destroy(&r->exts); /* all classifiers are required to call tcf_exts_destroy() after rcu
* grace period, since converted-to-rcu actions are relying on that
* in cleanup() callback
*/
if (f) if (f)
kfree_rcu(f, rcu); call_rcu(&f->rcu, tcindex_destroy_fexts);
else
call_rcu(&r->rcu, tcindex_destroy_rexts);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment