Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 9 Sep 2017 07:21:27 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323351 - head/sys/compat/linuxkpi/common/include/linux
Message-ID:  <201709090721.v897LRWA084296@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Sat Sep  9 07:21:27 2017
New Revision: 323351
URL: https://svnweb.freebsd.org/changeset/base/323351

Log:
  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

Modified:
  head/sys/compat/linuxkpi/common/include/linux/inetdevice.h

Modified: head/sys/compat/linuxkpi/common/include/linux/inetdevice.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/inetdevice.h	Sat Sep  9 06:34:20 2017	(r323350)
+++ head/sys/compat/linuxkpi/common/include/linux/inetdevice.h	Sat Sep  9 07:21:27 2017	(r323351)
@@ -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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201709090721.v897LRWA084296>