Index: net/if.c =================================================================== --- net/if.c (revision 253307) +++ net/if.c (working copy) @@ -830,7 +830,9 @@ if_detach(struct ifnet *ifp) { + CURVNET_SET_QUIET(ifp->if_vnet); if_detach_internal(ifp, 0); + CURVNET_RESTORE(); } static void Index: netgraph/ng_base.c =================================================================== --- netgraph/ng_base.c (revision 253307) +++ netgraph/ng_base.c (working copy) @@ -789,6 +789,8 @@ if (node == &ng_deadnode) return; + CURVNET_SET(node->nd_vnet); + if (refcount_release(&node->nd_refs)) { /* we were the last */ node->nd_type->refs--; /* XXX maybe should get types lock? */ @@ -807,6 +809,7 @@ mtx_destroy(&node->nd_input_queue.q_mtx); NG_FREE_NODE(node); } + CURVNET_RESTORE(); } /************************************************************************ Index: kern/subr_bus.c =================================================================== --- kern/subr_bus.c (revision 253307) +++ kern/subr_bus.c (working copy) @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -53,6 +54,8 @@ #include #include +#include + #include #include @@ -2312,6 +2315,7 @@ va_list ap; int retval; + printf("[%lld] ", (long long int) curthread->td_tid); retval = device_print_prettyname(dev); va_start(ap, fmt); retval += vprintf(fmt, ap); @@ -2718,7 +2722,7 @@ int device_probe_and_attach(device_t dev) { - int error; + int error, is_default_vnet; GIANT_REQUIRED; @@ -2727,7 +2731,18 @@ return (0); else if (error != 0) return (error); - return (device_attach(dev)); + + /* + * Only set the default vnet to vnet0 if the current + * vnet isn't vnet0. + */ + is_default_vnet = !! IS_DEFAULT_VNET(curvnet); + if (! is_default_vnet) + CURVNET_SET_QUIET(vnet0); + error = device_attach(dev); + if (! is_default_vnet) + CURVNET_RESTORE(); + return error; } /**