From owner-svn-src-user@FreeBSD.ORG Fri Nov 29 04:29:02 2013 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 85556F79; Fri, 29 Nov 2013 04:29:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 722251BF7; Fri, 29 Nov 2013 04:29:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAT4T2GV065769; Fri, 29 Nov 2013 04:29:02 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAT4T2Ev065768; Fri, 29 Nov 2013 04:29:02 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201311290429.rAT4T2Ev065768@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 29 Nov 2013 04:29:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r258730 - user/ae/inet6/sys/net X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Nov 2013 04:29:02 -0000 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 #include +#include #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