aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2017-10-26 21:24:30 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-29 09:49:30 -0400
commite910af676b565ecc16bcd6c896ecb68157396ecc (patch)
tree604434afa5e122cd4e9d4a3c071f716f64e6ca21
parentc96a48385d53089ee9977dd0bce82a9493984484 (diff)
net_sched: use tcf_queue_work() in bpf filter
Defer the tcf_exts_destroy() in RCU callback to tc filter workqueue and get RTNL lock. Reported-by: Chris 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: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/sched/cls_bpf.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 520c5027646a..037a3ae86829 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -49,7 +49,10 @@ struct cls_bpf_prog {
49 struct sock_filter *bpf_ops; 49 struct sock_filter *bpf_ops;
50 const char *bpf_name; 50 const char *bpf_name;
51 struct tcf_proto *tp; 51 struct tcf_proto *tp;
52 struct rcu_head rcu; 52 union {
53 struct work_struct work;
54 struct rcu_head rcu;
55 };
53}; 56};
54 57
55static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = { 58static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
@@ -257,9 +260,21 @@ static void __cls_bpf_delete_prog(struct cls_bpf_prog *prog)
257 kfree(prog); 260 kfree(prog);
258} 261}
259 262
263static void cls_bpf_delete_prog_work(struct work_struct *work)
264{
265 struct cls_bpf_prog *prog = container_of(work, struct cls_bpf_prog, work);
266
267 rtnl_lock();
268 __cls_bpf_delete_prog(prog);
269 rtnl_unlock();
270}
271
260static void cls_bpf_delete_prog_rcu(struct rcu_head *rcu) 272static void cls_bpf_delete_prog_rcu(struct rcu_head *rcu)
261{ 273{
262 __cls_bpf_delete_prog(container_of(rcu, struct cls_bpf_prog, rcu)); 274 struct cls_bpf_prog *prog = container_of(rcu, struct cls_bpf_prog, rcu);
275
276 INIT_WORK(&prog->work, cls_bpf_delete_prog_work);
277 tcf_queue_work(&prog->work);
263} 278}
264 279
265static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog) 280static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog)