Skip to content

Commit

Permalink
net_sched: use tcf_queue_work() in tcindex 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 <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>
  • Loading branch information
Cong Wang authored and David S. Miller committed Oct 29, 2017
1 parent d4f84a4 commit 27ce4f0
Showing 1 changed file with 33 additions and 5 deletions.
38 changes: 33 additions & 5 deletions net/sched/cls_tcindex.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@
struct tcindex_filter_result {
struct tcf_exts exts;
struct tcf_result res;
struct rcu_head rcu;
union {
struct work_struct work;
struct rcu_head rcu;
};
};

struct tcindex_filter {
u16 key;
struct tcindex_filter_result result;
struct tcindex_filter __rcu *next;
struct rcu_head rcu;
union {
struct work_struct work;
struct rcu_head rcu;
};
};


Expand Down Expand Up @@ -133,21 +139,43 @@ static int tcindex_init(struct tcf_proto *tp)
return 0;
}

static void tcindex_destroy_rexts_work(struct work_struct *work)
{
struct tcindex_filter_result *r;

r = container_of(work, struct tcindex_filter_result, work);
rtnl_lock();
tcf_exts_destroy(&r->exts);
rtnl_unlock();
}

static void tcindex_destroy_rexts(struct rcu_head *head)
{
struct tcindex_filter_result *r;

r = container_of(head, struct tcindex_filter_result, rcu);
tcf_exts_destroy(&r->exts);
INIT_WORK(&r->work, tcindex_destroy_rexts_work);
tcf_queue_work(&r->work);
}

static void tcindex_destroy_fexts_work(struct work_struct *work)
{
struct tcindex_filter *f = container_of(work, struct tcindex_filter,
work);

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

static void tcindex_destroy_fexts(struct rcu_head *head)
{
struct tcindex_filter *f = container_of(head, struct tcindex_filter,
rcu);

tcf_exts_destroy(&f->result.exts);
kfree(f);
INIT_WORK(&f->work, tcindex_destroy_fexts_work);
tcf_queue_work(&f->work);
}

static int tcindex_delete(struct tcf_proto *tp, void *arg, bool *last)
Expand Down

0 comments on commit 27ce4f0

Please sign in to comment.