Skip to content

Commit 94cdb47

Browse files
congwangdavem330
authored andcommitted
net_sched: use tcf_queue_work() in flow 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 b1b5b04 commit 94cdb47

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

net/sched/cls_flow.c

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ struct flow_filter {
5757
u32 divisor;
5858
u32 baseclass;
5959
u32 hashrnd;
60-
struct rcu_head rcu;
60+
union {
61+
struct work_struct work;
62+
struct rcu_head rcu;
63+
};
6164
};
6265

6366
static inline u32 addr_fold(void *addr)
@@ -369,14 +372,24 @@ static const struct nla_policy flow_policy[TCA_FLOW_MAX + 1] = {
369372
[TCA_FLOW_PERTURB] = { .type = NLA_U32 },
370373
};
371374

372-
static void flow_destroy_filter(struct rcu_head *head)
375+
static void flow_destroy_filter_work(struct work_struct *work)
373376
{
374-
struct flow_filter *f = container_of(head, struct flow_filter, rcu);
377+
struct flow_filter *f = container_of(work, struct flow_filter, work);
375378

379+
rtnl_lock();
376380
del_timer_sync(&f->perturb_timer);
377381
tcf_exts_destroy(&f->exts);
378382
tcf_em_tree_destroy(&f->ematches);
379383
kfree(f);
384+
rtnl_unlock();
385+
}
386+
387+
static void flow_destroy_filter(struct rcu_head *head)
388+
{
389+
struct flow_filter *f = container_of(head, struct flow_filter, rcu);
390+
391+
INIT_WORK(&f->work, flow_destroy_filter_work);
392+
tcf_queue_work(&f->work);
380393
}
381394

382395
static int flow_change(struct net *net, struct sk_buff *in_skb,

0 commit comments

Comments
 (0)