Skip to content

Commit

Permalink
net_sched: use tcf_queue_work() in fw filter
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
congwang authored and davem330 committed Oct 29, 2017
1 parent 0552c8a commit e071dff
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions net/sched/cls_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ struct fw_filter {
#endif /* CONFIG_NET_CLS_IND */
struct tcf_exts exts;
struct tcf_proto *tp;
struct rcu_head rcu;
union {
struct work_struct work;
struct rcu_head rcu;
};
};

static u32 fw_hash(u32 handle)
Expand Down Expand Up @@ -119,12 +122,22 @@ static int fw_init(struct tcf_proto *tp)
return 0;
}

static void fw_delete_filter(struct rcu_head *head)
static void fw_delete_filter_work(struct work_struct *work)
{
struct fw_filter *f = container_of(head, struct fw_filter, rcu);
struct fw_filter *f = container_of(work, struct fw_filter, work);

rtnl_lock();
tcf_exts_destroy(&f->exts);
kfree(f);
rtnl_unlock();
}

static void fw_delete_filter(struct rcu_head *head)
{
struct fw_filter *f = container_of(head, struct fw_filter, rcu);

INIT_WORK(&f->work, fw_delete_filter_work);
tcf_queue_work(&f->work);
}

static void fw_destroy(struct tcf_proto *tp)
Expand Down

0 comments on commit e071dff

Please sign in to comment.