diff options
author | Cong Wang <xiyou.wangcong@gmail.com> | 2017-10-26 21:24:31 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-29 09:49:30 -0400 |
commit | b1b5b04fdb6da262aef37ef83b9f2e41326720ef (patch) | |
tree | 572b1bae9f6e87f857ad8bd7066f5ccb07621c52 /net | |
parent | e910af676b565ecc16bcd6c896ecb68157396ecc (diff) |
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: 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>
Diffstat (limited to 'net')
-rw-r--r-- | net/sched/cls_cgroup.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/net/sched/cls_cgroup.c b/net/sched/cls_cgroup.c index d48452f87975..a97e069bee89 100644 --- a/net/sched/cls_cgroup.c +++ b/net/sched/cls_cgroup.c | |||
@@ -23,7 +23,10 @@ struct cls_cgroup_head { | |||
23 | struct tcf_exts exts; | 23 | struct tcf_exts exts; |
24 | struct tcf_ematch_tree ematches; | 24 | struct tcf_ematch_tree ematches; |
25 | struct tcf_proto *tp; | 25 | struct tcf_proto *tp; |
26 | struct rcu_head rcu; | 26 | union { |
27 | struct work_struct work; | ||
28 | struct rcu_head rcu; | ||
29 | }; | ||
27 | }; | 30 | }; |
28 | 31 | ||
29 | static int cls_cgroup_classify(struct sk_buff *skb, const struct tcf_proto *tp, | 32 | 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 | [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED }, | 60 | [TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED }, |
58 | }; | 61 | }; |
59 | 62 | ||
63 | static void cls_cgroup_destroy_work(struct work_struct *work) | ||
64 | { | ||
65 | struct cls_cgroup_head *head = container_of(work, | ||
66 | struct cls_cgroup_head, | ||
67 | work); | ||
68 | rtnl_lock(); | ||
69 | tcf_exts_destroy(&head->exts); | ||
70 | tcf_em_tree_destroy(&head->ematches); | ||
71 | kfree(head); | ||
72 | rtnl_unlock(); | ||
73 | } | ||
74 | |||
60 | static void cls_cgroup_destroy_rcu(struct rcu_head *root) | 75 | static void cls_cgroup_destroy_rcu(struct rcu_head *root) |
61 | { | 76 | { |
62 | struct cls_cgroup_head *head = container_of(root, | 77 | struct cls_cgroup_head *head = container_of(root, |
63 | struct cls_cgroup_head, | 78 | struct cls_cgroup_head, |
64 | rcu); | 79 | rcu); |
65 | 80 | ||
66 | tcf_exts_destroy(&head->exts); | 81 | INIT_WORK(&head->work, cls_cgroup_destroy_work); |
67 | tcf_em_tree_destroy(&head->ematches); | 82 | tcf_queue_work(&head->work); |
68 | kfree(head); | ||
69 | } | 83 | } |
70 | 84 | ||
71 | static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, | 85 | static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb, |