1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-24 16:10:11 +00:00

Resolve IPv6 scope ID issues when using ip6_find_dev() in the LinuxKPI.

Workaround problem that ifa_ifwithaddr() also matches the scope ID of
the IPv6 address when searching for a maching IPv6 address. For now
simply try all valid scope IDs until a match is found.

MFC after:		1 week
Sponsored by:		Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2017-09-09 07:21:27 +00:00
parent 65c5a7a879
commit f4cf3177a2
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323351

View File

@ -62,22 +62,26 @@ ip6_dev_find(struct vnet *vnet, struct in6_addr addr)
{
struct sockaddr_in6 sin6;
struct ifaddr *ifa;
struct ifnet *ifp;
struct ifnet *ifp = NULL;
int x;
memset(&sin6, 0, sizeof(sin6));
sin6.sin6_addr = addr;
sin6.sin6_len = sizeof(sin6);
sin6.sin6_family = AF_INET6;
CURVNET_SET_QUIET(vnet);
ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
CURVNET_RESTORE();
if (ifa) {
ifp = ifa->ifa_ifp;
if_ref(ifp);
ifa_free(ifa);
} else {
ifp = NULL;
/* XXX need to search all scope ID's */
for (x = 0; x <= V_if_index; x++) {
sin6.sin6_addr.s6_addr[3] = x;
ifa = ifa_ifwithaddr((struct sockaddr *)&sin6);
if (ifa != NULL) {
ifp = ifa->ifa_ifp;
if_ref(ifp);
ifa_free(ifa);
break;
}
}
CURVNET_RESTORE();
return (ifp);
}