Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 Feb 2018 10:30:34 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
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
Message-ID:  <201802191030.w1JAUY8N086739@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
 	}
 



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