diff options
author | adrian <adrian@FreeBSD.org> | 2012-10-26 16:56:55 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2012-10-26 16:56:55 +0000 |
commit | cc93b91b81aa385b660a4d4fa680acec2e2eb002 (patch) | |
tree | 89dc6c8f02833aca831c905e6e95a4501c8e18c8 /sys/net80211/ieee80211.c | |
parent | b24573de07e5249b4c159feabcbfed257142a85d (diff) | |
download | FreeBSD-src-cc93b91b81aa385b660a4d4fa680acec2e2eb002.zip FreeBSD-src-cc93b91b81aa385b660a4d4fa680acec2e2eb002.tar.gz |
Fix up some initial issues with creation and deletion of hotplugged
net80211 devices and vaps.
* vnet sets vnet0 during kldload and device probe/attach, but not for
the hotplug event. Thus, plugging in a NIC causes things to panic.
So, add a CURVNET_SET(vnet0) for now during the attach phase, until
the hotplug code is taught to set CURVNET_SET(vnet0).
* there's also no implied detach vnet context - so teach the detach
path about ifp->if_vnet.
* When creating/deleting vaps, also set the vnet context appropriately.
These can be done at any time.
Now, the problems!
* ieee80211.c is supposed to be OS-portable code, with no OS-specific stuff
like vnet. That should be fixed.
* When the device hotplug code gets taught about CURVNET_SET(vnet0), the
device vnet set can go away; but the VAP vnet set still needs to be there.
* .. and there still is the question about potentially adding an implied
CURVNET_SET(ifp->if_vnet) on if_free(), since any/all devices may end up
being detached by a hotplug event in today's world. That's going to be
a topic of a subsequent commit.
Diffstat (limited to 'sys/net80211/ieee80211.c')
-rw-r--r-- | sys/net80211/ieee80211.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/sys/net80211/ieee80211.c b/sys/net80211/ieee80211.c index 78c876e..49f8a8e 100644 --- a/sys/net80211/ieee80211.c +++ b/sys/net80211/ieee80211.c @@ -317,7 +317,11 @@ ieee80211_ifattach(struct ieee80211com *ic, ifp->if_addrlen = IEEE80211_ADDR_LEN; ifp->if_hdrlen = 0; + + CURVNET_SET(vnet0); + if_attach(ifp); + ifp->if_mtu = IEEE80211_MTU_MAX; ifp->if_broadcastaddr = ieee80211broadcastaddr; ifp->if_output = null_output; @@ -331,6 +335,8 @@ ieee80211_ifattach(struct ieee80211com *ic, sdl->sdl_alen = IEEE80211_ADDR_LEN; IEEE80211_ADDR_COPY(LLADDR(sdl), macaddr); ifa_free(ifa); + + CURVNET_RESTORE(); } /* @@ -345,8 +351,18 @@ ieee80211_ifdetach(struct ieee80211com *ic) struct ifnet *ifp = ic->ic_ifp; struct ieee80211vap *vap; + /* + * This detaches the main interface, but not the vaps. + * Each VAP may be in a separate VIMAGE. + */ + CURVNET_SET(ifp->if_vnet); if_detach(ifp); + CURVNET_RESTORE(); + /* + * The VAP is responsible for setting and clearing + * the VIMAGE context. + */ while ((vap = TAILQ_FIRST(&ic->ic_vaps)) != NULL) ieee80211_vap_destroy(vap); ieee80211_waitfor_parent(ic); @@ -365,7 +381,9 @@ ieee80211_ifdetach(struct ieee80211com *ic) ieee80211_power_detach(ic); ieee80211_node_detach(ic); + /* XXX VNET needed? */ ifmedia_removeall(&ic->ic_media); + taskqueue_free(ic->ic_tq); IEEE80211_LOCK_DESTROY(ic); } @@ -586,6 +604,8 @@ ieee80211_vap_detach(struct ieee80211vap *vap) struct ieee80211com *ic = vap->iv_ic; struct ifnet *ifp = vap->iv_ifp; + CURVNET_SET(ifp->if_vnet); + IEEE80211_DPRINTF(vap, IEEE80211_MSG_STATE, "%s: %s parent %s\n", __func__, ieee80211_opmode_name[vap->iv_opmode], ic->ic_ifp->if_xname); @@ -638,6 +658,8 @@ ieee80211_vap_detach(struct ieee80211vap *vap) ieee80211_sysctl_vdetach(vap); if_free(ifp); + + CURVNET_RESTORE(); } /* |