Skip to content

Commit

Permalink
net_sched: use tcf_queue_work() in route 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 c0d378e commit c2f3f31
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions net/sched/cls_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ struct route4_filter {
u32 handle;
struct route4_bucket *bkt;
struct tcf_proto *tp;
struct rcu_head rcu;
union {
struct work_struct work;
struct rcu_head rcu;
};
};

#define ROUTE4_FAILURE ((struct route4_filter *)(-1L))
Expand Down Expand Up @@ -254,12 +257,22 @@ static int route4_init(struct tcf_proto *tp)
return 0;
}

static void route4_delete_filter(struct rcu_head *head)
static void route4_delete_filter_work(struct work_struct *work)
{
struct route4_filter *f = container_of(head, struct route4_filter, rcu);
struct route4_filter *f = container_of(work, struct route4_filter, work);

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

static void route4_delete_filter(struct rcu_head *head)
{
struct route4_filter *f = container_of(head, struct route4_filter, rcu);

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

static void route4_destroy(struct tcf_proto *tp)
Expand Down

0 comments on commit c2f3f31

Please sign in to comment.