Skip to content

Commit 1c51dc9

Browse files
lrq-maxdavem330
authored andcommitted
net/ipv6: compute anycast address hash only if dev is null
avoid to compute the hash value if dev is not null, since hash value is not used Signed-off-by: Li RongQing <lirongqing@baidu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0db5509 commit 1c51dc9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

net/ipv6/anycast.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,15 +433,16 @@ static bool ipv6_chk_acast_dev(struct net_device *dev, const struct in6_addr *ad
433433
bool ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
434434
const struct in6_addr *addr)
435435
{
436-
unsigned int hash = inet6_acaddr_hash(net, addr);
437436
struct net_device *nh_dev;
438437
struct ifacaddr6 *aca;
439438
bool found = false;
440439

441440
rcu_read_lock();
442441
if (dev)
443442
found = ipv6_chk_acast_dev(dev, addr);
444-
else
443+
else {
444+
unsigned int hash = inet6_acaddr_hash(net, addr);
445+
445446
hlist_for_each_entry_rcu(aca, &inet6_acaddr_lst[hash],
446447
aca_addr_lst) {
447448
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,
452453
break;
453454
}
454455
}
456+
}
455457
rcu_read_unlock();
456458
return found;
457459
}

0 commit comments

Comments
 (0)