Only search the scope ID in ip6_find_dev() for IPv6 addresses which

have a scope ID. Change size of the searched scope ID to the full
16-bits. There can typically be more than 255 interfaces.

Suggested by:		ae @
MFC after:		1 week
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2017-09-09 12:50:12 +00:00
parent 7ca8a2b385
commit 6263f8b78d

View File

@ -61,7 +61,7 @@ static inline struct net_device *
ip6_dev_find(struct vnet *vnet, struct in6_addr addr)
{
struct sockaddr_in6 sin6;
struct ifaddr *ifa;
struct ifaddr *ifa = NULL;
struct ifnet *ifp = NULL;
int x;
@ -70,16 +70,22 @@ ip6_dev_find(struct vnet *vnet, struct in6_addr addr)
sin6.sin6_len = sizeof(sin6);
sin6.sin6_family = AF_INET6;
CURVNET_SET_QUIET(vnet);
if (IN6_IS_SCOPE_LINKLOCAL(&addr) ||
IN6_IS_ADDR_MC_INTFACELOCAL(&addr)) {
/* XXX need to search all scope ID's */
for (x = 0; x <= V_if_index; x++) {
sin6.sin6_addr.s6_addr[3] = x;
for (x = 0; x <= V_if_index && x < 65536; x++) {
sin6.sin6_addr.s6_addr16[1] = htons(x);
ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
if (ifa != NULL)
break;
}
} else {
ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
}
if (ifa != NULL) {
ifp = ifa->ifa_ifp;
if_ref(ifp);
ifa_free(ifa);
break;
}
}
CURVNET_RESTORE();
return (ifp);