svn commit: r253700 - in stable/9/sys: kern net netgraph netgraph/bluetooth/socket
Craig Rodrigues
rodrigc at FreeBSD.org
Sat Jul 27 05:32:28 UTC 2013
Author: rodrigc
Date: Sat Jul 27 05:32:26 2013
New Revision: 253700
URL: http://svnweb.freebsd.org/changeset/base/253700
Log:
Approved by: re (hrs, marius)
MFC 253346:
PR: 168520 170096
Submitted by: adrian, zec
Fix multiple kernel panics when VIMAGE is enabled in the kernel.
These fixes are based on patches submitted by Adrian Chadd and Marko Zec.
(1) Set curthread->td_vnet to vnet0 in device_probe_and_attach() just before calling
device_attach(). This fixes multiple VIMAGE related kernel panics
when trying to attach Bluetooth or USB Ethernet devices because
curthread->td_vnet is NULL.
(2) Set curthread->td_vnet in if_detach(). This fixes kernel panics when detaching networking
interfaces, especially USB Ethernet devices.
(3) Use VNET_DOMAIN_SET() in ng_btsocket.c
(4) In ng_unref_node() set curthread->td_vnet. This fixes kernel panics
when detaching Netgraph nodes.
Modified:
stable/9/sys/kern/subr_bus.c
stable/9/sys/net/if.c
stable/9/sys/netgraph/bluetooth/socket/ng_btsocket.c
stable/9/sys/netgraph/ng_base.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/net/ (props changed)
Modified: stable/9/sys/kern/subr_bus.c
==============================================================================
--- stable/9/sys/kern/subr_bus.c Sat Jul 27 00:53:07 2013 (r253699)
+++ stable/9/sys/kern/subr_bus.c Sat Jul 27 05:32:26 2013 (r253700)
@@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/interrupt.h>
+#include <net/vnet.h>
+
#include <machine/stdarg.h>
#include <vm/uma.h>
@@ -2727,7 +2729,11 @@ device_probe_and_attach(device_t dev)
return (0);
else if (error != 0)
return (error);
- return (device_attach(dev));
+
+ CURVNET_SET_QUIET(vnet0);
+ error = device_attach(dev);
+ CURVNET_RESTORE();
+ return error;
}
/**
Modified: stable/9/sys/net/if.c
==============================================================================
--- stable/9/sys/net/if.c Sat Jul 27 00:53:07 2013 (r253699)
+++ stable/9/sys/net/if.c Sat Jul 27 05:32:26 2013 (r253700)
@@ -509,6 +509,7 @@ if_free_type(struct ifnet *ifp, u_char t
ifp->if_flags |= IFF_DYING; /* XXX: Locking */
+ CURVNET_SET_QUIET(ifp->if_vnet);
IFNET_WLOCK();
KASSERT(ifp == ifnet_byindex_locked(ifp->if_index),
("%s: freeing unallocated ifnet", ifp->if_xname));
@@ -516,9 +517,9 @@ if_free_type(struct ifnet *ifp, u_char t
ifindex_free_locked(ifp->if_index);
IFNET_WUNLOCK();
- if (!refcount_release(&ifp->if_refcount))
- return;
- if_free_internal(ifp);
+ if (refcount_release(&ifp->if_refcount))
+ if_free_internal(ifp);
+ CURVNET_RESTORE();
}
/*
@@ -830,7 +831,9 @@ void
if_detach(struct ifnet *ifp)
{
+ CURVNET_SET_QUIET(ifp->if_vnet);
if_detach_internal(ifp, 0);
+ CURVNET_RESTORE();
}
static void
Modified: stable/9/sys/netgraph/bluetooth/socket/ng_btsocket.c
==============================================================================
--- stable/9/sys/netgraph/bluetooth/socket/ng_btsocket.c Sat Jul 27 00:53:07 2013 (r253699)
+++ stable/9/sys/netgraph/bluetooth/socket/ng_btsocket.c Sat Jul 27 05:32:26 2013 (r253700)
@@ -46,6 +46,8 @@
#include <sys/sysctl.h>
#include <sys/taskqueue.h>
+#include <net/vnet.h>
+
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
#include <netgraph/bluetooth/include/ng_bluetooth.h>
@@ -285,4 +287,4 @@ ng_btsocket_modevent(module_t mod, int e
return (error);
} /* ng_btsocket_modevent */
-DOMAIN_SET(ng_btsocket_);
+VNET_DOMAIN_SET(ng_btsocket_);
Modified: stable/9/sys/netgraph/ng_base.c
==============================================================================
--- stable/9/sys/netgraph/ng_base.c Sat Jul 27 00:53:07 2013 (r253699)
+++ stable/9/sys/netgraph/ng_base.c Sat Jul 27 05:32:26 2013 (r253700)
@@ -789,6 +789,8 @@ ng_unref_node(node_p node)
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 @@ ng_unref_node(node_p node)
mtx_destroy(&node->nd_input_queue.q_mtx);
NG_FREE_NODE(node);
}
+ CURVNET_RESTORE();
}
/************************************************************************
More information about the svn-src-stable-9
mailing list