From owner-svn-src-all@FreeBSD.ORG Tue Jan 5 18:25:42 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DAC7C1065695; Tue, 5 Jan 2010 18:25:41 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C913F8FC22; Tue, 5 Jan 2010 18:25:41 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o05IPfjk076261; Tue, 5 Jan 2010 18:25:41 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o05IPfG4076257; Tue, 5 Jan 2010 18:25:41 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201001051825.o05IPfG4076257@svn.freebsd.org> From: John Baldwin Date: Tue, 5 Jan 2010 18:25:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201597 - stable/8/sys/net X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jan 2010 18:25:42 -0000 Author: jhb Date: Tue Jan 5 18:25:41 2010 New Revision: 201597 URL: http://svn.freebsd.org/changeset/base/201597 Log: MFC 201196: Change vlan interfaces to cope more usefully with the parent interface being renamed. Previously the vlan interfaces would lose their configuration as if the parent interface had been physically removed. Now vlan interfaces ignore rename events. - Add a new ifnet flag (IFF_RENAMING) that is set while an ifnet is being renamed. This flag can be checked in ifnet departure/arrival event handlers to treat rename events differently. - Change the ifnet departure event handler in the if_vlan(4) driver to ignore departure events due to a trunk interface being renamed. Modified: stable/8/sys/net/if.c stable/8/sys/net/if.h stable/8/sys/net/if_vlan.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Modified: stable/8/sys/net/if.c ============================================================================== --- stable/8/sys/net/if.c Tue Jan 5 17:45:39 2010 (r201596) +++ stable/8/sys/net/if.c Tue Jan 5 18:25:41 2010 (r201597) @@ -2161,6 +2161,14 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, return (EINVAL); if (ifunit(new_name) != NULL) return (EEXIST); + + /* + * XXX: Locking. Nothing else seems to lock if_flags, + * and there are numerous other races with the + * ifunit() checks not being atomic with namespace + * changes (renames, vmoves, if_attach, etc). + */ + ifp->if_flags |= IFF_RENAMING; /* Announce the departure of the interface. */ rt_ifannouncemsg(ifp, IFAN_DEPARTURE); @@ -2195,6 +2203,8 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); /* Announce the return of the interface. */ rt_ifannouncemsg(ifp, IFAN_ARRIVAL); + + ifp->if_flags &= ~IFF_RENAMING; break; #ifdef VIMAGE Modified: stable/8/sys/net/if.h ============================================================================== --- stable/8/sys/net/if.h Tue Jan 5 17:45:39 2010 (r201596) +++ stable/8/sys/net/if.h Tue Jan 5 18:25:41 2010 (r201597) @@ -150,6 +150,7 @@ struct if_data { #define IFF_MONITOR 0x40000 /* (n) user-requested monitor mode */ #define IFF_STATICARP 0x80000 /* (n) static ARP */ #define IFF_DYING 0x200000 /* (n) interface is winding down */ +#define IFF_RENAMING 0x400000 /* (n) interface is being renamed */ /* * Old names for driver flags so that user space tools can continue to use Modified: stable/8/sys/net/if_vlan.c ============================================================================== --- stable/8/sys/net/if_vlan.c Tue Jan 5 17:45:39 2010 (r201596) +++ stable/8/sys/net/if_vlan.c Tue Jan 5 18:25:41 2010 (r201597) @@ -466,7 +466,8 @@ vlan_setmulti(struct ifnet *ifp) * A handler for network interface departure events. * Track departure of trunks here so that we don't access invalid * pointers or whatever if a trunk is ripped from under us, e.g., - * by ejecting its hot-plug card. + * by ejecting its hot-plug card. However, if an ifnet is simply + * being renamed, then there's no need to tear down the state. */ static void vlan_ifdetach(void *arg __unused, struct ifnet *ifp) @@ -481,6 +482,10 @@ vlan_ifdetach(void *arg __unused, struct if (ifp->if_vlantrunk == NULL) return; + /* If the ifnet is just being renamed, don't do anything. */ + if (ifp->if_flags & IFF_RENAMING) + return; + VLAN_LOCK(); /* * OK, it's a trunk. Loop over and detach all vlan's on it.