Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 29 Nov 2013 04:29:02 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r258730 - user/ae/inet6/sys/net
Message-ID:  <201311290429.rAT4T2Ev065768@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Fri Nov 29 04:29:01 2013
New Revision: 258730
URL: http://svnweb.freebsd.org/changeset/base/258730

Log:
  When we are trying to find ifaddr for the specific network, and this
  network has link-local scope, use its sin6_scope_id to determine
  corresponding ifnet. Then just take its first link-local address.
  This helps to go away from the embedded form of LLA.

Modified:
  user/ae/inet6/sys/net/if.c

Modified: user/ae/inet6/sys/net/if.c
==============================================================================
--- user/ae/inet6/sys/net/if.c	Fri Nov 29 04:18:36 2013	(r258729)
+++ user/ae/inet6/sys/net/if.c	Fri Nov 29 04:29:01 2013	(r258730)
@@ -84,6 +84,7 @@
 #ifdef INET6
 #include <netinet6/in6_var.h>
 #include <netinet6/in6_ifattach.h>
+#include <netinet6/scope6_var.h>
 #endif /* INET6 */
 #endif /* INET || INET6 */
 
@@ -1703,7 +1704,20 @@ ifa_ifwithnet(struct sockaddr *addr, int
 	    if (sdl->sdl_index && sdl->sdl_index <= V_if_index)
 		return (ifaddr_byindex(sdl->sdl_index));
 	}
+#ifdef INET6
+	if (af == AF_INET6) {
+		struct sockaddr_in6 *sin6;
 
+		sin6 = (struct sockaddr_in6 *)addr;
+		if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) &&
+		    sin6->sin6_scope_id != 0) {
+			ifp = in6_getlinkifnet(sin6->sin6_scope_id);
+			if (ifp != NULL)
+				return ((struct ifaddr *)
+				    in6ifa_ifpforlinklocal(ifp, 0));
+		}
+	}
+#endif
 	/*
 	 * Scan though each interface, looking for ones that have addresses
 	 * in this address family.  Maintain a reference on ifa_maybe once



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