From owner-svn-src-stable@freebsd.org Mon Feb 19 10:30:36 2018 Return-Path: Delivered-To: svn-src-stable@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 F0C6EF17A83; Mon, 19 Feb 2018 10:30:35 +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 ABB506C690; Mon, 19 Feb 2018 10:30:34 +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 A1A93194EF; Mon, 19 Feb 2018 10:30:34 +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 w1JAUYTb086740; Mon, 19 Feb 2018 10:30:34 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1JAUY8N086739; Mon, 19 Feb 2018 10:30:34 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201802191030.w1JAUY8N086739@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Mon, 19 Feb 2018 10:30:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r329558 - stable/11/sys/netinet6 X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: stable/11/sys/netinet6 X-SVN-Commit-Revision: 329558 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Feb 2018 10:30:36 -0000 Author: ae Date: Mon Feb 19 10:30:34 2018 New Revision: 329558 URL: https://svnweb.freebsd.org/changeset/base/329558 Log: MFC r328540: 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 Modified: stable/11/sys/netinet6/in6_ifattach.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netinet6/in6_ifattach.c ============================================================================== --- stable/11/sys/netinet6/in6_ifattach.c Mon Feb 19 09:08:46 2018 (r329557) +++ stable/11/sys/netinet6/in6_ifattach.c Mon Feb 19 10:30:34 2018 (r329558) @@ -689,7 +689,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; @@ -722,18 +721,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); } /* @@ -741,18 +738,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); }