svn commit: r328540 - head/sys/netinet6

Andrey V. Elsukov ae at FreeBSD.org
Mon Jan 29 10:33:56 UTC 2018


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);
 	}
 


More information about the svn-src-head mailing list