netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: sched: change tcf_del_walker() to use concurrent-safe delete
@ 2018-09-03  7:06 Vlad Buslov
  2018-09-03 18:50 ` Cong Wang
  0 siblings, 1 reply; 14+ messages in thread
From: Vlad Buslov @ 2018-09-03  7:06 UTC (permalink / raw)
  To: netdev; +Cc: jhs, xiyou.wangcong, jiri, davem, Vlad Buslov

Action API was changed to work with actions and action_idr in concurrency
safe manner, however tcf_del_walker() still uses actions without taking
reference to them first and deletes them directly, disregarding possible
concurrent delete.

Change tcf_del_walker() to use tcf_idr_delete_index() that doesn't require
caller to hold reference to action and accepts action id as argument,
instead of direct action pointer.

Modify tcf_action_delete_index() to return ACT_P_DELETED instead of 0 when
action was deleted successfully. This is necessary to allow
tcf_del_walker() to count deleted actions.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
---
 net/sched/act_api.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 398c752ff529..d593114e7d2f 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -246,6 +246,8 @@ static int tcf_dump_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
 	goto done;
 }
 
+static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index);
+
 static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
 			  const struct tc_action_ops *ops)
 {
@@ -263,13 +265,11 @@ static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
 		goto nla_put_failure;
 
 	idr_for_each_entry_ul(idr, p, id) {
-		ret = __tcf_idr_release(p, false, true);
-		if (ret == ACT_P_DELETED) {
-			module_put(ops->owner);
+		ret = tcf_idr_delete_index(idrinfo, id);
+		if (ret == ACT_P_DELETED)
 			n_i++;
-		} else if (ret < 0) {
+		else if (ret < 0)
 			goto nla_put_failure;
-		}
 	}
 	if (nla_put_u32(skb, TCA_FCNT, n_i))
 		goto nla_put_failure;
@@ -343,7 +343,7 @@ static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index)
 
 			tcf_action_cleanup(p);
 			module_put(owner);
-			return 0;
+			return ACT_P_DELETED;
 		}
 		ret = 0;
 	} else {
-- 
2.7.5

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-09-15  2:09 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-03  7:06 [PATCH net-next] net: sched: change tcf_del_walker() to use concurrent-safe delete Vlad Buslov
2018-09-03 18:50 ` Cong Wang
2018-09-03 20:33   ` Vlad Buslov
2018-09-04 22:41     ` Cong Wang
2018-09-05  7:03       ` Vlad Buslov
2018-09-05 20:32         ` Cong Wang
2018-09-06 11:14           ` Vlad Buslov
2018-09-06 19:58             ` Cong Wang
2018-09-07 13:51               ` [PATCH net-next v2] net: sched: change tcf_del_walker() to take idrinfo->lock Vlad Buslov
2018-09-07 19:12                 ` Cong Wang
2018-09-12  8:50                   ` Vlad Buslov
2018-09-13 17:13                     ` Cong Wang
2018-09-14 10:46                       ` Vlad Buslov
2018-09-14 20:53                         ` Cong Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).