From owner-svn-src-head@freebsd.org Mon Jan 29 10:33:56 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 829B4EE236D; Mon, 29 Jan 2018 10:33:56 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 35FCC699BA; Mon, 29 Jan 2018 10:33:56 +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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 309AE26F11; Mon, 29 Jan 2018 10:33:56 +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 w0TAXuPv047400; Mon, 29 Jan 2018 10:33:56 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0TAXuLY047399; Mon, 29 Jan 2018 10:33:56 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201801291033.w0TAXuLY047399@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 29 Jan 2018 10:33:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328540 - head/sys/netinet6 X-SVN-Group: head X-SVN-Commit-Author: ae X-SVN-Commit-Paths: head/sys/netinet6 X-SVN-Commit-Revision: 328540 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2018 10:33:56 -0000 Author: ae Date: Mon Jan 29 10:33:55 2018 New Revision: 328540 URL: https://svnweb.freebsd.org/changeset/base/328540 Log: Assign IPv6 link-local address to loopback interfaces whith unit > 0. When an interface has IFF_LOOPBACK flag in6_ifattach() tries to assing IPv6 loopback address to this interface. It uses in6ifa_ifpwithaddr() to check, that interface doesn't already have given address and then uses in6_ifattach_loopback(). If in6_ifattach_loopback() fails, it just exits and thus skips assignment of IPv6 LLA. Fix this using in6ifa_ifwithaddr() function. If IPv6 loopback address is already assigned in the system, do not call in6_ifattach_loopback(). PR: 138678 MFC after: 3 weeks Modified: head/sys/netinet6/in6_ifattach.c Modified: head/sys/netinet6/in6_ifattach.c ============================================================================== --- head/sys/netinet6/in6_ifattach.c Mon Jan 29 10:19:15 2018 (r328539) +++ head/sys/netinet6/in6_ifattach.c Mon Jan 29 10:33:55 2018 (r328540) @@ -690,7 +690,6 @@ void in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) { struct in6_ifaddr *ia; - struct in6_addr in6; if (ifp->if_afdata[AF_INET6] == NULL) return; @@ -723,18 +722,16 @@ in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) /* * assign loopback address for loopback interface. - * XXX multiple loopback interface case. */ if ((ifp->if_flags & IFF_LOOPBACK) != 0) { - struct ifaddr *ifa; - - in6 = in6addr_loopback; - ifa = (struct ifaddr *)in6ifa_ifpwithaddr(ifp, &in6); - if (ifa == NULL) { - if (in6_ifattach_loopback(ifp) != 0) - return; - } else - ifa_free(ifa); + /* + * check that loopback address doesn't exist yet. + */ + ia = in6ifa_ifwithaddr(&in6addr_loopback, 0); + if (ia == NULL) + in6_ifattach_loopback(ifp); + else + ifa_free(&ia->ia_ifa); } /* @@ -742,18 +739,10 @@ in6_ifattach(struct ifnet *ifp, struct ifnet *altifp) */ if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) && ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) { - int error; - ia = in6ifa_ifpforlinklocal(ifp, 0); - if (ia == NULL) { - error = in6_ifattach_linklocal(ifp, altifp); -#if 0 - if (error) - log(LOG_NOTICE, "in6_ifattach_linklocal: " - "failed to add a link-local addr to %s\n", - if_name(ifp)); -#endif - } else + if (ia == NULL) + in6_ifattach_linklocal(ifp, altifp); + else ifa_free(&ia->ia_ifa); }