From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: [PATCH net 12/13] net: sched: cls_u32: keep track of knodes count in tc_u_common Date: Sun, 9 Sep 2018 02:31:31 +0100 Message-ID: <20180909013132.3222-13-viro@ZenIV.linux.org.uk> References: <20180909013132.3222-1-viro@ZenIV.linux.org.uk> Cc: Jamal Hadi Salim , Cong Wang , Jiri Pirko To: netdev@vger.kernel.org Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:41066 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726084AbeIIG0B (ORCPT ); Sun, 9 Sep 2018 02:26:01 -0400 In-Reply-To: <20180909013132.3222-1-viro@ZenIV.linux.org.uk> Sender: netdev-owner@vger.kernel.org List-ID: From: Al Viro allows to simplify u32_delete() considerably Signed-off-by: Al Viro --- net/sched/cls_u32.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index f6bb3885598d..86cbe4f5800e 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -97,6 +97,7 @@ struct tc_u_common { int refcnt; struct idr handle_idr; struct hlist_node hnode; + long knodes; }; static inline unsigned int u32_hash_fold(__be32 key, @@ -453,6 +454,7 @@ static void u32_delete_key_freepf_work(struct work_struct *work) static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key) { + struct tc_u_common *tp_c = tp->data; struct tc_u_knode __rcu **kp; struct tc_u_knode *pkp; struct tc_u_hnode *ht = rtnl_dereference(key->ht_up); @@ -463,6 +465,7 @@ static int u32_delete_key(struct tcf_proto *tp, struct tc_u_knode *key) kp = &pkp->next, pkp = rtnl_dereference(*kp)) { if (pkp == key) { RCU_INIT_POINTER(*kp, key->next); + tp_c->knodes--; tcf_unbind_filter(tp, &key->res); idr_remove(&ht->handle_idr, key->handle); @@ -577,6 +580,7 @@ static int u32_replace_hw_knode(struct tcf_proto *tp, struct tc_u_knode *n, static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht, struct netlink_ext_ack *extack) { + struct tc_u_common *tp_c = tp->data; struct tc_u_knode *n; unsigned int h; @@ -584,6 +588,7 @@ static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht, while ((n = rtnl_dereference(ht->ht[h])) != NULL) { RCU_INIT_POINTER(ht->ht[h], rtnl_dereference(n->next)); + tp_c->knodes--; tcf_unbind_filter(tp, &n->res); u32_remove_hw_knode(tp, n, extack); idr_remove(&ht->handle_idr, n->handle); @@ -1140,6 +1145,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, RCU_INIT_POINTER(n->next, pins); rcu_assign_pointer(*ins, n); + tp_c->knodes++; *arg = n; return 0; } -- 2.11.0