From owner-svn-src-all@freebsd.org Thu Mar 31 09:55:22 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C5398AE380D; Thu, 31 Mar 2016 09:55:22 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8986119B9; Thu, 31 Mar 2016 09:55:22 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u2V9tLSd031723; Thu, 31 Mar 2016 09:55:21 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u2V9tL4Y031722; Thu, 31 Mar 2016 09:55:21 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201603310955.u2V9tL4Y031722@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 31 Mar 2016 09:55:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r297445 - stable/10/sys/netinet6 X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Mar 2016 09:55:22 -0000 Author: ae Date: Thu Mar 31 09:55:21 2016 New Revision: 297445 URL: https://svnweb.freebsd.org/changeset/base/297445 Log: MFC r296984: Change in6_selectsrc() to allow usage of non-local IPv6 addresses in IPV6_PKTINFO ancillary data when IPV6_BINDANY socket option is set. Modified: stable/10/sys/netinet6/in6_src.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/netinet6/in6_src.c ============================================================================== --- stable/10/sys/netinet6/in6_src.c Thu Mar 31 06:19:15 2016 (r297444) +++ stable/10/sys/netinet6/in6_src.c Thu Mar 31 09:55:21 2016 (r297445) @@ -249,19 +249,27 @@ in6_selectsrc(struct sockaddr_in6 *dstso (inp->inp_flags & IN6P_IPV6_V6ONLY) != 0))) != 0) return (error); - ia6 = (struct in6_ifaddr *)ifa_ifwithaddr( - (struct sockaddr *)&srcsock); - if (ia6 == NULL || - (ia6->ia6_flags & (IN6_IFF_ANYCAST | IN6_IFF_NOTREADY))) { - if (ia6 != NULL) - ifa_free(&ia6->ia_ifa); - return (EADDRNOTAVAIL); - } + /* + * If IPV6_BINDANY socket option is set, we allow to specify + * non local addresses as source address in IPV6_PKTINFO + * ancillary data. + */ + if ((inp->inp_flags & INP_BINDANY) == 0) { + ia6 = (struct in6_ifaddr *)ifa_ifwithaddr( + (struct sockaddr *)&srcsock); + if (ia6 == NULL || (ia6->ia6_flags & (IN6_IFF_ANYCAST | + IN6_IFF_NOTREADY))) { + if (ia6 != NULL) + ifa_free(&ia6->ia_ifa); + return (EADDRNOTAVAIL); + } + bcopy(&ia6->ia_addr.sin6_addr, srcp, sizeof(*srcp)); + ifa_free(&ia6->ia_ifa); + } else + bcopy(&srcsock.sin6_addr, srcp, sizeof(*srcp)); pi->ipi6_addr = srcsock.sin6_addr; /* XXX: this overrides pi */ if (ifpp) *ifpp = ifp; - bcopy(&ia6->ia_addr.sin6_addr, srcp, sizeof(*srcp)); - ifa_free(&ia6->ia_ifa); return (0); }