svn commit: r201196 - head/sys/net
John Baldwin
jhb at FreeBSD.org
Tue Dec 29 13:35:19 UTC 2009
Author: jhb
Date: Tue Dec 29 13:35:18 2009
New Revision: 201196
URL: http://svn.freebsd.org/changeset/base/201196
Log:
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.
Reviewed by: brooks, rwatson
MFC after: 1 week
Modified:
head/sys/net/if.c
head/sys/net/if.h
head/sys/net/if_vlan.c
Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c Tue Dec 29 13:14:13 2009 (r201195)
+++ head/sys/net/if.c Tue Dec 29 13:35:18 2009 (r201196)
@@ -2095,6 +2095,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);
@@ -2129,6 +2137,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: head/sys/net/if.h
==============================================================================
--- head/sys/net/if.h Tue Dec 29 13:14:13 2009 (r201195)
+++ head/sys/net/if.h Tue Dec 29 13:35:18 2009 (r201196)
@@ -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: head/sys/net/if_vlan.c
==============================================================================
--- head/sys/net/if_vlan.c Tue Dec 29 13:14:13 2009 (r201195)
+++ head/sys/net/if_vlan.c Tue Dec 29 13:35:18 2009 (r201196)
@@ -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.
More information about the svn-src-head
mailing list