From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 21C83C4321A for ; Sun, 28 Apr 2019 02:26:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E478C208C2 for ; Sun, 28 Apr 2019 02:26:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556418404; bh=bt4VYSePii/hokDc7O9WjHUJ31Z6pxFowz+rajO3rrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WmNDAGmgCxS5wQyxCGSiCqMpAtDg398jINO1DRBKXcE1LzHPx2g4kIOR9jkJYfPjh Dq5KprsdM5veCpKvxSW8nt2w/YL4jnm81JmEgWnkIA0rWDx5s+y7pMHi9DDVXeuHRI QrO3gzuEZyADG1F2tphSvbSTSSQFK4o3ryBRe76w= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726485AbfD1C0m (ORCPT ); Sat, 27 Apr 2019 22:26:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:44050 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726460AbfD1C0l (ORCPT ); Sat, 27 Apr 2019 22:26:41 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 507D521473; Sun, 28 Apr 2019 02:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556418400; bh=bt4VYSePii/hokDc7O9WjHUJ31Z6pxFowz+rajO3rrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vTJuzgo534X5XcEc77HUtgVMTJ8JnyUqBfqCl2RkwdZRnxVOd/qhPCdWPapy8jD2w u2xFsWPRb2Y9c537vKrXoes+UNDvQkLii0poFQPXs5QvK+rKEGKJ6ONG/7xq4OcSrO umApUDJnf5NW53wi7gVSoVRwojXHlEpX3Cj7XuYA= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, David Ahern Subject: [PATCH v2 net-next 5/7] ipv6: Refactor fib6_drop_pcpu_from Date: Sat, 27 Apr 2019 19:27:32 -0700 Message-Id: <20190428022734.21965-6-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190428022734.21965-1-dsahern@kernel.org> References: <20190428022734.21965-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Move the existing pcpu walk in fib6_drop_pcpu_from to a new helper, __fib6_drop_pcpu_from, that can be invoked per fib6_nh with a reference to the from entries that need to be evicted. If the passed in from is non-NULL then only entries associated with that fib6_info are removed (fib entry is deleted); if the from is NULL are entries are flushed (nexthop is deleted). For fib6_info entries with builtin fib6_nh (ie., current code) there is no change in behavior. Signed-off-by: David Ahern --- net/ipv6/ip6_fib.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 793830b2965d..aaffe4a653d8 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -874,10 +874,10 @@ static struct fib6_node *fib6_add_1(struct net *net, return ln; } -static void fib6_drop_pcpu_from(struct fib6_info *f6i, - const struct fib6_table *table) +static void __fib6_drop_pcpu_from(struct fib6_nh *fib6_nh, + const struct fib6_info *from, + const struct fib6_table *table) { - struct fib6_nh *fib6_nh = &f6i->fib6_nh; int cpu; if (!rcu_access_pointer(fib6_nh->rt6i_pcpu)) @@ -892,17 +892,27 @@ static void fib6_drop_pcpu_from(struct fib6_info *f6i, ppcpu_rt = per_cpu_ptr(fib6_nh->rt6i_pcpu, cpu); pcpu_rt = *ppcpu_rt; - if (pcpu_rt) { - struct fib6_info *from; + if (pcpu_rt && + (!from || rcu_access_pointer(pcpu_rt->from) == from)) { + struct fib6_info *pfrom; - from = rcu_dereference_protected(pcpu_rt->from, + pfrom = rcu_dereference_protected(pcpu_rt->from, lockdep_is_held(&table->tb6_lock)); rcu_assign_pointer(pcpu_rt->from, NULL); - fib6_info_release(from); + fib6_info_release(pfrom); } } } +static void fib6_drop_pcpu_from(struct fib6_info *f6i, + const struct fib6_table *table) +{ + struct fib6_nh *fib6_nh; + + fib6_nh = &f6i->fib6_nh; + __fib6_drop_pcpu_from(fib6_nh, f6i, table); +} + static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn, struct net *net) { @@ -930,8 +940,7 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn, lockdep_is_held(&table->tb6_lock)); } - if (rt->fib6_nh.rt6i_pcpu) - fib6_drop_pcpu_from(rt, table); + fib6_drop_pcpu_from(rt, table); } } -- 2.11.0