avoid to compute the hash value if dev is not null, since hash value is not used
Signed-off-by: Li RongQing <lirongq...@baidu.com> --- 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], 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