After r302054 unloading an network interface driver on a kernel

without VIMAGE support would dereference a NULL point unconditionally
leading to a panic.  Wrap the entire VIMAGE related code with #ifdefs
rather than just the decision making part to save an extra bit of
resources.

Reported by:	np
Sponsored by:	The FreeBSD Foundation
MFC After:	13 days
Approved by:	re (marius)
This commit is contained in:
Bjoern A. Zeeb 2016-06-22 11:45:30 +00:00
parent a844d49cc6
commit d3f6f80f4b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302083

View File

@ -931,10 +931,13 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
int i;
struct domain *dp;
struct ifnet *iter;
int found = 0, shutdown;
int found = 0;
#ifdef VIMAGE
int shutdown;
shutdown = (ifp->if_vnet->vnet_state > SI_SUB_VNET &&
ifp->if_vnet->vnet_state < SI_SUB_VNET_DONE) ? 1 : 0;
#endif
IFNET_WLOCK();
TAILQ_FOREACH(iter, &V_ifnet, if_link)
if (iter == ifp) {
@ -987,6 +990,7 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
if_down(ifp);
#ifdef VIMAGE
/*
* On VNET shutdown abort here as the stack teardown will do all
* the work top-down for us.
@ -1001,6 +1005,7 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
*/
goto finish_vnet_shutdown;
}
#endif
/*
* At this point we are not tearing down a VNET and are either
@ -1066,7 +1071,9 @@ if_detach_internal(struct ifnet *ifp, int vmove, struct if_clone **ifcp)
rt_flushifroutes(ifp);
#ifdef VIMAGE
finish_vnet_shutdown:
#endif
/*
* We cannot hold the lock over dom_ifdetach calls as they might
* sleep, for example trying to drain a callout, thus open up the