From patchwork Sun Oct 7 16:38:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jamal Hadi Salim X-Patchwork-Id: 980207 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mojatatu.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=mojatatu-com.20150623.gappssmtp.com header.i=@mojatatu-com.20150623.gappssmtp.com header.b="RjQ31TxM"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42Sq1r3G2XzB2xk for ; Mon, 8 Oct 2018 03:38:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728393AbeJGXq1 (ORCPT ); Sun, 7 Oct 2018 19:46:27 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:46160 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727992AbeJGXq0 (ORCPT ); Sun, 7 Oct 2018 19:46:26 -0400 Received: by mail-io1-f68.google.com with SMTP id t7-v6so14124274ioj.13 for ; Sun, 07 Oct 2018 09:38:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hCTx7qfcTYDXdZAMSmM8FAvvxp6pSfKrJpvo75jS43k=; b=RjQ31TxMFbpa6te2hTzbaxpYMy2h3mVdigN6UojrJjEtGYBFUSvi5XYEV9RVYIKMbL x5gsF20y1XHTgz8FYURCZxqy7y74v7J4j5FM65830C5CYKGvwGoeoV/d4e3cqEdmyS0C dLr9EU/z10LeQVhJNmDtnKPjp0TcKaNYEO8ba7wKPBzPuu63yDeB8N0Oh22V7gbE2Odo 4ITZOIKafsoHu7xUH0m4LYymkgcZlCOgxbi6Al6XDSScYaFED4vqWO5lBlTH6H0YTAAd Vla1bihe4ZKc40u/AUpsxMywL/+zGcFc0DrstpxIduZ9bH7bg6yNQeU7EybEdGgy6Rin FFIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hCTx7qfcTYDXdZAMSmM8FAvvxp6pSfKrJpvo75jS43k=; b=Pg24cbpI0qlkgHcV8gMgJslirhivDqYkwi/+9/Y1Lt44GkqkGmBy1O/S57HyKPXn+e a+QISwqHs4ldedE/n1Qh7SvBV+e19EtQwIuGAmGW66ng1jlLWfypC+qm8pg40ZCAY57a 3/yqpAmUUvVnK/sgStUP04y0kmIlEXDLLL4eRXOfVDdUOwz+UQ8sRXV1/XeuUn6Uja01 ZSN1/PnArRMDj0xvnPe88Fm2XNSntHn0jeF4sNr4CXL4EmpkBbFQZPLIiRCwj0QCICjK fWYGe9IQB6GnY4HsuznXWIRPvCzGpV4lG+W6Od8heEJUMuQIli9i7TKFnrs8MlbhLRlo neRQ== X-Gm-Message-State: ABuFfoiMuTymsXYqZst9oo4rZxbDW8LVWnHmBpYCt6p/mUg2gw3ckawS A+V+lRw3J4OfyPmkv1lnRf3WrQ== X-Google-Smtp-Source: ACcGV63lr61BoamYhSuJtkHJ9AD9HsnnHoeN839efqbOdqmK8SA2J2p0mU4zYNESCLfCm1mgH1jt8g== X-Received: by 2002:a6b:8cd1:: with SMTP id o200-v6mr13265179iod.186.1538930317104; Sun, 07 Oct 2018 09:38:37 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id z11-v6sm6674737itz.26.2018.10.07.09.38.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 07 Oct 2018 09:38:36 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: jiri@resnulli.us, xiyou.wangcong@gmail.com, viro@zeniv.linux.org.uk, netdev@vger.kernel.org, Jamal Hadi Salim Subject: [PATCH net-next 10/11] net: sched: cls_u32: keep track of knodes count in tc_u_common Date: Sun, 7 Oct 2018 12:38:10 -0400 Message-Id: <20181007163811.18453-11-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181007163811.18453-1-jhs@emojatatu.com> References: <20181007163811.18453-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro allows to simplify u32_delete() considerably Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- 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 3d4c360f9b0c..61593bee08db 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, @@ -452,6 +453,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); @@ -462,6 +464,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); @@ -576,6 +579,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; @@ -583,6 +587,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); @@ -1141,6 +1146,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; }