From patchwork Mon Oct 8 10:22:33 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: 980470 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="sXSJ1laO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGf42L2hz9sD2 for ; Mon, 8 Oct 2018 21:23:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727033AbeJHReG (ORCPT ); Mon, 8 Oct 2018 13:34:06 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:54317 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbeJHReG (ORCPT ); Mon, 8 Oct 2018 13:34:06 -0400 Received: by mail-it1-f196.google.com with SMTP id l191-v6so10730526ita.4 for ; Mon, 08 Oct 2018 03:23:05 -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=7qNouc+NvqZLQK0lqvati4npgI6xJY/kQ4dDO+7lAwA=; b=sXSJ1laO+7ZhKFzkix3uq6nhAq4mkEbuxG8+7B2Wcx+GDgaCEMU//uLyC2f1dO9JMB N/o6outaBxXGCxNJNUK74nLwBKseetrMk9LX1K/0TEcW7LDrOoEr+Hv2EmZ7JZ2LQd07 pVmXKzSTCQ6lxDrJ75SpgXvGMBlydu0PHRK6jnHob7x8fw784kT1Q5UP//rqkS0HjjQ1 9rZMLfeog5kT9E2rc9g3qqYvypLWl8NWBkOA1sbQlkhYzR0nSviXN8bF7iC3QL5dHpR2 g0fGPl+JLmpOTyPfK3hyjyALmkDY05nIO3MUPmVEkMSpP5O+dPxXvyUmikF15iLJxcrW k7Pw== 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=7qNouc+NvqZLQK0lqvati4npgI6xJY/kQ4dDO+7lAwA=; b=tBEX2NcgrLRXoHcBcKx45sOO3h+mdgp81TrxZGosYl7mdtOhZQMrPi/PPjoaHHKAHV fcU15Z4T8ZkmKMzej+ljwA4nUMKk77uMVuW9hbQkdeW7AsEdqOLx6dFrDhbsfep+BlxM NtzP8j5Qh24vmQ7uzS+Ovah40LLXpOoIk1IP7MZq1FJ7/CXivOjiR1PRwwzSMekIQphv FB69rBpv9/NAAIkeyrSbZ5Brx8mQGrJWSu4qFDBU95efM/cf7k8MVEJvh4HOS8/Aq7te h+z4yUEGJew4IhPj12b+7WRQGBJDLSBU8KvfMKJJe+cmaZoQDChtuMmUtbfeISj9qqr3 d66Q== X-Gm-Message-State: ABuFfoincNTet6U6in4O12OaMbRblPdIFSxnNz9os3JzTu8Z+to7GbvT 0szzlic16SkU3fqJvX2NxvxE8+h0z+M= X-Google-Smtp-Source: ACcGV61msfNdxKPHHyw+DIX0Ad6CxAfsdJYgTELXD1xlKvTGDL7zWmnq2+0sOnzWro1e8mH+53pZPQ== X-Received: by 2002:a24:81d7:: with SMTP id q206-v6mr15068400itd.94.1538994185556; Mon, 08 Oct 2018 03:23:05 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:04 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 01/12] net: sched: cls_u32: mark root hnode explicitly Date: Mon, 8 Oct 2018 06:22:33 -0400 Message-Id: <20181008102244.22212-2-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro ... and produce consistent error on attempt to delete such. Existing check in u32_delete() is inconsistent - after tc qdisc add dev eth0 ingress tc filter add dev eth0 parent ffff: protocol ip prio 100 handle 1: u32 \ divisor 1 tc filter add dev eth0 parent ffff: protocol ip prio 200 handle 2: u32 \ divisor 1 both tc filter delete dev eth0 parent ffff: protocol ip prio 100 handle 801: u32 and tc filter delete dev eth0 parent ffff: protocol ip prio 100 handle 800: u32 will fail (at least with refcounting fixes), but the former will complain about an attempt to remove a busy table, while the latter will recognize it as root and yield "Not allowed to delete root node" instead. The problem with the existing check is that several tcf_proto instances might share the same tp->data and handle-to-hnode lookup will be the same for all of them. So comparing an hnode to be deleted with tp->root won't catch the case when one tp is used to try deleting the root of another. Solution is trivial - mark the root hnodes explicitly upon allocation and check for that. Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index f218ccf1e2d9..622f4657da94 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -84,6 +84,7 @@ struct tc_u_hnode { int refcnt; unsigned int divisor; struct idr handle_idr; + bool is_root; struct rcu_head rcu; u32 flags; /* The 'ht' field MUST be the last field in structure to allow for @@ -377,6 +378,7 @@ static int u32_init(struct tcf_proto *tp) root_ht->refcnt++; root_ht->handle = tp_c ? gen_new_htid(tp_c, root_ht) : 0x80000000; root_ht->prio = tp->prio; + root_ht->is_root = true; idr_init(&root_ht->handle_idr); if (tp_c == NULL) { @@ -692,7 +694,7 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last, goto out; } - if (root_ht == ht) { + if (ht->is_root) { NL_SET_ERR_MSG_MOD(extack, "Not allowed to delete root node"); return -EINVAL; } From patchwork Mon Oct 8 10:22:34 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: 980481 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="P2rvODFR"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfT3rvJz9s5c for ; Mon, 8 Oct 2018 21:23:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727348AbeJHReI (ORCPT ); Mon, 8 Oct 2018 13:34:08 -0400 Received: from mail-it1-f193.google.com ([209.85.166.193]:39244 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726193AbeJHReH (ORCPT ); Mon, 8 Oct 2018 13:34:07 -0400 Received: by mail-it1-f193.google.com with SMTP id w200-v6so11130650itc.4 for ; Mon, 08 Oct 2018 03:23:07 -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=iB2zr0IdkwIiH++HO4iq2fb/YhwieSxz2DBfSJYci5A=; b=P2rvODFR5bCMfZn32HoWYUanW5DyQPXeIpvxXb4aqhh/iF/IYXjIFFxX5hdFqpU5U/ WyR2OsiTnVUTg4l/JiIfoFQH1fBzMKRa4QMc6A4r6YSBDlPZ/5KXeliazEy8VSFhhZ0M MrhGN+lpiRPZ0cV8YASk+FrkwgWDvCfK8RU3qVJ6R+uW3lB7/M4C3YzknfDqw4iYZ7Wh 1dfKjmGVbEYORShZYeI065WCHpoB48H6B+QTi/rwh9ySbDSwiSMB5iNcuNpnF5bff0os jwuOhfG4BwgCwN1p+X2TAN7UQQ9dnuxkkjC1Dv22TYwYnhpnXK04AL7J4KBupCURTL0S NLjQ== 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=iB2zr0IdkwIiH++HO4iq2fb/YhwieSxz2DBfSJYci5A=; b=oOSUQRs+WF6V7f9VwZ+YZo3S+UNd4vls3JGBxKxwW+f3NHQD0taloxFVTfPYpjFmjv +D008D+BfXhVaBqPBf/EQm+TIuLeSoYdTsKV/epHXh8iSk7L4rJZYxw1skxHE6GG01kq uia5DWogQjsr7D/2NM7kJTjjoOCo7Vh5hZPI97ZMmDls0yB6e4q7t20Z0BZqRBIUUmzF RoLjVjMScu29RjUBHBgKFgDGdbn/Uh609EaHfcgTE6o+GAyY39zCb+kG/Wat/uFo5LB6 9Digwc6HaHi5fxf4o25OmUc4Z35zGv9i4uNShJL8MKlS34NWV+m5OXP//YhJBo2wG/jr 53aA== X-Gm-Message-State: ABuFfojIXGWOjAYi83HDmeuTocOtdaEhFD5OIIJFwkM9BNKa0uAANdDb 6PcT8Wo4dOleGveeZGPEh7ut8g== X-Google-Smtp-Source: ACcGV624HwCBDwhilkriT7NNFUhbGbk2kbP/qGy3DROXsSzpfSajGpMKsI8Xg7qBmOZrHwaZdEP0hg== X-Received: by 2002:a05:660c:14e:: with SMTP id r14mr5172824itk.136.1538994186643; Mon, 08 Oct 2018 03:23:06 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:06 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 02/12] net: sched: cls_u32: disallow linking to root hnode Date: Mon, 8 Oct 2018 06:22:34 -0400 Message-Id: <20181008102244.22212-3-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro Operation makes no sense. Nothing will actually break if we do so (depth limit in u32_classify() will prevent infinite loops), but according to maintainers it's best prohibited outright. NOTE: doing so guarantees that u32_destroy() will trigger the call of u32_destroy_hnode(); we might want to make that unconditional. Test: tc qdisc add dev eth0 ingress tc filter add dev eth0 parent ffff: protocol ip prio 100 u32 \ link 800: offset at 0 mask 0f00 shift 6 plus 0 eat match ip protocol 6 ff should fail with Error: cls_u32: Not linking to root node Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 622f4657da94..3357331a80a2 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -797,6 +797,10 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, NL_SET_ERR_MSG_MOD(extack, "Link hash table not found"); return -EINVAL; } + if (ht_down->is_root) { + NL_SET_ERR_MSG_MOD(extack, "Not linking to root node"); + return -EINVAL; + } ht_down->refcnt++; } From patchwork Mon Oct 8 10:22:35 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: 980471 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="fnw0EiHO"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGf63H6cz9s5c for ; Mon, 8 Oct 2018 21:23:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbeJHReJ (ORCPT ); Mon, 8 Oct 2018 13:34:09 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:37503 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727065AbeJHReI (ORCPT ); Mon, 8 Oct 2018 13:34:08 -0400 Received: by mail-it1-f194.google.com with SMTP id e74-v6so11145188ita.2 for ; Mon, 08 Oct 2018 03:23:08 -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=n0nq5/PSNZg84w4nKazg4x2UG3zNSNx8ylZm1Ln+BxQ=; b=fnw0EiHOrSGJQ1ep/14iCW0cKiua84p1K243otYYs1gJjPW2AHmAVxEm8PQ//IxB8n LXrH49O+Bpi2bTN8ngh4q2j42l9PmoBJBPRMyz9owC7Z1aoLw22Gd7DRhzM1iNbLKcwN hjHO8P49mz95k17P0J4MPeXTVzU13uWAVCKoiX/oJTRJGu4yenLoPxLDQeJEXnrSDw5Y 3172E1qKNGaM3XMLBAABtKTfXspzg+GoL3/IRXYOwRJYUabcIer8XO+gdyq0hOfrEtxZ EZHVfeTNuUWJdSpjrPFtNXM+AZqoWZ1VAcZJLqvzCKvMD2r2ra8DVfSJ52ppbTkDWT87 Htfw== 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=n0nq5/PSNZg84w4nKazg4x2UG3zNSNx8ylZm1Ln+BxQ=; b=p0c+6eqdzNOCXZv3e6vpVyzYmWWdXKnTFCIEsbjy0jX0qAiATlvGRs8v7IuNC2qVHI lyNbv1OVtvy5j3XSFGUkcGapnUneAP7pcx3Ob3Q5vgiWib78Y6gW/Ila0UO4O8NJ0/lm f+SN7Ew5pvavNyuqNqw41m/cMKM9wutXEtMPu27SyUrMj/TgEVY9wTDiUd04GsHT8uNR Zu8LNH9r+OtJXo/2d3YeL8EHQYfjQSWisL0XayCSRXIpNHoswbrByKQcZjRwlFcZU/aX Rsyy7rotJz7zG8mF9jmz8ZGh6SMvcOSo2+DezjjHB/f0aIDGNdaDDsIapuD0WULA0Wr8 TwPQ== X-Gm-Message-State: ABuFfoj2Gk3ScyAGItYi0lmaCSxIgiqVmspyjnx/bd/6PKeJzpUuB01e VWGSJbJwn3Mx70JRPP9yqWnioQ== X-Google-Smtp-Source: ACcGV61LUTB4dnGSuICxzydQNSiM4inOIhR1dZ9sJH67moYoo3MmB1+wuQDZrfozhU87E0+NnE5Tjw== X-Received: by 2002:a24:45cf:: with SMTP id c76-v6mr16611676itd.112.1538994187753; Mon, 08 Oct 2018 03:23:07 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:07 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 03/12] net: sched: cls_u32: make sure that divisor is a power of 2 Date: Mon, 8 Oct 2018 06:22:35 -0400 Message-Id: <20181008102244.22212-4-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro Tested by modifying iproute2 to allow sending a divisor > 255 Tested-by: Jamal Hadi Salim Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 3357331a80a2..ce55eea448a0 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -994,7 +994,11 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, if (tb[TCA_U32_DIVISOR]) { unsigned int divisor = nla_get_u32(tb[TCA_U32_DIVISOR]); - if (--divisor > 0x100) { + if (!is_power_of_2(divisor)) { + NL_SET_ERR_MSG_MOD(extack, "Divisor is not a power of 2"); + return -EINVAL; + } + if (divisor-- > 0x100) { NL_SET_ERR_MSG_MOD(extack, "Exceeded maximum 256 hash buckets"); return -EINVAL; } From patchwork Mon Oct 8 10:22:36 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: 980472 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="rgfhvaah"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGf72vx1z9sD2 for ; Mon, 8 Oct 2018 21:23:11 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727579AbeJHReJ (ORCPT ); Mon, 8 Oct 2018 13:34:09 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:38046 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727427AbeJHReJ (ORCPT ); Mon, 8 Oct 2018 13:34:09 -0400 Received: by mail-it1-f196.google.com with SMTP id i76-v6so11129694ita.3 for ; Mon, 08 Oct 2018 03:23:09 -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=8UC1Kgf9qA/QOHP7F6iVDMxE1J1nvyAyhv2ZoIq0ZUg=; b=rgfhvaahlZy4nIfRWW6gpe9wVexnLVEA058Va02Z4JZqVJrywNikgDbOjrHsNsSSES u/cMMhJNaoEb7JrCkuFywIc8vLj1uGCPcHa7IOh5/b2IOLoF1n1xFEcm9AOoKckq2pcj z+lWyxhu2KlCDJgQCqfqRWTX+tfYOY5/JtgFYp9gt74EDVMpAHMmHABkb5U2D8F+pnj6 kUZt7r7Gi3gcj5+CJbxPjE3o3r+q6CahASbFWRIv264xe0oDxRTKtQMEQwnZ+gixa/QB RMUdJpP19pgB5QPg0Aicgl77+Sn/vSC79mOU7eOmGz/W/XD1vboqrSmMAlLGSsNlPMMM ATQg== 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=8UC1Kgf9qA/QOHP7F6iVDMxE1J1nvyAyhv2ZoIq0ZUg=; b=hTE73/CvsRg7bzp/a6AYIrJdpc5KKdvpL86IDO/w5i0UBxFZC/9yXYf185BLQPNxvy A2anrIjjTksU13V62+IQQIOSniSxmlh74wUKkhi1kQD++U5uGtisl4P+3tinfNdO3ek6 kLPDasfMreUY/C/3Gize9usXmbF2PUt8gyFYLU89iyoh+8s4nFqN93R7rjtpwr20rO5q IrzGI+QVbyy+WzV1TmJ4USHWClYrMAkYIL5/srCAFEe6uwzZPGmnRq+kqTvEl9RLNbbY Th9hjwK6ucgxCRsB81kvb7KThtNKleL6QTTZf4zK4oEzBgwD8tw049nYbP/QyEwfY5Ix lFXQ== X-Gm-Message-State: ABuFfoi6IjNAcYhv3hKCcazoEbOzMPkbOhN2s7yYDvHbVsgj1+Ntidk6 Cdce32i1Y2qtW2DG4DBFq33FA9VgdD4= X-Google-Smtp-Source: ACcGV62ZAFkign3FWlr1tcXOso/gn5L4eoeLuAFxyc7tD15n7PpQ1m27WQje2nlQpSm6PQ4bT4GnpA== X-Received: by 2002:a24:68f:: with SMTP id 137-v6mr11926179itv.54.1538994188861; Mon, 08 Oct 2018 03:23:08 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:08 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 04/12] net: sched: cls_u32: get rid of unused argument of u32_destroy_key() Date: Mon, 8 Oct 2018 06:22:36 -0400 Message-Id: <20181008102244.22212-5-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index ce55eea448a0..ef0f2e6ec422 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -405,8 +405,7 @@ static int u32_init(struct tcf_proto *tp) return 0; } -static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n, - bool free_pf) +static int u32_destroy_key(struct tc_u_knode *n, bool free_pf) { struct tc_u_hnode *ht = rtnl_dereference(n->ht_down); @@ -440,7 +439,7 @@ static void u32_delete_key_work(struct work_struct *work) struct tc_u_knode, rwork); rtnl_lock(); - u32_destroy_key(key->tp, key, false); + u32_destroy_key(key, false); rtnl_unlock(); } @@ -457,7 +456,7 @@ static void u32_delete_key_freepf_work(struct work_struct *work) struct tc_u_knode, rwork); rtnl_lock(); - u32_destroy_key(key->tp, key, true); + u32_destroy_key(key, true); rtnl_unlock(); } @@ -600,7 +599,7 @@ static void u32_clear_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht, if (tcf_exts_get_net(&n->exts)) tcf_queue_work(&n->rwork, u32_delete_key_freepf_work); else - u32_destroy_key(n->tp, n, true); + u32_destroy_key(n, true); } } } @@ -971,13 +970,13 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, tca[TCA_RATE], ovr, extack); if (err) { - u32_destroy_key(tp, new, false); + u32_destroy_key(new, false); return err; } err = u32_replace_hw_knode(tp, new, flags, extack); if (err) { - u32_destroy_key(tp, new, false); + u32_destroy_key(new, false); return err; } From patchwork Mon Oct 8 10:22:37 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: 980473 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="dHARnFel"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGf937Jxz9s5c for ; Mon, 8 Oct 2018 21:23:13 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727622AbeJHReL (ORCPT ); Mon, 8 Oct 2018 13:34:11 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:54323 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727427AbeJHReK (ORCPT ); Mon, 8 Oct 2018 13:34:10 -0400 Received: by mail-it1-f194.google.com with SMTP id l191-v6so10730709ita.4 for ; Mon, 08 Oct 2018 03:23:10 -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=b141/TWzSPUgXiso5juftiBMP5RkNKDpt6MolITsKpI=; b=dHARnFeljMxt+AKhQgrNXg+sa/63JcjAPkK9tMK4XzZKbyN+h8CGNSgNjiE/m8IrT/ r34OjBRfBVYC1zBHKS+FnO+I7BXiaznGmSapYcDjk9OT44ppHUA3Md+Zi8HK6mVNXPJ6 9k4l7EK8Nq72dpKQsYcuhX+1Gr4Hn7kXIvkY5uTmdSowIFlyUhszr/dnkLIgcMvlstdU cW1ImlQshS2NCzZ0+7wBjIWC4UyXihKAFxtlUig5oOu6UoU6eKELIhMtPOgFmDnHmdti Y80F4Pvircg3QdJETGV7fUtEQwbSDe2ugp/V22BfAFrBgSRBD0qFmssL69EOo00w29Fq hb3Q== 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=b141/TWzSPUgXiso5juftiBMP5RkNKDpt6MolITsKpI=; b=Fvuhy659Bdh1+JWvd+lEUIiWQ1KghBmPmotuZ89pNQIdnADCTp7DFnnZ39IiTrdANa LoNl20Tk/cO9YBZlD+/3cRulcf+EZTQtEVjJhSfyxH1LC8Ah8uc1gL+CuFgFFhZNA4v8 XMMxwlEq/ilSbSytsD2QxN/xulr4seGqnDo+Dl8YkoZbIUesE2YVLrWFupOZaFO9nJOU M2zv8IIFCAVKGXya4qBcJacEtw6wRNbkmDhow7UJdY/YZAsmHtxqd4OC/ICkJRjYdwKw AawjnYTtCQ1sotNYVi7+DhYODzgAiy1Frkw4bA2y87N4yHLMXsLd3cthshp55BWYRj9q 44hQ== X-Gm-Message-State: ABuFfoiB/JaeEPYiZIx8RGe2zsXXXMVmVhkvo2mfsYbZ8TAYePXvem/L lVADcXYQX/i938mGDWyZD5mhMQ== X-Google-Smtp-Source: ACcGV62iPP8Jr9/ePnEVuSGyMAwsPlKQq7xVwjgwGoS4smYNbiesmcXarFhdAi3CmcucYfCJZSIRTQ== X-Received: by 2002:a24:da04:: with SMTP id z4-v6mr16478528itg.101.1538994190123; Mon, 08 Oct 2018 03:23:10 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:09 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 05/12] net: sched: cls_u32: get rid of tc_u_knode ->tp Date: Mon, 8 Oct 2018 06:22:37 -0400 Message-Id: <20181008102244.22212-6-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro not used anymore Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index ef0f2e6ec422..810c49ac1bbe 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -68,7 +68,6 @@ struct tc_u_knode { u32 mask; u32 __percpu *pcpu_success; #endif - struct tcf_proto *tp; struct rcu_work rwork; /* The 'sel' field MUST be the last field in structure to allow for * tc_u32_keys allocated at end of structure. @@ -896,7 +895,6 @@ static struct tc_u_knode *u32_init_knode(struct tcf_proto *tp, /* Similarly success statistics must be moved as pointers */ new->pcpu_success = n->pcpu_success; #endif - new->tp = tp; memcpy(&new->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key)); if (tcf_exts_init(&new->exts, TCA_U32_ACT, TCA_U32_POLICE)) { @@ -1112,7 +1110,6 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, n->handle = handle; n->fshift = s->hmask ? ffs(ntohl(s->hmask)) - 1 : 0; n->flags = flags; - n->tp = tp; err = tcf_exts_init(&n->exts, TCA_U32_ACT, TCA_U32_POLICE); if (err < 0) From patchwork Mon Oct 8 10:22:38 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: 980474 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="ejYw8DYm"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfB2C2lz9sD2 for ; Mon, 8 Oct 2018 21:23:14 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727635AbeJHReM (ORCPT ); Mon, 8 Oct 2018 13:34:12 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:38049 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbeJHReM (ORCPT ); Mon, 8 Oct 2018 13:34:12 -0400 Received: by mail-it1-f194.google.com with SMTP id i76-v6so11129855ita.3 for ; Mon, 08 Oct 2018 03:23:11 -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=YUnKaHLlp2x4faSACqdE6Fso3Yk2+08hvStA05uy8C8=; b=ejYw8DYmaxN0Q8BNiP/Y7s/gqRHPYFcwOHQUQh0dPUF9YqmV28Dw6zIXm+V8K8W6hM LUJyfgd4hg7xXCqRvukSGUNtg2wWr4NO/LDstRGuYSOcov34jH1evSya11m/Jdg37F2V bMIhgxbJ1WfPyO1Bn+89TMrqQwcn3BJrS+DlHTTIlBQrkJZgrq2IKHfxTLW+jRrENxe9 sJKtQ9yJwxP1MzjMzCpTBFjBX96dgB/jUNIzHg0Qu2Fp4NIG6Zb3sSrv8yDqYfTV4qBo 4t90djber9YfA9Yl7p3fDze0Tv4eVFT85bXadF6l50KweZLbWM586IqUgMszCrHlKHwU 9Axg== 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=YUnKaHLlp2x4faSACqdE6Fso3Yk2+08hvStA05uy8C8=; b=RotlUTLptyQNBANpLvb0CyLSJEqBGAWiBNRmtMK6cey1fFCQsbtbeh3+t36Q5TcmMf CFyiCzMZlfhg02qRRKsDNFv3G5BAEnxv6bMyRdSs6/jRbbYaqOSXN+YcrtBsuNGjFpm0 RJ8Y3vnhT0c4qNRurVZmJ8wZ3lMonoSUk5Imd5iwvdwiWu6Tm+kYEargyJ80CYbmWHKL 4Gkm+tTJgj2xUzA0vkhWHK2qCSn+hUbqgg2ql866avfYeYC+597jPxRQpwxt7qd7F/yC eSu2NdSu0s1+iaA2BLDTsFLjoUzqs/YMV9f7RS7MpRrwhyjP5utNMi8iTM8FoRv83eIG rZvg== X-Gm-Message-State: ABuFfoh1XAtEjh+m548RYqSTkpGOkCIUH9PLMsWrK0nQESE714k52lXL QQD1Nn1f7hBJYuhUTTyHGZN4H0iEX8w= X-Google-Smtp-Source: ACcGV62+OVXNgvYijjP/ngs19CV898l86eTCcf7Z0wput5XKm9NPLDFattVPNeZCKlxwSJ4AoHXv9Q== X-Received: by 2002:a24:4cc2:: with SMTP id a185-v6mr16086108itb.81.1538994191312; Mon, 08 Oct 2018 03:23:11 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:10 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 06/12] net: sched: cls_u32: get rid of tc_u_common ->rcu Date: Mon, 8 Oct 2018 06:22:38 -0400 Message-Id: <20181008102244.22212-7-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro unused Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 1 - 1 file changed, 1 deletion(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 810c49ac1bbe..c378168f4562 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -98,7 +98,6 @@ struct tc_u_common { int refcnt; struct idr handle_idr; struct hlist_node hnode; - struct rcu_head rcu; }; static inline unsigned int u32_hash_fold(__be32 key, From patchwork Mon Oct 8 10:22:39 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: 980475 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="KrewUSWx"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfC4LZyz9s5c for ; Mon, 8 Oct 2018 21:23:15 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727654AbeJHReO (ORCPT ); Mon, 8 Oct 2018 13:34:14 -0400 Received: from mail-it1-f180.google.com ([209.85.166.180]:37199 "EHLO mail-it1-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbeJHReN (ORCPT ); Mon, 8 Oct 2018 13:34:13 -0400 Received: by mail-it1-f180.google.com with SMTP id e74-v6so11145465ita.2 for ; Mon, 08 Oct 2018 03:23:12 -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=7yEb69amIJq5DjprWqU04TpFMQDeRUOQFvIrBp+DW7A=; b=KrewUSWxUrlpNgdxfY7Z/Gc7G8QRoZjECNrhVXeEoZynI6QCjaK3I/VErmG2Vmhmtg Ij+XUVEdhp8txDe9vO1MIVMwdQQmh39GKuDggNQgW+dRxzvA9ET4DZL/evylbr2TOyNW 1XZZ9S0BhgIPtquNTrqa/rumXnWv3HkgFRRBmrb7Gc8jSaantsyL80OnhkHAhXogM1bI wrGJcOLNGtHWLU5E4NVNlMS1fa+JRHFlYluYg6FuyNDdBgeWO19wzb3huP/J44sv/SCh QA0HoyvTNpyT9AKJqDKWqL3wKj3p4enIt13Dgr5NGwarRm8fKxX1btOzyno4j7dweqcN +xsg== 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=7yEb69amIJq5DjprWqU04TpFMQDeRUOQFvIrBp+DW7A=; b=A7KM5IaD05yha9HAL59sM0K6CuTaRWHDvOLW1TD+OTA4bJhNRkHJVRsdHrSiYMtn2o mtxDhefBoBneZUqMBF66+NWS2pYeAK51ULzmjnKCAYIGeogVDiNKhgQpu32Pf5+rskDl sn7FBLjhCW0oGHoo1CLIFAgadSOD1mmsOEQ2hq7TinJbxx01bvbfFVgAgKzAezZpU9hX sdRCfabMlsqKYXmhKPCdkgEw2EaCG0IH6wGrUF6MANpUb6D29oyF4s6KQ3Gl3lkELGV7 oxQEiRJdk+gob0zCbEXYq/21YDlnLTwbCWPnW5M3l1NP99BUut7XgePq24nzW4GSupV5 EnSw== X-Gm-Message-State: ABuFfois7v3fdoNgNp5nxqx+H+qKWGdhbXfHKL0eJg5t/zwi1atN3FI3 zaKZ5p0DMbHKMrSnyDrfL9W0oLdnMnE= X-Google-Smtp-Source: ACcGV63/2echJOu66ck9D3yHtS36G1846ZDa0AyLAdoYvMBLlAeyQTwwSmVLRxlcqBUcRmo1XZvThQ== X-Received: by 2002:a24:118f:: with SMTP id 137-v6mr15900991itf.30.1538994192450; Mon, 08 Oct 2018 03:23:12 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:11 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 07/12] net: sched: cls_u32: clean tc_u_common hashtable Date: Mon, 8 Oct 2018 06:22:39 -0400 Message-Id: <20181008102244.22212-8-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro * calculate key *once*, not for each hash chain element * let tc_u_hash() return the pointer to chain head rather than index - callers are cleaner that way. Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index c378168f4562..3f6fba831c57 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -343,19 +343,16 @@ static void *tc_u_common_ptr(const struct tcf_proto *tp) return block->q; } -static unsigned int tc_u_hash(const struct tcf_proto *tp) +static struct hlist_head *tc_u_hash(void *key) { - return hash_ptr(tc_u_common_ptr(tp), U32_HASH_SHIFT); + return tc_u_common_hash + hash_ptr(key, U32_HASH_SHIFT); } -static struct tc_u_common *tc_u_common_find(const struct tcf_proto *tp) +static struct tc_u_common *tc_u_common_find(void *key) { struct tc_u_common *tc; - unsigned int h; - - h = tc_u_hash(tp); - hlist_for_each_entry(tc, &tc_u_common_hash[h], hnode) { - if (tc->ptr == tc_u_common_ptr(tp)) + hlist_for_each_entry(tc, tc_u_hash(key), hnode) { + if (tc->ptr == key) return tc; } return NULL; @@ -364,10 +361,8 @@ static struct tc_u_common *tc_u_common_find(const struct tcf_proto *tp) static int u32_init(struct tcf_proto *tp) { struct tc_u_hnode *root_ht; - struct tc_u_common *tp_c; - unsigned int h; - - tp_c = tc_u_common_find(tp); + void *key = tc_u_common_ptr(tp); + struct tc_u_common *tp_c = tc_u_common_find(key); root_ht = kzalloc(sizeof(*root_ht), GFP_KERNEL); if (root_ht == NULL) @@ -385,12 +380,11 @@ static int u32_init(struct tcf_proto *tp) kfree(root_ht); return -ENOBUFS; } - tp_c->ptr = tc_u_common_ptr(tp); + tp_c->ptr = key; INIT_HLIST_NODE(&tp_c->hnode); idr_init(&tp_c->handle_idr); - h = tc_u_hash(tp); - hlist_add_head(&tp_c->hnode, &tc_u_common_hash[h]); + hlist_add_head(&tp_c->hnode, tc_u_hash(key)); } tp_c->refcnt++; From patchwork Mon Oct 8 10:22:40 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: 980476 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="nRCKJ7TC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfF3BMBz9s5c for ; Mon, 8 Oct 2018 21:23:17 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727669AbeJHReP (ORCPT ); Mon, 8 Oct 2018 13:34:15 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:37518 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727640AbeJHReO (ORCPT ); Mon, 8 Oct 2018 13:34:14 -0400 Received: by mail-it1-f194.google.com with SMTP id e74-v6so11145528ita.2 for ; Mon, 08 Oct 2018 03:23:13 -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=Pi29VMGpgeE8gmlXuqK4hX/rrL/d+DYeIU9YqHffwAI=; b=nRCKJ7TChjKbNqem3RjPajoKC/ioTLpZhAw1ahhAaLy4DhHZ12sZ+KbuBPYJ9JICm5 YlvpMgBU1TPbIYa5PThL14GBHYPG7YHrjkIk4JeL//sb612RsnvaBffC6Y5wfaQVPLIr k2/P541Ox+BZQmM5TB2E5+L7ThyD0V4upu6CRawu17trbZKv4q8lQogfNQWq9r0sAHTe RlEFy7qJ61b+BEjs6qTDVMV9BWQoVpcoJoJxw6NML/S/IB6RyXP5tHULuy6gdWKf4ck+ tsx26xzkwXQo4iu4yue5KNgzwkNmvCGbg8gB7uZXkavvSEpqHZz39N+nlBW+fyXqIoNh gAJg== 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=Pi29VMGpgeE8gmlXuqK4hX/rrL/d+DYeIU9YqHffwAI=; b=TPvSZId2VQSY6tP453T1S0QkU2TkHvP1fXlgbEqpxS1B3V+WQGoK2njgQxmZEm8zt7 WD3+oi+dVJTFFAGtzhTcG4lzuL68uNGcuYIh2iXZ39iVpaFujoMUPLJC1uWl+SPE9Jn9 pCGnBw3JCLt/aItnKIQDlCwdPozeBBwaO7+AgsI7WD+sUXl4HGXmWvMpgeOkImllz8Ya 70HtcpJ4BWZB3P04pvgFU7zVlAl1BWDVR+vjfRi3X3Wv3Osz/iIVZOMnGWC26upypyWt fBrTKFoVzyw57nAYSzT4mn3vrXLzrpRhYQiD4sySLY5UfvRqw/UagtRa+syKTIUOTGOx mxuw== X-Gm-Message-State: ABuFfog0H3OH/sHwvspiT2MNeM/WF3u0fIGv/K630r2vYZKMJpIEbu1J nnMLhD1WTvoxFcj90eACjKqLag== X-Google-Smtp-Source: ACcGV60IwD+MZ33hoyXdAm/zZUUnWyZhm1GTHdKiFICwNrHWy4MHm6JY1UsEpDIyNAdkUL9xRlcd8A== X-Received: by 2002:a24:d0d3:: with SMTP id m202-v6mr16769953itg.104.1538994193598; Mon, 08 Oct 2018 03:23:13 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:12 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 08/12] net: sched: cls_u32: pass tc_u_common to u32_set_parms() instead of tc_u_hnode Date: Mon, 8 Oct 2018 06:22:40 -0400 Message-Id: <20181008102244.22212-9-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro the only thing we used ht for was ht->tp_c and callers can get that without going through ->tp_c at all; start with lifting that into the callers, next commits will massage those, eventually removing ->tp_c altogether. Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 3f6fba831c57..53f34f8cde8b 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -761,7 +761,7 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { }; static int u32_set_parms(struct net *net, struct tcf_proto *tp, - unsigned long base, struct tc_u_hnode *ht, + unsigned long base, struct tc_u_common *tp_c, struct tc_u_knode *n, struct nlattr **tb, struct nlattr *est, bool ovr, struct netlink_ext_ack *extack) @@ -782,7 +782,7 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, } if (handle) { - ht_down = u32_lookup_ht(ht->tp_c, handle); + ht_down = u32_lookup_ht(tp_c, handle); if (!ht_down) { NL_SET_ERR_MSG_MOD(extack, "Link hash table not found"); @@ -957,7 +957,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return -ENOMEM; err = u32_set_parms(net, tp, base, - rtnl_dereference(n->ht_up), new, tb, + rtnl_dereference(n->ht_up)->tp_c, new, tb, tca[TCA_RATE], ovr, extack); if (err) { @@ -1124,7 +1124,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif - err = u32_set_parms(net, tp, base, ht, n, tb, tca[TCA_RATE], ovr, + err = u32_set_parms(net, tp, base, ht->tp_c, n, tb, tca[TCA_RATE], ovr, extack); if (err == 0) { struct tc_u_knode __rcu **ins; From patchwork Mon Oct 8 10:22:41 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: 980477 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="CTbw1i/i"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfG21Rvz9sD2 for ; Mon, 8 Oct 2018 21:23:18 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727703AbeJHReQ (ORCPT ); Mon, 8 Oct 2018 13:34:16 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:40441 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbeJHReP (ORCPT ); Mon, 8 Oct 2018 13:34:15 -0400 Received: by mail-it1-f194.google.com with SMTP id i191-v6so11122017iti.5 for ; Mon, 08 Oct 2018 03:23:15 -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=RZBqrUosu/Uue1HYEwhT5UCJ3WwUyT7bPHFwo9m1qzM=; b=CTbw1i/inDXToL6Em3n4/QUGLe0rSZqwcDSXj42Ux2UXGLdr8c5r/Cszg5416c8Dn4 8jP/uJRfYpBoaCzqngovsY80qFWU0ZUWRCkgyAMgoYjfClbTFEwf28wwrpOdllOQuZyu iR2HN/zse6g3ttc9jJRdnn7M5CK9c/l7tGPCsSSztNcaI6B+zdcVBYmnfng9blVWczP8 T8K+O8BJRk3MCYgK61GFWB4OK+ROTh8MFlTCkVkNbaR5Zswc46gmxNgxMgzepI7Fer91 e4dXJt+2NxHJBBxeEqblnC6MMKmBf6u8PsGPLRW7POyITqwZ9k6VODlSnF64inD4XOdl d/4A== 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=RZBqrUosu/Uue1HYEwhT5UCJ3WwUyT7bPHFwo9m1qzM=; b=UIBfueFAm5H+z+7DVNJVJJR/LtUSjX03VowO/CnakjSzmicR+pKDACZvbKkpioEYeU SP/GNljEcwRbkEZr/Lv/KLTIxJougD2XG0SdfNvJLptFrvU5SQDAqDxGyB0bCOtN8AaR HDowvfU3OHHDrC2uEuhKVaqcIsca61MNBJ/+Gv98Y+Eo/e/icKliLNjZ6FiNbrr97yO5 DI5wDgZgA0EtaA87viVLallOpIC1jEnQHSfI9Vpl/Qe/LQMwnDGlYmplDzO2ygr5r15k 8FV4+2Z7ItpsxH8AfJtE2nqMc4OhRd8tZQ8IWuVDkoVQSou4nWI5w7SP7UaK++O35laf tQSw== X-Gm-Message-State: ABuFfoh4S8/1XeJcLlRM16Njnba4CC66v7m7i14KfCvNyjg/zp24L/AQ 79TVbOoxyVGuunB6/69NEitnyw== X-Google-Smtp-Source: ACcGV63nGAyaOXjUZeKzHDur229zIV82LMGTUZd4YUadGtw7OVVatsC/4MdtjF13LRNMBomQ9JP5Kw== X-Received: by 2002:a24:7ad1:: with SMTP id a200-v6mr15660928itc.55.1538994194716; Mon, 08 Oct 2018 03:23:14 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:14 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 09/12] net: sched: cls_u32: the tp_c argument of u32_set_parms() is always tp->data Date: Mon, 8 Oct 2018 06:22:41 -0400 Message-Id: <20181008102244.22212-10-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro It must be tc_u_common associated with that tp (i.e. tp->data). Proof: * both ->ht_up and ->tp_c are assign-once * ->tp_c of anything inserted into tp_c->hlist is tp_c * hnodes never get reinserted into the lists or moved between those, so anything found by u32_lookup_ht(tp->data, ...) will have ->tp_c equal to tp->data. * tp->root->tp_c == tp->data. * ->ht_up of anything inserted into hnode->ht[...] is equal to hnode. * knodes never get reinserted into hash chains or moved between those, so anything returned by u32_lookup_key(ht, ...) will have ->ht_up equal to ht. * any knode returned by u32_get(tp, ...) will have ->ht_up->tp_c point to tp->data Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 53f34f8cde8b..3ed2c9866b36 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -956,8 +956,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, if (!new) return -ENOMEM; - err = u32_set_parms(net, tp, base, - rtnl_dereference(n->ht_up)->tp_c, new, tb, + err = u32_set_parms(net, tp, base, tp_c, new, tb, tca[TCA_RATE], ovr, extack); if (err) { @@ -1124,7 +1123,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif - err = u32_set_parms(net, tp, base, ht->tp_c, n, tb, tca[TCA_RATE], ovr, + err = u32_set_parms(net, tp, base, tp_c, n, tb, tca[TCA_RATE], ovr, extack); if (err == 0) { struct tc_u_knode __rcu **ins; From patchwork Mon Oct 8 10:22:42 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: 980478 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="fWcr8Hx3"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfH4lGrz9s5c for ; Mon, 8 Oct 2018 21:23:19 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727727AbeJHReR (ORCPT ); Mon, 8 Oct 2018 13:34:17 -0400 Received: from mail-it1-f196.google.com ([209.85.166.196]:37522 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727640AbeJHReQ (ORCPT ); Mon, 8 Oct 2018 13:34:16 -0400 Received: by mail-it1-f196.google.com with SMTP id e74-v6so11145644ita.2 for ; Mon, 08 Oct 2018 03:23:16 -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=3mkWyi2Bg3sRTooEo9NlhdDSy+QhZX5hcE/mCbPwjMY=; b=fWcr8Hx3r4jg5o7Y1HowyOwAKEsk1t0jdIZf2WlX+3POVSU8oA/whLMFIp6sBzxLaE I58YJI6T0GusPH4bXxfwBApQaYirGPv+pR5P48CuE4pwZeCUeGd4ktHPgvO/e9deJE64 JEyk1oxSEd70DUxKp69hQjfaOxe+36bctuJOJAX2AtFHgYnTHwU44vUg5NZWMOL8zTwd 3iF7ZXkQwCRACOKl9HimjFvCT9hOjr7w+gJJ7gVbi+Aiyk0F7dcSa9lKinCqacFp5TK7 tVZaW4aQCMXKPk292YEtbiN4auGjxUyMPaqzU6BYI9WQ8Os0NS5nmUToDg+aL+jJLvI2 ZyQA== 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=3mkWyi2Bg3sRTooEo9NlhdDSy+QhZX5hcE/mCbPwjMY=; b=LFTVzV8VKqXm+7H7iCML+D2qnbwVl8r7xPHeA4CI8BmdVSXvi2qDfjGU1lR3XY9z2A igXCRyZNja8OFSD0tfTiYjVzMcJdkTwIhwiqPRKOtiJ44wlMij7NMDooPdDiZavA1EC5 8YR/JVDEC10QdiUb8Fzc47wvXGAIjA4tkqKPk+JkLSRsefEBVKvr5l9JaT5awTxudgWa XKGv1Yz96fgjwJBpSlYFxn7gzbk2blbIwHoeea8Lp7QWskuybeqQLIPTyy33qeDVmoeo juH+fRzkbzuZBbDSIpuYLpr/kVecX3aOPr6ajkjLLQKeyERmphkp8hkTALqU2J/t0VqN Jj1g== X-Gm-Message-State: ABuFfohP/QCv0DsPvR/0C5UrTwkSMQCEB5v8m8X4EJogaYwQHg47Xjv0 d9M3WFRp8KDHv3gnL/qCpC9HLQ== X-Google-Smtp-Source: ACcGV62ieyiuX21jwUxboDh5hy7A3kgKHmZi6T/JnVtT6c7hnQJx4cqCNhLEVPHOIv+bHrWpdAnQVQ== X-Received: by 2002:a24:f908:: with SMTP id l8-v6mr15616341ith.148.1538994195767; Mon, 08 Oct 2018 03:23:15 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:15 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 10/12] net: sched: cls_u32: get rid of tp_c Date: Mon, 8 Oct 2018 06:22:42 -0400 Message-Id: <20181008102244.22212-11-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro Both hnode ->tp_c and tp_c argument of u32_set_parms() the latter is redundant, the former - never read... Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 3ed2c9866b36..3d4c360f9b0c 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -79,7 +79,6 @@ struct tc_u_hnode { struct tc_u_hnode __rcu *next; u32 handle; u32 prio; - struct tc_u_common *tp_c; int refcnt; unsigned int divisor; struct idr handle_idr; @@ -390,7 +389,6 @@ static int u32_init(struct tcf_proto *tp) tp_c->refcnt++; RCU_INIT_POINTER(root_ht->next, tp_c->hlist); rcu_assign_pointer(tp_c->hlist, root_ht); - root_ht->tp_c = tp_c; rcu_assign_pointer(tp->root, root_ht); tp->data = tp_c; @@ -761,7 +759,7 @@ static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { }; static int u32_set_parms(struct net *net, struct tcf_proto *tp, - unsigned long base, struct tc_u_common *tp_c, + unsigned long base, struct tc_u_knode *n, struct nlattr **tb, struct nlattr *est, bool ovr, struct netlink_ext_ack *extack) @@ -782,7 +780,7 @@ static int u32_set_parms(struct net *net, struct tcf_proto *tp, } if (handle) { - ht_down = u32_lookup_ht(tp_c, handle); + ht_down = u32_lookup_ht(tp->data, handle); if (!ht_down) { NL_SET_ERR_MSG_MOD(extack, "Link hash table not found"); @@ -956,7 +954,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, if (!new) return -ENOMEM; - err = u32_set_parms(net, tp, base, tp_c, new, tb, + err = u32_set_parms(net, tp, base, new, tb, tca[TCA_RATE], ovr, extack); if (err) { @@ -1012,7 +1010,6 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, return err; } } - ht->tp_c = tp_c; ht->refcnt = 1; ht->divisor = divisor; ht->handle = handle; @@ -1123,7 +1120,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb, } #endif - err = u32_set_parms(net, tp, base, tp_c, n, tb, tca[TCA_RATE], ovr, + err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], ovr, extack); if (err == 0) { struct tc_u_knode __rcu **ins; From patchwork Mon Oct 8 10:22:43 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: 980479 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="m3MvOUCH"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfJ32bYz9sD2 for ; Mon, 8 Oct 2018 21:23:20 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727739AbeJHReS (ORCPT ); Mon, 8 Oct 2018 13:34:18 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:44879 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727587AbeJHReR (ORCPT ); Mon, 8 Oct 2018 13:34:17 -0400 Received: by mail-io1-f65.google.com with SMTP id x26-v6so15415840iog.11 for ; Mon, 08 Oct 2018 03:23:17 -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=m3MvOUCHVKySwFa5QnuFG0PhXiL81uTdg45VWQ2afRtKh89IYastAZZ6iid+Tsh5xr ysi2LUBD5+IATShvg6qQbxCdMwwaBSeVZLnDKYFXA099Zb0XmEur7bc01eAFA/Cq79k3 pXJjkoyoM3vrsfnjn33N5emIdATpGcOVcm+yvCaN49dYKbHGqUACNb8wYlmCQ/AmFWLh LhVyD9nvPaxCqjvw5RVWSYR1wth48q1pz1RH7Yt8N5VtnKy67HW3ozYRGuGy4Pp6n/3u RMnVme7qhP6fP664qd1+jWrg1ga3DZElNrax4UNmNtXt2pRZS3SnN2PpIlMpBKyS0hvi zaKA== 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=RCgVFVGmrl3aD9gJUKHqFufXSpqsB9DnbPPXSlcNomBkJqIQDqi5Z3JmOYgM1GGgmC HJqe8vWPiF4GG+sJyhrBAFbbPhBD00aZJ+5885WUX4qOwo58sm4Z691glhW3Fmf/PRSg Dvjd9SEz+5ET3N6N97Z2t03jqNVLH2EiPAul+8ag4u5r3iFYupEXFjffj3CCvXaVAjtp cvu5sk5WmLU4AgFO9I22+WiVLHjMINjvmqNkHRgZiFy+yp/T4bqONOFTt6OofN9MOVhe 4a8AdIMZiakkxudSWwsvH0/NAf+oErmOxy/dwizHjbH+EHEJ26TK6r+mnYtfbf2EFsix 2JJA== X-Gm-Message-State: ABuFfoh8m4OxoWumxLkui2l7stXiQpzPh7rp4GXmovKABy/NCtpBBu6V KGH2vHdYre9XyAkPmW16R7N4lA== X-Google-Smtp-Source: ACcGV604YBJVN0Jse2ovs6QNbArpmyTyn2CCc9pTec6m2XVIwxCXdMaY7X+OH61MQwFy5nVKBWzivg== X-Received: by 2002:a6b:c9d5:: with SMTP id z204-v6mr14380773iof.265.1538994196815; Mon, 08 Oct 2018 03:23:16 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:16 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 11/12] net: sched: cls_u32: keep track of knodes count in tc_u_common Date: Mon, 8 Oct 2018 06:22:43 -0400 Message-Id: <20181008102244.22212-12-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-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; } From patchwork Mon Oct 8 10:22:44 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: 980480 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="llL6k6Oc"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 42TGfK1fXYz9s5c for ; Mon, 8 Oct 2018 21:23:21 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727754AbeJHReT (ORCPT ); Mon, 8 Oct 2018 13:34:19 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:40817 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727734AbeJHReS (ORCPT ); Mon, 8 Oct 2018 13:34:18 -0400 Received: by mail-io1-f67.google.com with SMTP id w16-v6so15430230iom.7 for ; Mon, 08 Oct 2018 03:23:18 -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=tpEEUYQPh3O2OXByWkXILYy0yV9DHU+xmXj8F59w+O8=; b=llL6k6OczuiZuOmezPpCSI2SI+8qL7eiPka4KoBKxwnYoAleoORSIw/ugD9QfmltLX fLpksmSsRuXDQFDOjofwKNpYFTCiuXVNbYjmOkAFykRNex7s7wVsaw5h7EB85oNW2WH1 4LCh6ibhShaJo2bLhUL+nOKkelsN4zLWuSTc2A6RXLJ6dqveIwUqtBKLwldXYOyxQ8P4 EWcM/I1XPckSoIfLZ3TZ8zYtKyFhyqrYLAh9wmJaqwX03zvmnz5ILGgv4YXk7/2T6IRs UCInZa4G8oIsrJjUPc0I3VJxkMX0cojrw/Wt5snjttUF2Wg/3RBX1/yxjOQQJDrDpyRa PHPQ== 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=tpEEUYQPh3O2OXByWkXILYy0yV9DHU+xmXj8F59w+O8=; b=XJ2V9CpH+thvbklQ+JyE5FYKO2W92MrAUal148bQvhXTvFc4vE63YO1kELeCmKOeAu sQp/+wQBlVgbMYwzd9yO/pbVTyHn7hcwJPYDOa5pqrciNB+Jp/QAukqKeiRxuxfW13OC Zk3MDqiaEF6uz6bHp8gFMvHZzn6HSE+ewh2z+eCHpS63N84+dQE17/2hVr72vMdAbVGM 5tz48vSvtZljMtK/EfdaZ/D9038xBjU91TjTYlw0xBzWjwZe0COW2gmTMZaR68LgyEyv 0yz1e0DeYvK8+DScSXluCbCF77l3lQ1lwQmYXEy2Wy1pJorYhR2Vp887KPGxj5+7CoIk NCFg== X-Gm-Message-State: ABuFfojD5TRQ/gpjvToodro4/OoHZ55mN8SPVqtV0JxyZO4QRVu3DY4p olKIyCfB2F2F5RRmEZeycaGTww== X-Google-Smtp-Source: ACcGV61MAAVSo+AcJJu6TeE1HWSJGCbW8YfpzO1eas8EivzMcK5wS7hR3ziyz7V9pymwmJHuB+z//g== X-Received: by 2002:a6b:6e0b:: with SMTP id d11-v6mr14058423ioh.4.1538994197913; Mon, 08 Oct 2018 03:23:17 -0700 (PDT) Received: from localhost.localdomain (198-84-205-232.cpe.teksavvy.com. [198.84.205.232]) by smtp.gmail.com with ESMTPSA id q5-v6sm5184418iog.8.2018.10.08.03.23.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 08 Oct 2018 03:23:17 -0700 (PDT) From: Jamal Hadi Salim X-Google-Original-From: Jamal Hadi Salim To: davem@davemloft.net Cc: xiyou.wangcong@gmail.com, jiri@resnulli.us, netdev@vger.kernel.org, viro@zeniv.linux.org.uk, Jamal Hadi Salim Subject: [PATCH net-next v2 12/12] net: sched: cls_u32: simplify the hell out u32_delete() emptiness check Date: Mon, 8 Oct 2018 06:22:44 -0400 Message-Id: <20181008102244.22212-13-jhs@emojatatu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008102244.22212-1-jhs@emojatatu.com> References: <20181008102244.22212-1-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Al Viro Now that we have the knode count, we can instantly check if any hnodes are non-empty. And that kills the check for extra references to root hnode - those could happen only if there was a knode to carry such a link. Signed-off-by: Al Viro Signed-off-by: Jamal Hadi Salim --- net/sched/cls_u32.c | 48 +----------------------------------------------- 1 file changed, 1 insertion(+), 47 deletions(-) diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 61593bee08db..ac79a40a0392 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c @@ -627,17 +627,6 @@ static int u32_destroy_hnode(struct tcf_proto *tp, struct tc_u_hnode *ht, return -ENOENT; } -static bool ht_empty(struct tc_u_hnode *ht) -{ - unsigned int h; - - for (h = 0; h <= ht->divisor; h++) - if (rcu_access_pointer(ht->ht[h])) - return false; - - return true; -} - static void u32_destroy(struct tcf_proto *tp, struct netlink_ext_ack *extack) { struct tc_u_common *tp_c = tp->data; @@ -675,13 +664,9 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last, struct netlink_ext_ack *extack) { struct tc_u_hnode *ht = arg; - struct tc_u_hnode *root_ht = rtnl_dereference(tp->root); struct tc_u_common *tp_c = tp->data; int ret = 0; - if (ht == NULL) - goto out; - if (TC_U32_KEY(ht->handle)) { u32_remove_hw_knode(tp, (struct tc_u_knode *)ht, extack); ret = u32_delete_key(tp, (struct tc_u_knode *)ht); @@ -702,38 +687,7 @@ static int u32_delete(struct tcf_proto *tp, void *arg, bool *last, } out: - *last = true; - if (root_ht) { - if (root_ht->refcnt > 1) { - *last = false; - goto ret; - } - if (root_ht->refcnt == 1) { - if (!ht_empty(root_ht)) { - *last = false; - goto ret; - } - } - } - - if (tp_c->refcnt > 1) { - *last = false; - goto ret; - } - - if (tp_c->refcnt == 1) { - struct tc_u_hnode *ht; - - for (ht = rtnl_dereference(tp_c->hlist); - ht; - ht = rtnl_dereference(ht->next)) - if (!ht_empty(ht)) { - *last = false; - break; - } - } - -ret: + *last = tp_c->refcnt == 1 && tp_c->knodes == 0; return ret; }