mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-14 06:12:01 +01:00
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.
This commit is contained in:
parent
04e9501602
commit
30e4856a81
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=242149
@ -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();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user