From mboxrd@z Thu Jan 1 00:00:00 1970 From: Li RongQing Subject: [PATCH][net-next][v2] net/ipv6: compute anycast address hash only if dev is null Date: Thu, 8 Nov 2018 14:58:07 +0800 Message-ID: <1541660287-8728-1-git-send-email-lirongqing@baidu.com> To: netdev@vger.kernel.org Return-path: Received: from mx58.baidu.com ([61.135.168.58]:15370 "EHLO tc-sys-mailedm01.tc.baidu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726027AbeKHQc3 (ORCPT ); Thu, 8 Nov 2018 11:32:29 -0500 Received: from localhost (cp01-cos-dev01.cp01.baidu.com [10.92.119.46]) by tc-sys-mailedm01.tc.baidu.com (Postfix) with ESMTP id F2F6E2040041 for ; Thu, 8 Nov 2018 14:58:07 +0800 (CST) Sender: netdev-owner@vger.kernel.org List-ID: 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..cca3b3603c42 100644 --- a/net/ipv6/anycast.c +++ b/net/ipv6/anycast.c @@ -433,7 +433,6 @@ 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; @@ -441,7 +440,9 @@ bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, rcu_read_lock(); if (dev) found = ipv6_chk_acast_dev(dev, addr); - else + else { + unsigned int hash = inet6_acaddr_hash(net, addr); + hlist_for_each_entry_rcu(aca, &inet6_acaddr_lst[hash], aca_addr_lst) { nh_dev = fib6_info_nh_dev(aca->aca_rt); @@ -452,6 +453,7 @@ bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev, break; } } + } rcu_read_unlock(); return found; } -- 2.16.2