Date: Fri, 26 Oct 2012 16:56:55 +0000 (UTC) From: Adrian Chadd <adrian@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r242149 - head/sys/net80211 Message-ID: <201210261656.q9QGutjl045015@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: adrian Date: Fri Oct 26 16:56:55 2012 New Revision: 242149 URL: http://svn.freebsd.org/changeset/base/242149 Log: 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. Modified: head/sys/net80211/ieee80211.c head/sys/net80211/ieee80211_freebsd.c Modified: head/sys/net80211/ieee80211.c ============================================================================== --- head/sys/net80211/ieee80211.c Fri Oct 26 16:52:56 2012 (r242148) +++ head/sys/net80211/ieee80211.c Fri Oct 26 16:56:55 2012 (r242149) @@ -317,7 +317,11 @@ ieee80211_ifattach(struct ieee80211com * 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 * 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 * 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 * 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 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 ieee80211_sysctl_vdetach(vap); if_free(ifp); + + CURVNET_RESTORE(); } /* Modified: head/sys/net80211/ieee80211_freebsd.c ============================================================================== --- head/sys/net80211/ieee80211_freebsd.c Fri Oct 26 16:52:56 2012 (r242148) +++ head/sys/net80211/ieee80211_freebsd.c Fri Oct 26 16:56:55 2012 (r242149) @@ -152,7 +152,9 @@ wlan_clone_destroy(struct ifnet *ifp) void ieee80211_vap_destroy(struct ieee80211vap *vap) { + CURVNET_SET(vap->iv_ifp->if_vnet); if_clone_destroyif(wlan_cloner, vap->iv_ifp); + CURVNET_RESTORE(); } int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210261656.q9QGutjl045015>