aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2017-10-26 21:24:36 -0400
committerDavid S. Miller <davem@davemloft.net>2017-10-29 09:49:31 -0400
commitc0d378ef1266546a39f2df00a56ff1f74166a2b7 (patch)
tree558829cc9645b2ae96f9943de2a6c4bb633865ee /net
parentdf2735ee8e6ca202a8630f237b59401a25193be1 (diff)
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: 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_u32.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c
index 10b8d851fc6b..dadd1b344497 100644
--- a/net/sched/cls_u32.c
+++ b/net/sched/cls_u32.c
@@ -68,7 +68,10 @@ struct tc_u_knode {
68 u32 __percpu *pcpu_success; 68 u32 __percpu *pcpu_success;
69#endif 69#endif
70 struct tcf_proto *tp; 70 struct tcf_proto *tp;
71 struct rcu_head rcu; 71 union {
72 struct work_struct work;
73 struct rcu_head rcu;
74 };
72 /* The 'sel' field MUST be the last field in structure to allow for 75 /* The 'sel' field MUST be the last field in structure to allow for
73 * tc_u32_keys allocated at end of structure. 76 * tc_u32_keys allocated at end of structure.
74 */ 77 */
@@ -418,11 +421,21 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n,
418 * this the u32_delete_key_rcu variant does not free the percpu 421 * this the u32_delete_key_rcu variant does not free the percpu
419 * statistics. 422 * statistics.
420 */ 423 */
424static void u32_delete_key_work(struct work_struct *work)
425{
426 struct tc_u_knode *key = container_of(work, struct tc_u_knode, work);
427
428 rtnl_lock();
429 u32_destroy_key(key->tp, key, false);
430 rtnl_unlock();
431}
432
421static void u32_delete_key_rcu(struct rcu_head *rcu) 433static void u32_delete_key_rcu(struct rcu_head *rcu)
422{ 434{
423 struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu); 435 struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu);
424 436
425 u32_destroy_key(key->tp, key, false); 437 INIT_WORK(&key->work, u32_delete_key_work);
438 tcf_queue_work(&key->work);
426} 439}
427 440
428/* u32_delete_key_freepf_rcu is the rcu callback variant 441/* 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 * for the variant that should be used with keys return from 445 * for the variant that should be used with keys return from
433 * u32_init_knode() 446 * u32_init_knode()
434 */ 447 */
448static void u32_delete_key_freepf_work(struct work_struct *work)
449{
450 struct tc_u_knode *key = container_of(work, struct tc_u_knode, work);
451
452 rtnl_lock();
453 u32_destroy_key(key->tp, key, true);
454 rtnl_unlock();
455}
456
435static void u32_delete_key_freepf_rcu(struct rcu_head *rcu) 457static void u32_delete_key_freepf_rcu(struct rcu_head *rcu)
436{ 458{
437 struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu); 459 struct tc_u_knode *key = container_of(rcu, struct tc_u_knode, rcu);
438 460
439 u32_destroy_key(key->tp, key, true); 461 INIT_WORK(&key->work, u32_delete_key_freepf_work);
462 tcf_queue_work(&key->work);
440} 463}
441 464
442static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key) 465static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key)