From nobody@FreeBSD.org  Mon Nov  8 12:13:52 2010
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 5B435106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Nov 2010 12:13:52 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 4A0788FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  8 Nov 2010 12:13:52 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id oA8CDqaM068763
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 8 Nov 2010 12:13:52 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id oA8CDplp068762;
	Mon, 8 Nov 2010 12:13:52 GMT
	(envelope-from nobody)
Message-Id: <201011081213.oA8CDplp068762@www.freebsd.org>
Date: Mon, 8 Nov 2010 12:13:52 GMT
From: Anton <x86mail@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: TUN\TAP under jail with vimage crashes system
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         152047
>Category:       kern
>Synopsis:       [vimage] [panic] TUN\TAP under jail with vimage crashes system
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-virtualization
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 08 12:20:10 UTC 2010
>Closed-Date:    Sat Sep 01 17:59:58 UTC 2012
>Last-Modified:  Mon Oct 22 07:50:00 UTC 2012
>Originator:     Anton
>Release:        8.1-STABLE
>Organization:
>Environment:
FreeBSD panzer 8.1-STABLE FreeBSD 8.1-STABLE #0: Fri Nov  5 17:52:01 MSK 2010     root@panzer:/usr/obj/usr/src/sys/ACORE  amd64
>Description:
I'm trying to use client openvpn under jail with vimage. After connect openvpn try to create tap or tun interface and in that moment server halts. If i manually create tap interface it is ok, and mostly works (pings going in both sides) until i restart openvpn. In moment of stopping openvpn server halts.
>How-To-Repeat:
Create new jail with:
jail -c vnet path="/path/to/jail" name="jail_name" persist

Install world and openvpn in it.
Configure openvpn as client.
Start openvpn.
>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: bz 
State-Changed-When: Thu Nov 18 06:13:54 UTC 2010 
State-Changed-Why:  
Problem is well known. 


Responsible-Changed-From-To: freebsd-bugs->freebsd-virtualization 
Responsible-Changed-By: bz 
Responsible-Changed-When: Thu Nov 18 06:13:54 UTC 2010 
Responsible-Changed-Why:  
Re-assign to freebsd virtualization list as it's a VNET specific 
problem. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/152047: commit references a PR
Date: Thu,  7 Jun 2012 19:47:01 +0000 (UTC)

 Author: trociny
 Date: Thu Jun  7 19:46:46 2012
 New Revision: 236724
 URL: http://svn.freebsd.org/changeset/base/236724
 
 Log:
   Add VIMAGE support to if_tap.
   
   PR:		kern/152047, kern/158686
   Submitted by:	Daan Vreeken <pa4dan Bliksem.VEHosting.nl>
   MFC after:	1 week
 
 Modified:
   head/sys/net/if_tap.c
 
 Modified: head/sys/net/if_tap.c
 ==============================================================================
 --- head/sys/net/if_tap.c	Thu Jun  7 19:19:12 2012	(r236723)
 +++ head/sys/net/if_tap.c	Thu Jun  7 19:46:46 2012	(r236724)
 @@ -42,6 +42,7 @@
  #include <sys/conf.h>
  #include <sys/fcntl.h>
  #include <sys/filio.h>
 +#include <sys/jail.h>
  #include <sys/kernel.h>
  #include <sys/malloc.h>
  #include <sys/mbuf.h>
 @@ -66,6 +67,7 @@
  #include <net/if_dl.h>
  #include <net/route.h>
  #include <net/if_types.h>
 +#include <net/vnet.h>
  
  #include <netinet/in.h>
  
 @@ -214,6 +216,7 @@ tap_destroy(struct tap_softc *tp)
  	KASSERT(!(tp->tap_flags & TAP_OPEN),
  		("%s flags is out of sync", ifp->if_xname));
  
 +	CURVNET_SET(ifp->if_vnet);
  	seldrain(&tp->tap_rsel);
  	knlist_destroy(&tp->tap_rsel.si_note);
  	destroy_dev(tp->tap_dev);
 @@ -222,6 +225,7 @@ tap_destroy(struct tap_softc *tp)
  
  	mtx_destroy(&tp->tap_mtx);
  	free(tp, M_TAP);
 +	CURVNET_RESTORE();
  }
  
  static void
 @@ -363,6 +367,7 @@ tapclone(void *arg, struct ucred *cred, 
  	if (unit == -1)
  		append_unit = 1;
  
 +	CURVNET_SET(CRED_TO_VNET(cred));
  	/* find any existing device, or allocate new unit number */
  	i = clone_create(&tapclones, &tap_cdevsw, &unit, dev, extra);
  	if (i) {
 @@ -381,6 +386,7 @@ tapclone(void *arg, struct ucred *cred, 
  	}
  
  	if_clone_create(name, namelen, NULL);
 +	CURVNET_RESTORE();
  } /* tapclone */
  
  
 @@ -521,6 +527,7 @@ tapclose(struct cdev *dev, int foo, int 
  
  	/* junk all pending output */
  	mtx_lock(&tp->tap_mtx);
 +	CURVNET_SET(ifp->if_vnet);
  	IF_DRAIN(&ifp->if_snd);
  
  	/*
 @@ -544,6 +551,8 @@ tapclose(struct cdev *dev, int foo, int 
  	}
  
  	if_link_state_change(ifp, LINK_STATE_DOWN);
 +	CURVNET_RESTORE();
 +
  	funsetown(&tp->tap_sigio);
  	selwakeuppri(&tp->tap_rsel, PZERO+1);
  	KNOTE_LOCKED(&tp->tap_rsel.si_note, 0);
 @@ -945,7 +954,9 @@ tapwrite(struct cdev *dev, struct uio *u
  	}
  
  	/* Pass packet up to parent. */
 +	CURVNET_SET(ifp->if_vnet);
  	(*ifp->if_input)(ifp, m);
 +	CURVNET_RESTORE();
  	ifp->if_ipackets ++; /* ibytes are counted in parent */
  
  	return (0);
 _______________________________________________
 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/152047: commit references a PR
Date: Fri, 15 Jun 2012 20:25:54 +0000 (UTC)

 Author: trociny
 Date: Fri Jun 15 20:25:44 2012
 New Revision: 237144
 URL: http://svn.freebsd.org/changeset/base/237144
 
 Log:
   MFC 236724, 236725:
   
   MFC 236724:
   
   Add VIMAGE support to if_tap.
   
   PR:		kern/152047, kern/158686
   Submitted by:	Daan Vreeken <pa4dan Bliksem.VEHosting.nl>
   
   MFC 236725:
   
   Sort includes.
   
   Submitted by:	Daan Vreeken <pa4dan Bliksem.VEHosting.nl>
 
 Modified:
   stable/9/sys/net/if_tap.c
 Directory Properties:
   stable/9/sys/   (props changed)
 
 Modified: stable/9/sys/net/if_tap.c
 ==============================================================================
 --- stable/9/sys/net/if_tap.c	Fri Jun 15 20:08:13 2012	(r237143)
 +++ stable/9/sys/net/if_tap.c	Fri Jun 15 20:25:44 2012	(r237144)
 @@ -42,6 +42,7 @@
  #include <sys/conf.h>
  #include <sys/fcntl.h>
  #include <sys/filio.h>
 +#include <sys/jail.h>
  #include <sys/kernel.h>
  #include <sys/malloc.h>
  #include <sys/mbuf.h>
 @@ -64,8 +65,9 @@
  #include <net/if.h>
  #include <net/if_clone.h>
  #include <net/if_dl.h>
 -#include <net/route.h>
  #include <net/if_types.h>
 +#include <net/route.h>
 +#include <net/vnet.h>
  
  #include <netinet/in.h>
  
 @@ -214,6 +216,7 @@ tap_destroy(struct tap_softc *tp)
  	KASSERT(!(tp->tap_flags & TAP_OPEN),
  		("%s flags is out of sync", ifp->if_xname));
  
 +	CURVNET_SET(ifp->if_vnet);
  	seldrain(&tp->tap_rsel);
  	knlist_destroy(&tp->tap_rsel.si_note);
  	destroy_dev(tp->tap_dev);
 @@ -222,6 +225,7 @@ tap_destroy(struct tap_softc *tp)
  
  	mtx_destroy(&tp->tap_mtx);
  	free(tp, M_TAP);
 +	CURVNET_RESTORE();
  }
  
  static void
 @@ -363,6 +367,7 @@ tapclone(void *arg, struct ucred *cred, 
  	if (unit == -1)
  		append_unit = 1;
  
 +	CURVNET_SET(CRED_TO_VNET(cred));
  	/* find any existing device, or allocate new unit number */
  	i = clone_create(&tapclones, &tap_cdevsw, &unit, dev, extra);
  	if (i) {
 @@ -381,6 +386,7 @@ tapclone(void *arg, struct ucred *cred, 
  	}
  
  	if_clone_create(name, namelen, NULL);
 +	CURVNET_RESTORE();
  } /* tapclone */
  
  
 @@ -521,6 +527,7 @@ tapclose(struct cdev *dev, int foo, int 
  
  	/* junk all pending output */
  	mtx_lock(&tp->tap_mtx);
 +	CURVNET_SET(ifp->if_vnet);
  	IF_DRAIN(&ifp->if_snd);
  
  	/*
 @@ -544,6 +551,8 @@ tapclose(struct cdev *dev, int foo, int 
  	}
  
  	if_link_state_change(ifp, LINK_STATE_DOWN);
 +	CURVNET_RESTORE();
 +
  	funsetown(&tp->tap_sigio);
  	selwakeuppri(&tp->tap_rsel, PZERO+1);
  	KNOTE_LOCKED(&tp->tap_rsel.si_note, 0);
 @@ -945,7 +954,9 @@ tapwrite(struct cdev *dev, struct uio *u
  	}
  
  	/* Pass packet up to parent. */
 +	CURVNET_SET(ifp->if_vnet);
  	(*ifp->if_input)(ifp, m);
 +	CURVNET_RESTORE();
  	ifp->if_ipackets ++; /* ibytes are counted in parent */
  
  	return (0);
 _______________________________________________
 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/152047: commit references a PR
Date: Fri, 15 Jun 2012 20:27:30 +0000 (UTC)

 Author: trociny
 Date: Fri Jun 15 20:27:15 2012
 New Revision: 237145
 URL: http://svn.freebsd.org/changeset/base/237145
 
 Log:
   MFC 236724, 236725:
   
   MFC 236724:
   
   Add VIMAGE support to if_tap.
   
   PR:		kern/152047, kern/158686
   Submitted by:	Daan Vreeken <pa4dan Bliksem.VEHosting.nl>
   
   MFC 236725:
   
   Sort includes.
   
   Submitted by:	Daan Vreeken <pa4dan Bliksem.VEHosting.nl>
 
 Modified:
   stable/8/sys/net/if_tap.c
 Directory Properties:
   stable/8/sys/   (props changed)
 
 Modified: stable/8/sys/net/if_tap.c
 ==============================================================================
 --- stable/8/sys/net/if_tap.c	Fri Jun 15 20:25:44 2012	(r237144)
 +++ stable/8/sys/net/if_tap.c	Fri Jun 15 20:27:15 2012	(r237145)
 @@ -42,6 +42,7 @@
  #include <sys/conf.h>
  #include <sys/fcntl.h>
  #include <sys/filio.h>
 +#include <sys/jail.h>
  #include <sys/kernel.h>
  #include <sys/malloc.h>
  #include <sys/mbuf.h>
 @@ -64,8 +65,9 @@
  #include <net/if.h>
  #include <net/if_clone.h>
  #include <net/if_dl.h>
 -#include <net/route.h>
  #include <net/if_types.h>
 +#include <net/route.h>
 +#include <net/vnet.h>
  
  #include <netinet/in.h>
  
 @@ -214,6 +216,7 @@ tap_destroy(struct tap_softc *tp)
  	KASSERT(!(tp->tap_flags & TAP_OPEN),
  		("%s flags is out of sync", ifp->if_xname));
  
 +	CURVNET_SET(ifp->if_vnet);
  	seldrain(&tp->tap_rsel);
  	knlist_destroy(&tp->tap_rsel.si_note);
  	destroy_dev(tp->tap_dev);
 @@ -222,6 +225,7 @@ tap_destroy(struct tap_softc *tp)
  
  	mtx_destroy(&tp->tap_mtx);
  	free(tp, M_TAP);
 +	CURVNET_RESTORE();
  }
  
  static void
 @@ -363,6 +367,7 @@ tapclone(void *arg, struct ucred *cred, 
  	if (unit == -1)
  		append_unit = 1;
  
 +	CURVNET_SET(CRED_TO_VNET(cred));
  	/* find any existing device, or allocate new unit number */
  	i = clone_create(&tapclones, &tap_cdevsw, &unit, dev, extra);
  	if (i) {
 @@ -381,6 +386,7 @@ tapclone(void *arg, struct ucred *cred, 
  	}
  
  	if_clone_create(name, namelen, NULL);
 +	CURVNET_RESTORE();
  } /* tapclone */
  
  
 @@ -521,6 +527,7 @@ tapclose(struct cdev *dev, int foo, int 
  
  	/* junk all pending output */
  	mtx_lock(&tp->tap_mtx);
 +	CURVNET_SET(ifp->if_vnet);
  	IF_DRAIN(&ifp->if_snd);
  
  	/*
 @@ -544,6 +551,8 @@ tapclose(struct cdev *dev, int foo, int 
  	}
  
  	if_link_state_change(ifp, LINK_STATE_DOWN);
 +	CURVNET_RESTORE();
 +
  	funsetown(&tp->tap_sigio);
  	selwakeuppri(&tp->tap_rsel, PZERO+1);
  	KNOTE_LOCKED(&tp->tap_rsel.si_note, 0);
 @@ -945,7 +954,9 @@ tapwrite(struct cdev *dev, struct uio *u
  	}
  
  	/* Pass packet up to parent. */
 +	CURVNET_SET(ifp->if_vnet);
  	(*ifp->if_input)(ifp, m);
 +	CURVNET_RESTORE();
  	ifp->if_ipackets ++; /* ibytes are counted in parent */
  
  	return (0);
 _______________________________________________
 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: analyzed->feedback 
State-Changed-By: trociny 
State-Changed-When: Sat Jun 16 06:56:13 UTC 2012 
State-Changed-Why:  
Asking the reporter to check on a recent system. 

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

From: Mikolaj Golub <trociny@freebsd.org>
To: Anton <x86mail@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/152047: [vimage] [panic] TUN\TAP under jail with vimage crashes system
Date: Sat, 16 Jun 2012 09:54:39 +0300

 Hi, Anton,
 
 I just have merged VIMAGE support for tap to STABLE branches. Could you please
 try a recent kernel to see if it has fixed the issues for you.
 
 -- 
 Mikolaj Golub
State-Changed-From-To: feedback->closed 
State-Changed-By: trociny 
State-Changed-When: Sat Sep 1 17:58:19 UTC 2012 
State-Changed-Why:  
No feedback from the originator. The problem is beleived to be fixed.  

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

From: =?ISO-8859-1?Q?Jean-S=E9bastien_P=E9dron?= <dumbbell@FreeBSD.org>
To: bug-followup@FreeBSD.org, x86mail@gmail.com
Cc:  
Subject: Re: kern/152047: [vimage] [panic] TUN\TAP under jail with vimage
 crashes system
Date: Mon, 22 Oct 2012 09:45:29 +0200

 I applied the patch to FreeNAS 8.3.0 RC1, based on FreeBSD
 8.3-RELEASE-p4 and this fixes the problem for me.
 
 Thank you!
 
 -- 
 Jean-Sbastien Pdron
>Unformatted:
