From nobody@FreeBSD.org  Fri Jun  1 10:16:25 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 522FF106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  1 Jun 2012 10:16:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 250BA8FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  1 Jun 2012 10:16:25 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q51AGOca089229
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 1 Jun 2012 10:16:24 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q51AGOqP089211;
	Fri, 1 Jun 2012 10:16:24 GMT
	(envelope-from nobody)
Message-Id: <201206011016.q51AGOqP089211@red.freebsd.org>
Date: Fri, 1 Jun 2012 10:16:24 GMT
From: "YAMAMOTO, Shigeru" <shigeru@iij.ad.jp>
To: freebsd-gnats-submit@FreeBSD.org
Subject: "option VIMAGE" kernel with ng_ubt.ko cause kernel panic
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         168520
>Category:       kern
>Synopsis:       [ng_ubt] [patch] "option VIMAGE" kernel with ng_ubt.ko cause kernel panic
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    rodrigc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 01 10:20:01 UTC 2012
>Closed-Date:    Tue Oct 15 18:45:55 PDT 2013
>Last-Modified:  Tue Oct 15 18:45:55 PDT 2013
>Originator:     YAMAMOTO, Shigeru
>Release:        FreeBSD 9.0-release and 10-current
>Organization:
Internet Initiative Japan Inc.
>Environment:
FreeBSD venus.tokyo.iiji.jp 10.0-CURRENT FreeBSD 10.0-CURRENT #0 r236371M: Fri Jun  1 12:57:18 JST 2012     root@venus.tokyo.iiji.jp:/usr/obj/usr/src/sys/VENUS  amd64

>Description:
@src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c is not changed to support VNET().

It cause kernel panic, when booting "option VIMAGE" kernel.

>How-To-Repeat:
1. boot "option VIMAGE" kernel
2. kldload ng_ubt
3. insert USB Bluetooth Adapter
4. panic!

>Fix:
In @src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c, ng_make_node_common() is called, but nb_ubt.c does not change to support VNET().

I do quick hack to fix it, and make a small patch.


Patch attached with submission follows:

Index: sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
===================================================================
--- sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	(ӥ 235569)
+++ sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	(ȥԡ)
@@ -111,6 +111,11 @@
 #include <sys/malloc.h>
 #include <sys/priv.h>
 
+#include <sys/proc.h>
+#include <sys/ucred.h>
+#include <sys/jail.h>
+#include <net/vnet.h>
+
 #include "usbdevs.h"
 #include <dev/usb/usb.h>
 #include <dev/usb/usbdi.h>
@@ -452,8 +457,11 @@
 	 * Create Netgraph node
 	 */
 
+	CURVNET_SET(TD_TO_VNET(curthread));
+
 	if (ng_make_node_common(&typestruct, &sc->sc_node) != 0) {
 		UBT_ALERT(sc, "could not create Netgraph node\n");
+		CURVNET_RESTORE();
 		return (ENXIO);
 	}
 
@@ -461,6 +469,7 @@
 	if (ng_name_node(sc->sc_node, device_get_nameunit(dev)) != 0) {
 		UBT_ALERT(sc, "could not name Netgraph node\n");
 		NG_NODE_UNREF(sc->sc_node);
+		CURVNET_RESTORE();
 		return (ENXIO);
 	}
 	NG_NODE_SET_PRIVATE(sc->sc_node, sc);
@@ -558,9 +567,13 @@
 	for (i = 1; usbd_get_iface(uaa->device, i) != NULL; i ++)
 		usbd_set_parent_iface(uaa->device, i, uaa->info.bIfaceIndex);
 
+	CURVNET_RESTORE();
+
 	return (0); /* success */
 
 detach:
+	CURVNET_RESTORE();
+
 	ubt_detach(dev);
 
 	return (ENXIO);
@@ -577,6 +590,8 @@
 	struct ubt_softc	*sc = device_get_softc(dev);
 	node_p			node = sc->sc_node;
 
+	CURVNET_SET(TD_TO_VNET(curthread));
+
 	/* Destroy Netgraph node */
 	if (node != NULL) {
 		sc->sc_node = NULL;
@@ -600,6 +615,8 @@
 	mtx_destroy(&sc->sc_if_mtx);
 	mtx_destroy(&sc->sc_ng_mtx);
 
+	CURVNET_RESTORE();
+
 	return (0);
 } /* ubt_detach */
 


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->rodrigc 
Responsible-Changed-By: rodrigc 
Responsible-Changed-When: Fri Jul 12 00:56:25 PDT 2013 
Responsible-Changed-Why:  
. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168520 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/168520: commit references a PR
Date: Fri, 12 Jul 2013 08:03:22 +0000 (UTC)

 Author: rodrigc
 Date: Fri Jul 12 08:03:10 2013
 New Revision: 253255
 URL: http://svnweb.freebsd.org/changeset/base/253255
 
 Log:
   PR: kern/168520
   Submitted by: "YAMAMOTO, Shigeru" <shigeru@iij.ad.jp>
   Reviewed by: adrian
   
   In PC-BSD 9.1, VIMAGE is enabled in the kernel config.
   For laptops with Bluetooth capability, such as the HP Elitebook 8460p,
   the kernel will panic upon bootup, because curthread->td_vnet
   is not initialized.
   
   Properly initialize curthread->td_vnet when initializing the Bluetooth stack.
   
   This allows laptops such as the HP Elitebook 8460p laptop
   to properly boot with VIMAGE kernels.
 
 Modified:
   head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
 
 Modified: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
 ==============================================================================
 --- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	Fri Jul 12 07:43:56 2013	(r253254)
 +++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	Fri Jul 12 08:03:10 2013	(r253255)
 @@ -109,7 +109,9 @@
  #include <sys/unistd.h>
  #include <sys/callout.h>
  #include <sys/malloc.h>
 +#include <sys/jail.h>
  #include <sys/priv.h>
 +#include <sys/proc.h>
  
  #include "usbdevs.h"
  #include <dev/usb/usb.h>
 @@ -123,6 +125,7 @@
  #include <sys/mbuf.h>
  #include <sys/taskqueue.h>
  
 +#include <net/vnet.h>
  #include <netgraph/ng_message.h>
  #include <netgraph/netgraph.h>
  #include <netgraph/ng_parse.h>
 @@ -487,13 +490,14 @@ ubt_attach(device_t dev)
  
  	sc->sc_dev = dev;
  	sc->sc_debug = NG_UBT_WARN_LEVEL;
 -
 +	CURVNET_SET(TD_TO_VNET(curthread));
  	/* 
  	 * Create Netgraph node
  	 */
  
  	if (ng_make_node_common(&typestruct, &sc->sc_node) != 0) {
  		UBT_ALERT(sc, "could not create Netgraph node\n");
 +		CURVNET_RESTORE();
  		return (ENXIO);
  	}
  
 @@ -501,10 +505,12 @@ ubt_attach(device_t dev)
  	if (ng_name_node(sc->sc_node, device_get_nameunit(dev)) != 0) {
  		UBT_ALERT(sc, "could not name Netgraph node\n");
  		NG_NODE_UNREF(sc->sc_node);
 +		CURVNET_RESTORE();
  		return (ENXIO);
  	}
  	NG_NODE_SET_PRIVATE(sc->sc_node, sc);
  	NG_NODE_FORCE_WRITER(sc->sc_node);
 +	CURVNET_RESTORE();
  
  	/*
  	 * Initialize device softc structure
 @@ -631,8 +637,10 @@ ubt_detach(device_t dev)
  	/* Destroy Netgraph node */
  	if (node != NULL) {
  		sc->sc_node = NULL;
 +		CURVNET_SET(node->nd_vnet);
  		NG_NODE_REALLY_DIE(node);
  		ng_rmnode_self(node);
 +		CURVNET_RESTORE();
  	}
  
  	/* Make sure ubt_task in gone */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: rodrigc 
State-Changed-When: Fri Jul 12 01:26:55 PDT 2013 
State-Changed-Why:  
. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168520 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/168520: commit references a PR
Date: Mon, 15 Jul 2013 01:33:03 +0000 (UTC)

 Author: rodrigc
 Date: Mon Jul 15 01:32:55 2013
 New Revision: 253346
 URL: http://svnweb.freebsd.org/changeset/base/253346
 
 Log:
   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:
   head/sys/kern/subr_bus.c
   head/sys/net/if.c
   head/sys/netgraph/bluetooth/socket/ng_btsocket.c
   head/sys/netgraph/ng_base.c
 
 Modified: head/sys/kern/subr_bus.c
 ==============================================================================
 --- head/sys/kern/subr_bus.c	Mon Jul 15 00:49:10 2013	(r253345)
 +++ head/sys/kern/subr_bus.c	Mon Jul 15 01:32:55 2013	(r253346)
 @@ -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>
 @@ -2735,7 +2737,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: head/sys/net/if.c
 ==============================================================================
 --- head/sys/net/if.c	Mon Jul 15 00:49:10 2013	(r253345)
 +++ head/sys/net/if.c	Mon Jul 15 01:32:55 2013	(r253346)
 @@ -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
 
 Modified: head/sys/netgraph/bluetooth/socket/ng_btsocket.c
 ==============================================================================
 --- head/sys/netgraph/bluetooth/socket/ng_btsocket.c	Mon Jul 15 00:49:10 2013	(r253345)
 +++ head/sys/netgraph/bluetooth/socket/ng_btsocket.c	Mon Jul 15 01:32:55 2013	(r253346)
 @@ -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: head/sys/netgraph/ng_base.c
 ==============================================================================
 --- head/sys/netgraph/ng_base.c	Mon Jul 15 00:49:10 2013	(r253345)
 +++ head/sys/netgraph/ng_base.c	Mon Jul 15 01:32:55 2013	(r253346)
 @@ -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();
  }
  
  /************************************************************************
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/168520: commit references a PR
Date: Mon, 15 Jul 2013 01:41:42 +0000 (UTC)

 Author: rodrigc
 Date: Mon Jul 15 01:41:34 2013
 New Revision: 253347
 URL: http://svnweb.freebsd.org/changeset/base/253347
 
 Log:
   PR: kern/168520
   
   Revert GRN 253255.  It is not needed now that GRN 253346 is committed.
 
 Modified:
   head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
 
 Modified: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
 ==============================================================================
 --- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	Mon Jul 15 01:32:55 2013	(r253346)
 +++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	Mon Jul 15 01:41:34 2013	(r253347)
 @@ -109,9 +109,7 @@
  #include <sys/unistd.h>
  #include <sys/callout.h>
  #include <sys/malloc.h>
 -#include <sys/jail.h>
  #include <sys/priv.h>
 -#include <sys/proc.h>
  
  #include "usbdevs.h"
  #include <dev/usb/usb.h>
 @@ -125,7 +123,6 @@
  #include <sys/mbuf.h>
  #include <sys/taskqueue.h>
  
 -#include <net/vnet.h>
  #include <netgraph/ng_message.h>
  #include <netgraph/netgraph.h>
  #include <netgraph/ng_parse.h>
 @@ -490,14 +487,13 @@ ubt_attach(device_t dev)
  
  	sc->sc_dev = dev;
  	sc->sc_debug = NG_UBT_WARN_LEVEL;
 -	CURVNET_SET(TD_TO_VNET(curthread));
 +
  	/* 
  	 * Create Netgraph node
  	 */
  
  	if (ng_make_node_common(&typestruct, &sc->sc_node) != 0) {
  		UBT_ALERT(sc, "could not create Netgraph node\n");
 -		CURVNET_RESTORE();
  		return (ENXIO);
  	}
  
 @@ -505,12 +501,10 @@ ubt_attach(device_t dev)
  	if (ng_name_node(sc->sc_node, device_get_nameunit(dev)) != 0) {
  		UBT_ALERT(sc, "could not name Netgraph node\n");
  		NG_NODE_UNREF(sc->sc_node);
 -		CURVNET_RESTORE();
  		return (ENXIO);
  	}
  	NG_NODE_SET_PRIVATE(sc->sc_node, sc);
  	NG_NODE_FORCE_WRITER(sc->sc_node);
 -	CURVNET_RESTORE();
  
  	/*
  	 * Initialize device softc structure
 @@ -637,10 +631,8 @@ ubt_detach(device_t dev)
  	/* Destroy Netgraph node */
  	if (node != NULL) {
  		sc->sc_node = NULL;
 -		CURVNET_SET(node->nd_vnet);
  		NG_NODE_REALLY_DIE(node);
  		ng_rmnode_self(node);
 -		CURVNET_RESTORE();
  	}
  
  	/* Make sure ubt_task in gone */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/168520: commit references a PR
Date: Mon, 15 Jul 2013 01:41:42 +0000 (UTC)

 Author: rodrigc
 Date: Mon Jul 15 01:41:34 2013
 New Revision: 253347
 URL: http://svnweb.freebsd.org/changeset/base/253347
 
 Log:
   PR: kern/168520
   
   Revert GRN 253255.  It is not needed now that GRN 253346 is committed.
 
 Modified:
   head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
 
 Modified: head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
 ==============================================================================
 --- head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	Mon Jul 15 01:32:55 2013	(r253346)
 +++ head/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c	Mon Jul 15 01:41:34 2013	(r253347)
 @@ -109,9 +109,7 @@
  #include <sys/unistd.h>
  #include <sys/callout.h>
  #include <sys/malloc.h>
 -#include <sys/jail.h>
  #include <sys/priv.h>
 -#include <sys/proc.h>
  
  #include "usbdevs.h"
  #include <dev/usb/usb.h>
 @@ -125,7 +123,6 @@
  #include <sys/mbuf.h>
  #include <sys/taskqueue.h>
  
 -#include <net/vnet.h>
  #include <netgraph/ng_message.h>
  #include <netgraph/netgraph.h>
  #include <netgraph/ng_parse.h>
 @@ -490,14 +487,13 @@ ubt_attach(device_t dev)
  
  	sc->sc_dev = dev;
  	sc->sc_debug = NG_UBT_WARN_LEVEL;
 -	CURVNET_SET(TD_TO_VNET(curthread));
 +
  	/* 
  	 * Create Netgraph node
  	 */
  
  	if (ng_make_node_common(&typestruct, &sc->sc_node) != 0) {
  		UBT_ALERT(sc, "could not create Netgraph node\n");
 -		CURVNET_RESTORE();
  		return (ENXIO);
  	}
  
 @@ -505,12 +501,10 @@ ubt_attach(device_t dev)
  	if (ng_name_node(sc->sc_node, device_get_nameunit(dev)) != 0) {
  		UBT_ALERT(sc, "could not name Netgraph node\n");
  		NG_NODE_UNREF(sc->sc_node);
 -		CURVNET_RESTORE();
  		return (ENXIO);
  	}
  	NG_NODE_SET_PRIVATE(sc->sc_node, sc);
  	NG_NODE_FORCE_WRITER(sc->sc_node);
 -	CURVNET_RESTORE();
  
  	/*
  	 * Initialize device softc structure
 @@ -637,10 +631,8 @@ ubt_detach(device_t dev)
  	/* Destroy Netgraph node */
  	if (node != NULL) {
  		sc->sc_node = NULL;
 -		CURVNET_SET(node->nd_vnet);
  		NG_NODE_REALLY_DIE(node);
  		ng_rmnode_self(node);
 -		CURVNET_RESTORE();
  	}
  
  	/* Make sure ubt_task in gone */
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/168520: commit references a PR
Date: Sat, 27 Jul 2013 05:32:45 +0000 (UTC)

 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();
  }
  
  /************************************************************************
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: rodrigc 
State-Changed-When: Tue Oct 15 18:44:59 PDT 2013 
State-Changed-Why:  
Fixed in FreeBSD 9.2 

http://www.freebsd.org/cgi/query-pr.cgi?pr=168520 
>Unformatted:
