Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Dec 2011 22:12:58 +0000 (UTC)
From:      Hiroki Sato <hrs@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r228244 - stable/9/sys/netinet6
Message-ID:  <201112032212.pB3MCwGF058505@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hrs
Date: Sat Dec  3 22:12:57 2011
New Revision: 228244
URL: http://svn.freebsd.org/changeset/base/228244

Log:
  MFC r226446:
  Fix a problem that an interface unexpectedly becomes IFF_UP by
  just doing "ifconfing inet6 -ifdisabled" when the interface has
  ND6_IFF_AUTO_LINKLOCAL flag and no link-local address.
  
  Approved by:	re (bz)

Modified:
  stable/9/sys/netinet6/nd6.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)

Modified: stable/9/sys/netinet6/nd6.c
==============================================================================
--- stable/9/sys/netinet6/nd6.c	Sat Dec  3 19:56:52 2011	(r228243)
+++ stable/9/sys/netinet6/nd6.c	Sat Dec  3 22:12:57 2011	(r228244)
@@ -1364,7 +1364,8 @@ nd6_ioctl(u_long cmd, caddr_t data, stru
 				    " duplicate.\n");
 			} else {
 				ND_IFINFO(ifp)->flags &= ~ND6_IFF_IFDISABLED;
-				in6_if_up(ifp);
+				if (ifp->if_flags & IFF_UP)
+					in6_if_up(ifp);
 			}
 		} else if (!(ND_IFINFO(ifp)->flags & ND6_IFF_IFDISABLED) &&
 			    (ND.flags & ND6_IFF_IFDISABLED)) {
@@ -1382,35 +1383,37 @@ nd6_ioctl(u_long cmd, caddr_t data, stru
 			IF_ADDR_UNLOCK(ifp);
 		}
 
-		if (!(ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) &&
-		    (ND.flags & ND6_IFF_AUTO_LINKLOCAL)) {
-			/* auto_linklocal 0->1 transision */
-
-			/* If no link-local address on ifp, configure */
-			ND_IFINFO(ifp)->flags |= ND6_IFF_AUTO_LINKLOCAL;
-			in6_ifattach(ifp, NULL);
-		} else if ((ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL) &&
-		    !(ND.flags & ND6_IFF_IFDISABLED)) {
-			/*
-			 * When the IF already has
-			 * ND6_IFF_AUTO_LINKLOCAL and no link-local
-			 * address is assigned, try to assign one.
-			 */
-			int haslinklocal = 0;
+		if (ND.flags & ND6_IFF_AUTO_LINKLOCAL) {
+			if (!(ND_IFINFO(ifp)->flags & ND6_IFF_AUTO_LINKLOCAL)) {
+				/* auto_linklocal 0->1 transision */
+
+				/* If no link-local address on ifp, configure */
+				ND_IFINFO(ifp)->flags |= ND6_IFF_AUTO_LINKLOCAL;
+				in6_ifattach(ifp, NULL);
+			} else if (!(ND.flags & ND6_IFF_IFDISABLED) &&
+			    ifp->if_flags & IFF_UP) {
+				/*
+				 * When the IF already has
+				 * ND6_IFF_AUTO_LINKLOCAL, no link-local
+				 * address is assigned, and IFF_UP, try to
+				 * assign one.
+				 */
+				int haslinklocal = 0;
 			
-			IF_ADDR_LOCK(ifp);
-			TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
-				if (ifa->ifa_addr->sa_family != AF_INET6)
-					continue;
-				ia = (struct in6_ifaddr *)ifa;
-				if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) {
-					haslinklocal = 1;
-					break;
+				IF_ADDR_LOCK(ifp);
+				TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
+					if (ifa->ifa_addr->sa_family != AF_INET6)
+						continue;
+					ia = (struct in6_ifaddr *)ifa;
+					if (IN6_IS_ADDR_LINKLOCAL(IA6_IN6(ia))) {
+						haslinklocal = 1;
+						break;
+					}
 				}
+				IF_ADDR_UNLOCK(ifp);
+				if (!haslinklocal)
+					in6_ifattach(ifp, NULL);
 			}
-			IF_ADDR_UNLOCK(ifp);
-			if (!haslinklocal)
-				in6_ifattach(ifp, NULL);
 		}
 	}
 		ND_IFINFO(ifp)->flags = ND.flags;



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