Skip to content

Commit df2735e

Browse files
congwangdavem330
authored andcommitted
net_sched: use tcf_queue_work() in matchall filter
Defer the tcf_exts_destroy() in RCU callback to tc filter workqueue and get RTNL lock. Reported-by: Chris Mi <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Jiri Pirko <[email protected]> Cc: John Fastabend <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e071dff commit df2735e

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

net/sched/cls_matchall.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ struct cls_mall_head {
2121
struct tcf_result res;
2222
u32 handle;
2323
u32 flags;
24-
struct rcu_head rcu;
24+
union {
25+
struct work_struct work;
26+
struct rcu_head rcu;
27+
};
2528
};
2629

2730
static int mall_classify(struct sk_buff *skb, const struct tcf_proto *tp,
@@ -41,13 +44,23 @@ static int mall_init(struct tcf_proto *tp)
4144
return 0;
4245
}
4346

47+
static void mall_destroy_work(struct work_struct *work)
48+
{
49+
struct cls_mall_head *head = container_of(work, struct cls_mall_head,
50+
work);
51+
rtnl_lock();
52+
tcf_exts_destroy(&head->exts);
53+
kfree(head);
54+
rtnl_unlock();
55+
}
56+
4457
static void mall_destroy_rcu(struct rcu_head *rcu)
4558
{
4659
struct cls_mall_head *head = container_of(rcu, struct cls_mall_head,
4760
rcu);
4861

49-
tcf_exts_destroy(&head->exts);
50-
kfree(head);
62+
INIT_WORK(&head->work, mall_destroy_work);
63+
tcf_queue_work(&head->work);
5164
}
5265

5366
static int mall_replace_hw_filter(struct tcf_proto *tp,

0 commit comments

Comments
 (0)