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 08435C43218 for ; Sat, 27 Apr 2019 01:56:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CEE3D206BA for ; Sat, 27 Apr 2019 01:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556330170; bh=bt4VYSePii/hokDc7O9WjHUJ31Z6pxFowz+rajO3rrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=DotNGwRlzbUHvCQHS9t0uzaTfCWBf1N2Cwxl//4xbo/PVZzSKWXc1xGr4sA1V/CJ3 vLMCESSuhVSDYocJrjpIgvJWX3S6rX/Yv8qRQNOQ3RTneBFNTnBmQWKehASpIv+VOw DEin+VadfVt+EPYDSigA1I2kXaRXLjifRbj/xaSA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbfD0B4J (ORCPT ); Fri, 26 Apr 2019 21:56:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:56182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728011AbfD0B4D (ORCPT ); Fri, 26 Apr 2019 21:56:03 -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 CAD1F20B7C; Sat, 27 Apr 2019 01:56:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556330162; bh=bt4VYSePii/hokDc7O9WjHUJ31Z6pxFowz+rajO3rrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QJBm9WexyHZQotjh46ngEtEcwS+FEeAdhXqgN1/0PPKIt59QJC44sYmoqOEDgV52k 1Kuntp5Dh9UiW37skkFrfcZtrkauElguvTLEqEcUv/XHUwIunUCU/76NyqDCjVxDao ACf6Xs4FeCmXWRzR3jI9wM9kVxO0secuZ1ncYyNM= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, David Ahern Subject: [PATCH net-next 5/7] ipv6: Refactor fib6_drop_pcpu_from Date: Fri, 26 Apr 2019 18:56:55 -0700 Message-Id: <20190427015657.24655-6-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190427015657.24655-1-dsahern@kernel.org> References: <20190427015657.24655-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