From patchwork Fri Mar 27 21:14:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Duyck X-Patchwork-Id: 455582 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 8CA641400A0 for ; Sat, 28 Mar 2015 08:14:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752739AbbC0VOZ (ORCPT ); Fri, 27 Mar 2015 17:14:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47982 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752665AbbC0VOY (ORCPT ); Fri, 27 Mar 2015 17:14:24 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t2RLENKD027271 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 27 Mar 2015 17:14:23 -0400 Received: from [192.168.122.149] (ovpn-112-81.phx2.redhat.com [10.3.112.81]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t2RLEMn4012009; Fri, 27 Mar 2015 17:14:23 -0400 Subject: [net-next PATCH 2/2] fib_trie: Cleanup ip_fib_net_exit code path From: Alexander Duyck To: netdev@vger.kernel.org Cc: davem@davemloft.net Date: Fri, 27 Mar 2015 14:14:22 -0700 Message-ID: <20150327211422.2465.50276.stgit@ahduyck-vm-fedora22> In-Reply-To: <20150327211416.2465.23170.stgit@ahduyck-vm-fedora22> References: <20150327211416.2465.23170.stgit@ahduyck-vm-fedora22> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org While fixing a recent issue I noticed that we are doing some unnecessary work inside the loop for ip_fib_net_exit. As such I am pulling out the initialization to NULL for the locally stored fib_local, fib_main, and fib_default. In addition I am restoring the original code for flushing the table as there is no need to split up the fib_table_flush and hlist_del work since the code for packing the tnodes with multiple key vectors was dropped. Signed-off-by: Alexander Duyck --- net/ipv4/fib_frontend.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 767120111d90..718b0a16ea40 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -1176,35 +1176,20 @@ static void ip_fib_net_exit(struct net *net) rtnl_lock(); +#ifdef CONFIG_IP_MULTIPLE_TABLES + RCU_INIT_POINTER(net->ipv4.fib_local, NULL); + RCU_INIT_POINTER(net->ipv4.fib_main, NULL); + RCU_INIT_POINTER(net->ipv4.fib_default, NULL); +#endif + for (i = 0; i < FIB_TABLE_HASHSZ; i++) { struct hlist_head *head = &net->ipv4.fib_table_hash[i]; struct hlist_node *tmp; struct fib_table *tb; - /* this is done in two passes as flushing the table could - * cause it to be reallocated in order to accommodate new - * tnodes at the root as the table shrinks. - */ - hlist_for_each_entry_safe(tb, tmp, head, tb_hlist) - fib_table_flush(tb); - hlist_for_each_entry_safe(tb, tmp, head, tb_hlist) { -#ifdef CONFIG_IP_MULTIPLE_TABLES - switch (tb->tb_id) { - case RT_TABLE_LOCAL: - RCU_INIT_POINTER(net->ipv4.fib_local, NULL); - break; - case RT_TABLE_MAIN: - RCU_INIT_POINTER(net->ipv4.fib_main, NULL); - break; - case RT_TABLE_DEFAULT: - RCU_INIT_POINTER(net->ipv4.fib_default, NULL); - break; - default: - break; - } -#endif hlist_del(&tb->tb_hlist); + fib_table_flush(tb); fib_free_table(tb); } }