Commit 27ce4f05 authored by Cong Wang's avatar Cong Wang Committed by David S. Miller

net_sched: use tcf_queue_work() in tcindex filter

Defer the tcf_exts_destroy() in RCU callback to
tc filter workqueue and get RTNL lock.
Reported-by: default avatarChris Mi <chrism@mellanox.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d4f84a41
...@@ -27,14 +27,20 @@ ...@@ -27,14 +27,20 @@
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; union {
struct work_struct work;
struct rcu_head rcu;
};
}; };
struct tcindex_filter { struct tcindex_filter {
u16 key; u16 key;
struct tcindex_filter_result result; struct tcindex_filter_result result;
struct tcindex_filter __rcu *next; struct tcindex_filter __rcu *next;
struct rcu_head rcu; union {
struct work_struct work;
struct rcu_head rcu;
};
}; };
...@@ -133,12 +139,34 @@ static int tcindex_init(struct tcf_proto *tp) ...@@ -133,12 +139,34 @@ static int tcindex_init(struct tcf_proto *tp)
return 0; return 0;
} }
static void tcindex_destroy_rexts_work(struct work_struct *work)
{
struct tcindex_filter_result *r;
r = container_of(work, struct tcindex_filter_result, work);
rtnl_lock();
tcf_exts_destroy(&r->exts);
rtnl_unlock();
}
static void tcindex_destroy_rexts(struct rcu_head *head) static void tcindex_destroy_rexts(struct rcu_head *head)
{ {
struct tcindex_filter_result *r; struct tcindex_filter_result *r;
r = container_of(head, struct tcindex_filter_result, rcu); r = container_of(head, struct tcindex_filter_result, rcu);
tcf_exts_destroy(&r->exts); INIT_WORK(&r->work, tcindex_destroy_rexts_work);
tcf_queue_work(&r->work);
}
static void tcindex_destroy_fexts_work(struct work_struct *work)
{
struct tcindex_filter *f = container_of(work, struct tcindex_filter,
work);
rtnl_lock();
tcf_exts_destroy(&f->result.exts);
kfree(f);
rtnl_unlock();
} }
static void tcindex_destroy_fexts(struct rcu_head *head) static void tcindex_destroy_fexts(struct rcu_head *head)
...@@ -146,8 +174,8 @@ static void tcindex_destroy_fexts(struct rcu_head *head) ...@@ -146,8 +174,8 @@ static void tcindex_destroy_fexts(struct rcu_head *head)
struct tcindex_filter *f = container_of(head, struct tcindex_filter, struct tcindex_filter *f = container_of(head, struct tcindex_filter,
rcu); rcu);
tcf_exts_destroy(&f->result.exts); INIT_WORK(&f->work, tcindex_destroy_fexts_work);
kfree(f); tcf_queue_work(&f->work);
} }
static int tcindex_delete(struct tcf_proto *tp, void *arg, bool *last) static int tcindex_delete(struct tcf_proto *tp, void *arg, bool *last)
......
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