Commit 259e60f96785ab9043bb6eea5b90b354053f98cc

Authored by Vlad Buslov
Committed by David S. Miller
1 parent 195c234d15

net: sched: flower: protect masks list with spinlock

Protect modifications of flower masks list with spinlock to remove
dependency on rtnl lock and allow concurrent access.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 8 additions and 0 deletions Side-by-side Diff

net/sched/cls_flower.c
... ... @@ -88,6 +88,7 @@
88 88  
89 89 struct cls_fl_head {
90 90 struct rhashtable ht;
  91 + spinlock_t masks_lock; /* Protect masks list */
91 92 struct list_head masks;
92 93 struct rcu_work rwork;
93 94 struct idr handle_idr;
... ... @@ -312,6 +313,7 @@
312 313 if (!head)
313 314 return -ENOBUFS;
314 315  
  316 + spin_lock_init(&head->masks_lock);
315 317 INIT_LIST_HEAD_RCU(&head->masks);
316 318 rcu_assign_pointer(tp->root, head);
317 319 idr_init(&head->handle_idr);
318 320  
... ... @@ -341,7 +343,11 @@
341 343 return false;
342 344  
343 345 rhashtable_remove_fast(&head->ht, &mask->ht_node, mask_ht_params);
  346 +
  347 + spin_lock(&head->masks_lock);
344 348 list_del_rcu(&mask->list);
  349 + spin_unlock(&head->masks_lock);
  350 +
345 351 if (async)
346 352 tcf_queue_work(&mask->rwork, fl_mask_free_work);
347 353 else
348 354  
... ... @@ -1312,7 +1318,9 @@
1312 1318 /* Wait until any potential concurrent users of mask are finished */
1313 1319 synchronize_rcu();
1314 1320  
  1321 + spin_lock(&head->masks_lock);
1315 1322 list_add_tail_rcu(&newmask->list, &head->masks);
  1323 + spin_unlock(&head->masks_lock);
1316 1324  
1317 1325 return newmask;
1318 1326