Commit b1b5b04f authored by Cong Wang's avatar Cong Wang Committed by David S. Miller

net_sched: use tcf_queue_work() in cgroup filter

Defer the tcf_exts_destroy() in RCU callback to
tc filter workqueue and get RTNL lock.
Reported-by: default avatarChris 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: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e910af67
...@@ -23,7 +23,10 @@ struct cls_cgroup_head { ...@@ -23,7 +23,10 @@ struct cls_cgroup_head {
struct tcf_exts exts; struct tcf_exts exts;
struct tcf_ematch_tree ematches; struct tcf_ematch_tree ematches;
struct tcf_proto *tp; struct tcf_proto *tp;
struct rcu_head rcu; union {
struct work_struct work;
struct rcu_head rcu;
};
}; };
static int cls_cgroup_classify(struct sk_buff *skb, const struct tcf_proto *tp, static int cls_cgroup_classify(struct sk_buff *skb, const struct tcf_proto *tp,
...@@ -57,15 +60,26 @@ static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX + 1] = { ...@@ -57,15 +60,26 @@ static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX + 1] = {
[TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED }, [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED },
}; };
static void cls_cgroup_destroy_work(struct work_struct *work)
{
struct cls_cgroup_head *head = container_of(work,
struct cls_cgroup_head,
work);
rtnl_lock();
tcf_exts_destroy(&head->exts);
tcf_em_tree_destroy(&head->ematches);
kfree(head);
rtnl_unlock();
}
static void cls_cgroup_destroy_rcu(struct rcu_head *root) static void cls_cgroup_destroy_rcu(struct rcu_head *root)
{ {
struct cls_cgroup_head *head = container_of(root, struct cls_cgroup_head *head = container_of(root,
struct cls_cgroup_head, struct cls_cgroup_head,
rcu); rcu);
tcf_exts_destroy(&head->exts); INIT_WORK(&head->work, cls_cgroup_destroy_work);
tcf_em_tree_destroy(&head->ematches); tcf_queue_work(&head->work);
kfree(head);
} }
static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment