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

net_sched: use tcf_queue_work() in u32 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 df2735ee
...@@ -68,7 +68,10 @@ struct tc_u_knode { ...@@ -68,7 +68,10 @@ struct tc_u_knode {
u32 __percpu *pcpu_success; u32 __percpu *pcpu_success;
#endif #endif
struct tcf_proto *tp; struct tcf_proto *tp;
union {
struct work_struct work;
struct rcu_head rcu; struct rcu_head rcu;
};
/* The 'sel' field MUST be the last field in structure to allow for /* The 'sel' field MUST be the last field in structure to allow for
* tc_u32_keys allocated at end of structure. * tc_u32_keys allocated at end of structure.
*/ */
...@@ -418,11 +421,21 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n, ...@@ -418,11 +421,21 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n,
* this the u32_delete_key_rcu variant does not free the percpu * this the u32_delete_key_rcu variant does not free the percpu
* statistics. * statistics.
*/ */
static void u32_delete_key_work(struct work_struct *work)
{
struct tc_u_knode *key = container_of(work, struct tc_u_knode, work);
rtnl_lock();
u32_destroy_key(key->tp, key, false);
rtnl_unlock();
}
static void u32_delete_key_rcu(struct rcu_head *rcu) static void u32_delete_key_rcu(struct rcu_head *rcu)
{ {
struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu); struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu);
u32_destroy_key(key->tp, key, false); INIT_WORK(&key->work, u32_delete_key_work);
tcf_queue_work(&key->work);
} }
/* u32_delete_key_freepf_rcu is the rcu callback variant /* u32_delete_key_freepf_rcu is the rcu callback variant
...@@ -432,11 +445,21 @@ static void u32_delete_key_rcu(struct rcu_head *rcu) ...@@ -432,11 +445,21 @@ static void u32_delete_key_rcu(struct rcu_head *rcu)
* for the variant that should be used with keys return from * for the variant that should be used with keys return from
* u32_init_knode() * u32_init_knode()
*/ */
static void u32_delete_key_freepf_work(struct work_struct *work)
{
struct tc_u_knode *key = container_of(work, struct tc_u_knode, work);
rtnl_lock();
u32_destroy_key(key->tp, key, true);
rtnl_unlock();
}
static void u32_delete_key_freepf_rcu(struct rcu_head *rcu) static void u32_delete_key_freepf_rcu(struct rcu_head *rcu)
{ {
struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu); struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu);
u32_destroy_key(key->tp, key, true); INIT_WORK(&key->work, u32_delete_key_freepf_work);
tcf_queue_work(&key->work);
} }
static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key) static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key)
......
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