From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH][net-next] net/ipv6: compute anycast address hash only if dev is null Date: Wed, 07 Nov 2018 21:49:57 -0800 (PST) Message-ID: <20181107.214957.452822093411627013.davem@davemloft.net> References: <1541655340-7035-1-git-send-email-lirongqing@baidu.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: lirongqing@baidu.com Return-path: Received: from shards.monkeyblade.net ([23.128.96.9]:51490 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726068AbeKHPXs (ORCPT ); Thu, 8 Nov 2018 10:23:48 -0500 In-Reply-To: <1541655340-7035-1-git-send-email-lirongqing@baidu.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Li RongQing Date: Thu, 8 Nov 2018 13:35:40 +0800 > avoid to compute the hash value if dev is not null, since > hash value is not used > > Signed-off-by: Li RongQing > --- > net/ipv6/anycast.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c > index 94999058e110..a20e344486cb 100644 > --- a/net/ipv6/anycast.c > +++ b/net/ipv6/anycast.c > @@ -433,15 +433,16 @@ static bool ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *ad > bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, > const struct in6_addr *addr) > { > - unsigned int hash = inet6_acaddr_hash(net, addr); > struct net_device *nh_dev; > struct ifacaddr6 *aca; > bool found = false; > + unsigned int hash; > > rcu_read_lock(); > if (dev) > found = ipv6_chk_acast_dev(dev, addr); > - else > + else { > + hash = inet6_acaddr_hash(net, addr); > hlist_for_each_entry_rcu(aca, &inet6_acaddr_lst[hash], Please move the hash local variable declaration into this basic block too, if you're going to do this. Thanks.