diff options
author | rodrigc <rodrigc@FreeBSD.org> | 2013-07-15 01:32:55 +0000 |
---|---|---|
committer | rodrigc <rodrigc@FreeBSD.org> | 2013-07-15 01:32:55 +0000 |
commit | 7e3e1747c886c2c26003f94ad0e7dd03ea6cde2a (patch) | |
tree | 07b12ddaa4af38870ab0290b71afcba393c21913 /sys/net/if.c | |
parent | 2bfbfc539c4069e052503398bf33ced4b1e83959 (diff) | |
download | FreeBSD-src-7e3e1747c886c2c26003f94ad0e7dd03ea6cde2a.zip FreeBSD-src-7e3e1747c886c2c26003f94ad0e7dd03ea6cde2a.tar.gz |
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.
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index 326860d..2cb3da0 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -505,6 +505,7 @@ if_free(struct ifnet *ifp) 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)); @@ -512,9 +513,9 @@ if_free(struct ifnet *ifp) 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(); } /* @@ -803,7 +804,9 @@ void if_detach(struct ifnet *ifp) { + CURVNET_SET_QUIET(ifp->if_vnet); if_detach_internal(ifp, 0); + CURVNET_RESTORE(); } static void |