Skip to content

Commit c2f3f31

Browse files
congwangdavem330
authored andcommitted
net_sched: use tcf_queue_work() in route 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>
1 parent c0d378e commit c2f3f31

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

net/sched/cls_route.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ struct route4_filter {
5757
u32 handle;
5858
struct route4_bucket *bkt;
5959
struct tcf_proto *tp;
60-
struct rcu_head rcu;
60+
union {
61+
struct work_struct work;
62+
struct rcu_head rcu;
63+
};
6164
};
6265

6366
#define ROUTE4_FAILURE ((struct route4_filter *)(-1L))
@@ -254,12 +257,22 @@ static int route4_init(struct tcf_proto *tp)
254257
return 0;
255258
}
256259

257-
static void route4_delete_filter(struct rcu_head *head)
260+
static void route4_delete_filter_work(struct work_struct *work)
258261
{
259-
struct route4_filter *f = container_of(head, struct route4_filter, rcu);
262+
struct route4_filter *f = container_of(work, struct route4_filter, work);
260263

264+
rtnl_lock();
261265
tcf_exts_destroy(&f->exts);
262266
kfree(f);
267+
rtnl_unlock();
268+
}
269+
270+
static void route4_delete_filter(struct rcu_head *head)
271+
{
272+
struct route4_filter *f = container_of(head, struct route4_filter, rcu);
273+
274+
INIT_WORK(&f->work, route4_delete_filter_work);
275+
tcf_queue_work(&f->work);
263276
}
264277

265278
static void route4_destroy(struct tcf_proto *tp)

0 commit comments

Comments
 (0)