summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorbz <bz@FreeBSD.org>2016-06-22 11:45:30 +0000
committerbz <bz@FreeBSD.org>2016-06-22 11:45:30 +0000
commit2b26f1f44b746e4ccfd50c9d1e2cd3f7ac1e3ad5 (patch)
tree263f17630d849c1bf973e2eba1643d3aebc0d199 /sys/net
parent7cdbaef028ebaa6b6a8adce78fc14023033eb1f8 (diff)
downloadFreeBSD-src-2b26f1f44b746e4ccfd50c9d1e2cd3f7ac1e3ad5.zip
FreeBSD-src-2b26f1f44b746e4ccfd50c9d1e2cd3f7ac1e3ad5.tar.gz
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)
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 5bad9e2..c351bea 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -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
OpenPOWER on IntegriCloud