diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2017-10-26 21:24:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-29 09:49:30 -0400 |
commit | e910af676b565ecc16bcd6c896ecb68157396ecc (patch) | |
tree | 604434afa5e122cd4e9d4a3c071f716f64e6ca21 | |
parent | c96a48385d53089ee9977dd0bce82a9493984484 (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.c | 19 |
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 | ||
55 | static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = { | 58 | static 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 | ||
263 | static 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 | |||
260 | static void cls_bpf_delete_prog_rcu(struct rcu_head *rcu) | 272 | static 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 | ||
265 | static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog) | 280 | static void __cls_bpf_delete(struct tcf_proto *tp, struct cls_bpf_prog *prog) |