Index: lib/libkvm/kvm_vnet.c
===================================================================
--- lib/libkvm/kvm_vnet.c	(revision 196012)
+++ lib/libkvm/kvm_vnet.c	(working copy)
@@ -40,7 +40,6 @@
 #include <sys/jail.h>
 #include <sys/proc.h>
 #include <sys/types.h>
-#include <sys/vimage.h>
 
 #include <net/vnet.h>
 
Index: ObsoleteFiles.inc
===================================================================
--- ObsoleteFiles.inc	(revision 196012)
+++ ObsoleteFiles.inc	(working copy)
@@ -14,6 +14,8 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20090801: vimage.h removed in favour of vnet.h
+OLD_FILES+=usr/include/sys/vimage.h
 # 20090719: library version bump for 8.0
 OLD_LIBS+=lib/libalias.so.6
 OLD_LIBS+=lib/libavl.so.1
Index: sys/arm/arm/minidump_machdep.c
===================================================================
--- sys/arm/arm/minidump_machdep.c	(revision 196012)
+++ sys/arm/arm/minidump_machdep.c	(working copy)
@@ -36,7 +36,6 @@
 #include <sys/kernel.h>
 #include <sys/kerneldump.h>
 #include <sys/msgbuf.h>
-#include <sys/vimage.h>
 #include <vm/vm.h>
 #include <vm/pmap.h>
 #include <machine/pmap.h>
Index: sys/conf/files
===================================================================
--- sys/conf/files	(revision 196012)
+++ sys/conf/files	(working copy)
@@ -1992,7 +1992,6 @@
 kern/kern_timeout.c		standard
 kern/kern_umtx.c		standard
 kern/kern_uuid.c		standard
-kern/kern_vimage.c		optional vimage
 kern/kern_xxx.c			standard
 kern/link_elf.c			standard
 kern/linker_if.m		standard
Index: sys/nfsclient/nfs_vnops.c
===================================================================
--- sys/nfsclient/nfs_vnops.c	(revision 196012)
+++ sys/nfsclient/nfs_vnops.c	(working copy)
@@ -61,7 +61,6 @@
 #include <sys/stat.h>
 #include <sys/sysctl.h>
 #include <sys/signalvar.h>
-#include <sys/vimage.h>
 
 #include <vm/vm.h>
 #include <vm/vm_object.h>
Index: sys/nfsclient/bootp_subr.c
===================================================================
--- sys/nfsclient/bootp_subr.c	(revision 196012)
+++ sys/nfsclient/bootp_subr.c	(working copy)
@@ -58,7 +58,6 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/uio.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/nfsclient/nfs_diskless.c
===================================================================
--- sys/nfsclient/nfs_diskless.c	(revision 196012)
+++ sys/nfsclient/nfs_diskless.c	(working copy)
@@ -43,7 +43,6 @@
 #include <sys/malloc.h>
 #include <sys/mount.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/kern/kern_jail.c
===================================================================
--- sys/kern/kern_jail.c	(revision 196012)
+++ sys/kern/kern_jail.c	(working copy)
@@ -58,9 +58,12 @@
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
 #include <sys/vnode.h>
-#include <sys/vimage.h>
+
 #include <net/if.h>
+#include <net/vnet.h>
+
 #include <netinet/in.h>
+
 #ifdef DDB
 #include <ddb/ddb.h>
 #ifdef INET6
Index: sys/kern/uipc_syscalls.c
===================================================================
--- sys/kern/uipc_syscalls.c	(revision 196012)
+++ sys/kern/uipc_syscalls.c	(working copy)
@@ -64,12 +64,13 @@
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
 #include <sys/uio.h>
-#include <sys/vimage.h>
 #include <sys/vnode.h>
 #ifdef KTRACE
 #include <sys/ktrace.h>
 #endif
 
+#include <net/vnet.h>
+
 #include <security/audit/audit.h>
 #include <security/mac/mac_framework.h>
 
Index: sys/kern/uipc_usrreq.c
===================================================================
--- sys/kern/uipc_usrreq.c	(revision 196012)
+++ sys/kern/uipc_usrreq.c	(working copy)
@@ -88,8 +88,9 @@
 #include <sys/un.h>
 #include <sys/unpcb.h>
 #include <sys/vnode.h>
-#include <sys/vimage.h>
 
+#include <net/vnet.h>
+
 #ifdef DDB
 #include <ddb/ddb.h>
 #endif
Index: sys/kern/uipc_socket.c
===================================================================
--- sys/kern/uipc_socket.c	(revision 196012)
+++ sys/kern/uipc_socket.c	(working copy)
@@ -129,8 +129,9 @@
 #include <sys/sysctl.h>
 #include <sys/uio.h>
 #include <sys/jail.h>
-#include <sys/vimage.h>
 
+#include <net/vnet.h>
+
 #include <security/mac/mac_framework.h>
 
 #include <vm/uma.h>
Index: sys/kern/uipc_domain.c
===================================================================
--- sys/kern/uipc_domain.c	(revision 196012)
+++ sys/kern/uipc_domain.c	(working copy)
@@ -43,7 +43,9 @@
 #include <sys/mutex.h>
 #include <sys/socketvar.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
+
+#include <net/vnet.h>
+
 #include <vm/uma.h>
 
 /*
Index: sys/kern/kern_linker.c
===================================================================
--- sys/kern/kern_linker.c	(revision 196012)
+++ sys/kern/kern_linker.c	(working copy)
@@ -51,8 +51,9 @@
 #include <sys/vnode.h>
 #include <sys/syscallsubr.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
+#include <net/vnet.h>
+
 #include <security/mac/mac_framework.h>
 
 #include "linker_if.h"
Index: sys/kern/sys_socket.c
===================================================================
--- sys/kern/sys_socket.c	(revision 196012)
+++ sys/kern/sys_socket.c	(working copy)
@@ -48,10 +48,10 @@
 #include <sys/stat.h>
 #include <sys/uio.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <security/mac/mac_framework.h>
 
Index: sys/kern/kern_sysctl.c
===================================================================
--- sys/kern/kern_sysctl.c	(revision 196012)
+++ sys/kern/kern_sysctl.c	(working copy)
@@ -54,7 +54,6 @@
 #include <sys/sx.h>
 #include <sys/sysproto.h>
 #include <sys/uio.h>
-#include <sys/vimage.h>
 #ifdef KTRACE
 #include <sys/ktrace.h>
 #endif
Index: sys/kern/kern_uuid.c
===================================================================
--- sys/kern/kern_uuid.c	(revision 196012)
+++ sys/kern/kern_uuid.c	(working copy)
@@ -37,7 +37,6 @@
 #include <sys/sysproto.h>
 #include <sys/systm.h>
 #include <sys/uuid.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/kern/kern_poll.c
===================================================================
--- sys/kern/kern_poll.c	(revision 196012)
+++ sys/kern/kern_poll.c	(working copy)
@@ -41,7 +41,6 @@
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>			/* for IFF_* flags		*/
 #include <net/netisr.h>			/* for NETISR_POLL		*/
Index: sys/kern/kern_vimage.c
===================================================================
--- sys/kern/kern_vimage.c	(revision 196012)
+++ sys/kern/kern_vimage.c	(working copy)
@@ -1,186 +0,0 @@
-/*-
- * Copyright (c) 2004-2009 University of Zagreb
- * Copyright (c) 2006-2009 FreeBSD Foundation
- *
- * This software was developed by the University of Zagreb and the
- * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
- * FreeBSD Foundation.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "opt_ddb.h"
-
-#include <sys/param.h>
-#include <sys/jail.h>
-#include <sys/kernel.h>
-#include <sys/lock.h>
-#include <sys/malloc.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sx.h>
-#include <sys/vimage.h>
-#ifdef DDB
-#include <ddb/ddb.h>
-#endif
-
-#include <net/if.h>
-#include <net/route.h>
-#include <net/vnet.h>
-
-MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
-
-struct rwlock		vnet_rwlock;
-struct sx		vnet_sxlock;
-
-#define	VNET_LIST_WLOCK() do {						\
-	sx_xlock(&vnet_sxlock);						\
-	rw_wlock(&vnet_rwlock);						\
-} while (0)
-
-#define	VNET_LIST_WUNLOCK() do {					\
-	rw_wunlock(&vnet_rwlock);					\
-	sx_xunlock(&vnet_sxlock);					\
-} while (0)
-
-struct vnet_list_head vnet_head;
-struct vnet *vnet0;
-
-
-struct vnet *
-vnet_alloc(void)
-{
-	struct vnet *vnet;
-
-	vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO);
-	vnet->vnet_magic_n = VNET_MAGIC_N;
-	vnet_data_init(vnet);
-
-	/* Initialize / attach vnet module instances. */
-	CURVNET_SET_QUIET(vnet);
-
-	sx_xlock(&vnet_sxlock);
-	vnet_sysinit();
-	CURVNET_RESTORE();
-
-	rw_wlock(&vnet_rwlock);
-	LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
-	VNET_LIST_WUNLOCK();
-
-	return (vnet);
-}
-
-void
-vnet_destroy(struct vnet *vnet)
-{
-	struct ifnet *ifp, *nifp;
-
-	KASSERT(vnet->vnet_sockcnt == 0,
-	    ("%s: vnet still has sockets", __func__));
-
-	VNET_LIST_WLOCK();
-	LIST_REMOVE(vnet, vnet_le);
-	rw_wunlock(&vnet_rwlock);
-
-	CURVNET_SET_QUIET(vnet);
-
-	/* Return all inherited interfaces to their parent vnets. */
-	TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
-		if (ifp->if_home_vnet != ifp->if_vnet)
-			if_vmove(ifp, ifp->if_home_vnet);
-	}
-
-	vnet_sysuninit();
-	sx_xunlock(&vnet_sxlock);
-
-	CURVNET_RESTORE();
-
-	/* Hopefully, we are OK to free the vnet container itself. */
-	vnet_data_destroy(vnet);
-	vnet->vnet_magic_n = 0xdeadbeef;
-	free(vnet, M_VNET);
-}
-
-void
-vnet_foreach(void (*vnet_foreach_fn)(struct vnet *, void *), void *arg)
-{
-	struct vnet *vnet;
-
-	VNET_LIST_RLOCK();
-	LIST_FOREACH(vnet, &vnet_head, vnet_le)
-		vnet_foreach_fn(vnet, arg);
-	VNET_LIST_RUNLOCK();
-}
-
-static void
-vnet_init_prelink(void *arg)
-{
-
-	rw_init(&vnet_rwlock, "vnet_rwlock");
-	sx_init(&vnet_sxlock, "vnet_sxlock");
-	LIST_INIT(&vnet_head);
-}
-SYSINIT(vnet_init_prelink, SI_SUB_VNET_PRELINK, SI_ORDER_FIRST,
-    vnet_init_prelink, NULL);
-
-static void
-vnet0_init(void *arg)
-{
-
-	/*
-	 * We MUST clear curvnet in vi_init_done() before going SMP,
-	 * otherwise CURVNET_SET() macros would scream about unnecessary
-	 * curvnet recursions.
-	 */
-	curvnet = prison0.pr_vnet = vnet0 = vnet_alloc();
-}
-SYSINIT(vnet0_init, SI_SUB_VNET, SI_ORDER_FIRST, vnet0_init, NULL);
-
-static void
-vnet_init_done(void *unused)
-{
-
-	curvnet = NULL;
-}
-
-SYSINIT(vnet_init_done, SI_SUB_VNET_DONE, SI_ORDER_FIRST, vnet_init_done,
-    NULL);
-
-#ifdef DDB
-DB_SHOW_COMMAND(vnets, db_show_vnets)
-{
-	VNET_ITERATOR_DECL(vnet_iter);
-
-#if SIZE_MAX == UINT32_MAX /* 32-bit arch */
-	db_printf("      vnet ifs socks\n");
-#else /* 64-bit arch, most probaly... */
-	db_printf("              vnet ifs socks\n");
-#endif
-	VNET_FOREACH(vnet_iter) {
-		db_printf("%p %3d %5d\n", vnet_iter, vnet_iter->vnet_ifcnt,
-		    vnet_iter->vnet_sockcnt);
-	}
-}
-#endif
Index: sys/netinet/tcp_input.c
===================================================================
--- sys/netinet/tcp_input.c	(revision 196012)
+++ sys/netinet/tcp_input.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <machine/cpu.h>	/* before tcp_seq.h, for tcp_random18() */
 
@@ -58,6 +57,7 @@
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #define TCPSTATES		/* for logging */
 
Index: sys/netinet/in.c
===================================================================
--- sys/netinet/in.c	(revision 196012)
+++ sys/netinet/in.c	(working copy)
@@ -46,7 +46,6 @@
 #include <sys/proc.h>
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_var.h>
Index: sys/netinet/ip_carp.c
===================================================================
--- sys/netinet/ip_carp.c	(revision 196012)
+++ sys/netinet/ip_carp.c	(working copy)
@@ -52,7 +52,6 @@
 
 #include <sys/socket.h>
 #include <sys/vnode.h>
-#include <sys/vimage.h>
 
 #include <machine/stdarg.h>
 
@@ -65,6 +64,7 @@
 #include <net/if_dl.h>
 #include <net/if_types.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #ifdef INET
 #include <netinet/in.h>
Index: sys/netinet/tcp_subr.c
===================================================================
--- sys/netinet/tcp_subr.c	(revision 196012)
+++ sys/netinet/tcp_subr.c	(working copy)
@@ -55,12 +55,12 @@
 #include <sys/socketvar.h>
 #include <sys/protosw.h>
 #include <sys/random.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
 #include <net/route.h>
 #include <net/if.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/raw_ip.c
===================================================================
--- sys/netinet/raw_ip.c	(revision 196012)
+++ sys/netinet/raw_ip.c	(working copy)
@@ -52,7 +52,6 @@
 #include <sys/sx.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
Index: sys/netinet/tcp_reass.c
===================================================================
--- sys/netinet/tcp_reass.c	(revision 196012)
+++ sys/netinet/tcp_reass.c	(working copy)
@@ -45,12 +45,12 @@
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
Index: sys/netinet/ip_divert.c
===================================================================
--- sys/netinet/ip_divert.c	(revision 196012)
+++ sys/netinet/ip_divert.c	(working copy)
@@ -59,13 +59,13 @@
 #include <sys/sx.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
 #include <net/if.h>
 #include <net/netisr.h> 
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
Index: sys/netinet/tcp_timer.c
===================================================================
--- sys/netinet/tcp_timer.c	(revision 196012)
+++ sys/netinet/tcp_timer.c	(working copy)
@@ -45,10 +45,10 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
Index: sys/netinet/tcp_sack.c
===================================================================
--- sys/netinet/tcp_sack.c	(revision 196012)
+++ sys/netinet/tcp_sack.c	(working copy)
@@ -89,7 +89,6 @@
 #include <sys/socketvar.h>
 #include <sys/syslog.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <machine/cpu.h>	/* before tcp_seq.h, for tcp_random18() */
 
@@ -97,6 +96,7 @@
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/in_pcb.c
===================================================================
--- sys/netinet/in_pcb.c	(revision 196012)
+++ sys/netinet/in_pcb.c	(working copy)
@@ -51,7 +51,6 @@
 #include <sys/jail.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #ifdef DDB
 #include <ddb/ddb.h>
@@ -62,6 +61,7 @@
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
Index: sys/netinet/in_mcast.c
===================================================================
--- sys/netinet/in_mcast.c	(revision 196012)
+++ sys/netinet/in_mcast.c	(working copy)
@@ -45,7 +45,6 @@
 #include <sys/socketvar.h>
 #include <sys/protosw.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 #include <sys/ktr.h>
 #include <sys/tree.h>
 
Index: sys/netinet/tcp_output.c
===================================================================
--- sys/netinet/tcp_output.c	(revision 196012)
+++ sys/netinet/tcp_output.c	(working copy)
@@ -48,10 +48,10 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/tcp_hostcache.c
===================================================================
--- sys/netinet/tcp_hostcache.c	(revision 196012)
+++ sys/netinet/tcp_hostcache.c	(working copy)
@@ -76,10 +76,10 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/ip_output.c
===================================================================
--- sys/netinet/ip_output.c	(revision 196012)
+++ sys/netinet/ip_output.c	(working copy)
@@ -51,7 +51,6 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/netisr.h>
Index: sys/netinet/ip_ipsec.c
===================================================================
--- sys/netinet/ip_ipsec.c	(revision 196012)
+++ sys/netinet/ip_ipsec.c	(working copy)
@@ -43,7 +43,6 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet/tcp_syncache.c
===================================================================
--- sys/netinet/tcp_syncache.c	(revision 196012)
+++ sys/netinet/tcp_syncache.c	(working copy)
@@ -53,7 +53,6 @@
 #include <sys/socketvar.h>
 #include <sys/syslog.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
Index: sys/netinet/ipfw/ip_fw_pfil.c
===================================================================
--- sys/netinet/ipfw/ip_fw_pfil.c	(revision 196012)
+++ sys/netinet/ipfw/ip_fw_pfil.c	(working copy)
@@ -49,7 +49,6 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet/ipfw/ip_fw2.c
===================================================================
--- sys/netinet/ipfw/ip_fw2.c	(revision 196012)
+++ sys/netinet/ipfw/ip_fw2.c	(working copy)
@@ -63,7 +63,6 @@
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 #include <net/ethernet.h> /* for ETHERTYPE_IP */
 #include <net/if.h>
 #include <net/radix.h>
Index: sys/netinet/ipfw/ip_fw_nat.c
===================================================================
--- sys/netinet/ipfw/ip_fw_nat.c	(revision 196012)
+++ sys/netinet/ipfw/ip_fw_nat.c	(working copy)
@@ -45,7 +45,6 @@
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 
 #include <netinet/libalias/alias.h>
 #include <netinet/libalias/alias_local.h>
Index: sys/netinet/ip_input.c
===================================================================
--- sys/netinet/ip_input.c	(revision 196012)
+++ sys/netinet/ip_input.c	(working copy)
@@ -53,7 +53,6 @@
 #include <sys/rwlock.h>
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/pfil.h>
 #include <net/if.h>
Index: sys/netinet/tcp_usrreq.c
===================================================================
--- sys/netinet/tcp_usrreq.c	(revision 196012)
+++ sys/netinet/tcp_usrreq.c	(working copy)
@@ -53,7 +53,6 @@
 #include <sys/protosw.h>
 #include <sys/proc.h>
 #include <sys/jail.h>
-#include <sys/vimage.h>
 
 #ifdef DDB
 #include <ddb/ddb.h>
@@ -61,6 +60,7 @@
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/in_gif.c
===================================================================
--- sys/netinet/in_gif.c	(revision 196012)
+++ sys/netinet/in_gif.c	(working copy)
@@ -46,10 +46,10 @@
 #include <sys/sysctl.h>
 #include <sys/protosw.h>
 #include <sys/malloc.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/ip_mroute.c
===================================================================
--- sys/netinet/ip_mroute.c	(revision 196012)
+++ sys/netinet/ip_mroute.c	(working copy)
@@ -93,11 +93,11 @@
 #include <sys/syslog.h>
 #include <sys/systm.h>
 #include <sys/time.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/netisr.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/igmp.h>
Index: sys/netinet/sctp_os_bsd.h
===================================================================
--- sys/netinet/sctp_os_bsd.h	(revision 196012)
+++ sys/netinet/sctp_os_bsd.h	(working copy)
@@ -61,7 +61,6 @@
 #include <sys/random.h>
 #include <sys/limits.h>
 #include <sys/queue.h>
-#include <sys/vimage.h>
 #include <machine/cpu.h>
 
 #include <net/if.h>
Index: sys/netinet/ip_icmp.c
===================================================================
--- sys/netinet/ip_icmp.c	(revision 196012)
+++ sys/netinet/ip_icmp.c	(working copy)
@@ -42,7 +42,6 @@
 #include <sys/time.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet/tcp_offload.c
===================================================================
--- sys/netinet/tcp_offload.c	(revision 196012)
+++ sys/netinet/tcp_offload.c	(working copy)
@@ -37,12 +37,12 @@
 #include <sys/mbuf.h>
 #include <sys/socket.h>
 #include <sys/socketvar.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
 #include <net/if_var.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/ip_options.c
===================================================================
--- sys/netinet/ip_options.c	(revision 196012)
+++ sys/netinet/ip_options.c	(working copy)
@@ -44,7 +44,6 @@
 #include <sys/kernel.h>
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
@@ -52,6 +51,7 @@
 #include <net/if_dl.h>
 #include <net/route.h>
 #include <net/netisr.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/if_ether.c
===================================================================
--- sys/netinet/if_ether.c	(revision 196012)
+++ sys/netinet/if_ether.c	(working copy)
@@ -51,7 +51,6 @@
 #include <sys/proc.h>
 #include <sys/socket.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
@@ -60,6 +59,7 @@
 #include <net/if_llc.h>
 #include <net/ethernet.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_var.h>
Index: sys/netinet/ip_fastfwd.c
===================================================================
--- sys/netinet/ip_fastfwd.c	(revision 196012)
+++ sys/netinet/ip_fastfwd.c	(working copy)
@@ -87,7 +87,6 @@
 #include <sys/protosw.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/pfil.h>
 #include <net/if.h>
@@ -95,6 +94,7 @@
 #include <net/if_var.h>
 #include <net/if_dl.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/in_proto.c
===================================================================
--- sys/netinet/in_proto.c	(revision 196012)
+++ sys/netinet/in_proto.c	(working copy)
@@ -50,13 +50,13 @@
 #include <sys/protosw.h>
 #include <sys/queue.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
 #ifdef RADIX_MPATH
 #include <net/radix_mpath.h>
 #endif
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/tcp_timewait.c
===================================================================
--- sys/netinet/tcp_timewait.c	(revision 196012)
+++ sys/netinet/tcp_timewait.c	(working copy)
@@ -49,12 +49,12 @@
 #include <sys/socketvar.h>
 #include <sys/protosw.h>
 #include <sys/random.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
 #include <net/route.h>
 #include <net/if.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netinet/udp_usrreq.c
===================================================================
--- sys/netinet/udp_usrreq.c	(revision 196012)
+++ sys/netinet/udp_usrreq.c	(working copy)
@@ -56,7 +56,6 @@
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
Index: sys/netinet/igmp.c
===================================================================
--- sys/netinet/igmp.c	(revision 196012)
+++ sys/netinet/igmp.c	(working copy)
@@ -59,7 +59,6 @@
 #include <sys/protosw.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 #include <sys/ktr.h>
 #include <sys/condvar.h>
 
Index: sys/netinet/in_rmx.c
===================================================================
--- sys/netinet/in_rmx.c	(revision 196012)
+++ sys/netinet/in_rmx.c	(working copy)
@@ -51,10 +51,10 @@
 #include <sys/mbuf.h>
 #include <sys/syslog.h>
 #include <sys/callout.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_var.h>
Index: sys/netgraph/atm/ng_atm.c
===================================================================
--- sys/netgraph/atm/ng_atm.c	(revision 196012)
+++ sys/netgraph/atm/ng_atm.c	(working copy)
@@ -46,7 +46,6 @@
 #include <sys/sbuf.h>
 #include <sys/ioccom.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netgraph/ng_eiface.c
===================================================================
--- sys/netgraph/ng_eiface.c	(revision 196012)
+++ sys/netgraph/ng_eiface.c	(working copy)
@@ -35,10 +35,10 @@
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/errno.h>
+#include <sys/proc.h>
 #include <sys/sockio.h>
 #include <sys/socket.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netgraph/ng_bridge.c
===================================================================
--- sys/netgraph/ng_bridge.c	(revision 196012)
+++ sys/netgraph/ng_bridge.c	(working copy)
@@ -69,10 +69,10 @@
 #include <sys/syslog.h>
 #include <sys/socket.h>
 #include <sys/ctype.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/ethernet.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/ip_fw.h>
Index: sys/netgraph/ng_ether.c
===================================================================
--- sys/netgraph/ng_ether.c	(revision 196012)
+++ sys/netgraph/ng_ether.c	(working copy)
@@ -52,9 +52,9 @@
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/errno.h>
+#include <sys/proc.h>
 #include <sys/syslog.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/netgraph/ng_base.c
===================================================================
--- sys/netgraph/ng_base.c	(revision 196012)
+++ sys/netgraph/ng_base.c	(working copy)
@@ -61,7 +61,6 @@
 #include <sys/syslog.h>
 #include <sys/refcount.h>
 #include <sys/proc.h>
-#include <sys/vimage.h>
 #include <sys/unistd.h>
 #include <sys/kthread.h>
 #include <sys/smp.h>
Index: sys/netgraph/ng_iface.c
===================================================================
--- sys/netgraph/ng_iface.c	(revision 196012)
+++ sys/netgraph/ng_iface.c	(working copy)
@@ -64,12 +64,12 @@
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/errno.h>
+#include <sys/proc.h>
 #include <sys/random.h>
 #include <sys/sockio.h>
 #include <sys/socket.h>
 #include <sys/syslog.h>
 #include <sys/libkern.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netgraph/ng_pipe.c
===================================================================
--- sys/netgraph/ng_pipe.c	(revision 196012)
+++ sys/netgraph/ng_pipe.c	(working copy)
@@ -46,10 +46,11 @@
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
 #include <sys/time.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
+#include <net/vnet.h>
+
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
Index: sys/netgraph/ng_source.c
===================================================================
--- sys/netgraph/ng_source.c	(revision 196012)
+++ sys/netgraph/ng_source.c	(working copy)
@@ -66,9 +66,9 @@
 #include <sys/mbuf.h>
 #include <sys/socket.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 #include <net/if.h>
 #include <net/if_var.h>
+#include <net/vnet.h>
 #include <netgraph/ng_message.h>
 #include <netgraph/netgraph.h>
 #include <netgraph/ng_parse.h>
Index: sys/netgraph/ng_gif.c
===================================================================
--- sys/netgraph/ng_gif.c	(revision 196012)
+++ sys/netgraph/ng_gif.c	(working copy)
@@ -76,7 +76,6 @@
 #include <sys/errno.h>
 #include <sys/syslog.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/fs/nfs/nfsport.h
===================================================================
--- sys/fs/nfs/nfsport.h	(revision 196012)
+++ sys/fs/nfs/nfsport.h	(working copy)
@@ -78,7 +78,6 @@
 #include <sys/priv.h>
 #include <sys/kthread.h>
 #include <sys/syscallsubr.h>
-#include <sys/vimage.h>
 #include <fs/fifofs/fifo.h>
 #include <net/if.h>
 #include <net/radix.h>
Index: sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
===================================================================
--- sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	(revision 196012)
+++ sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	(working copy)
@@ -48,9 +48,7 @@
 #include <sys/protosw.h>
 #include <sys/priv.h>
 
-#if __FreeBSD_version >= 800044
-#include <sys/vimage.h>
-#else
+#if __FreeBSD_version < 800044
 #define V_tcp_do_autosndbuf tcp_do_autosndbuf
 #define V_tcp_autosndbuf_max tcp_autosndbuf_max
 #define V_tcp_do_rfc1323 tcp_do_rfc1323
Index: sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c
===================================================================
--- sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	(revision 196012)
+++ sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	(working copy)
@@ -54,9 +54,7 @@
 #include <sys/proc.h>
 #include <sys/eventhandler.h>
 
-#if __FreeBSD_version >= 800044
-#include <sys/vimage.h>
-#else
+#if __FreeBSD_version < 800044
 #define V_ifnet ifnet
 #endif
 
Index: sys/net80211/ieee80211_freebsd.c
===================================================================
--- sys/net80211/ieee80211_freebsd.c	(revision 196012)
+++ sys/net80211/ieee80211_freebsd.c	(working copy)
@@ -41,7 +41,6 @@
 #include <sys/sysctl.h>
 
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/bpf.h>
 #include <net/if.h>
@@ -51,6 +50,7 @@
 #include <net/if_types.h>
 #include <net/ethernet.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #include <net80211/ieee80211_var.h>
 #include <net80211/ieee80211_input.h>
Index: sys/net80211/ieee80211_ddb.c
===================================================================
--- sys/net80211/ieee80211_ddb.c	(revision 196012)
+++ sys/net80211/ieee80211_ddb.c	(working copy)
@@ -37,7 +37,6 @@
 #include <sys/systm.h> 
 #include <sys/kernel.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/compat/linprocfs/linprocfs.c
===================================================================
--- sys/compat/linprocfs/linprocfs.c	(revision 196012)
+++ sys/compat/linprocfs/linprocfs.c	(working copy)
@@ -73,7 +73,6 @@
 #include <sys/user.h>
 #include <sys/vmmeter.h>
 #include <sys/vnode.h>
-#include <sys/vimage.h>
 #include <sys/bus.h>
 
 #include <net/if.h>
Index: sys/compat/linux/linux_socket.c
===================================================================
--- sys/compat/linux/linux_socket.c	(revision 196012)
+++ sys/compat/linux/linux_socket.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/uio.h>
 #include <sys/syslog.h>
 #include <sys/un.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <netinet/in.h>
Index: sys/compat/linux/linux_ioctl.c
===================================================================
--- sys/compat/linux/linux_ioctl.c	(revision 196012)
+++ sys/compat/linux/linux_ioctl.c	(working copy)
@@ -59,7 +59,6 @@
 #include <sys/sx.h>
 #include <sys/tty.h>
 #include <sys/uio.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/compat/svr4/svr4_sockio.c
===================================================================
--- sys/compat/svr4/svr4_sockio.c	(revision 196012)
+++ sys/compat/svr4/svr4_sockio.c	(working copy)
@@ -36,7 +36,6 @@
 #include <sys/filedesc.h>
 #include <sys/sockio.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/vnet.h>
Index: sys/net/if.c
===================================================================
--- sys/net/if.c	(revision 196012)
+++ sys/net/if.c	(working copy)
@@ -59,7 +59,6 @@
 #include <sys/taskqueue.h>
 #include <sys/domain.h>
 #include <sys/jail.h>
-#include <sys/vimage.h>
 #include <machine/stdarg.h>
 #include <vm/uma.h>
 
Index: sys/net/netisr.c
===================================================================
--- sys/net/netisr.c	(revision 196012)
+++ sys/net/netisr.c	(working copy)
@@ -78,7 +78,6 @@
 #include <sys/socket.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #ifdef DDB
 #include <ddb/ddb.h>
@@ -87,6 +86,7 @@
 #include <net/if.h>
 #include <net/if_var.h>
 #include <net/netisr.h>
+#include <net/vnet.h>
 
 /*-
  * Synchronize use and modification of the registered netisr data structures;
Index: sys/net/bpf.c
===================================================================
--- sys/net/bpf.c	(revision 196012)
+++ sys/net/bpf.c	(working copy)
@@ -56,7 +56,6 @@
 #include <sys/sockio.h>
 #include <sys/ttycom.h>
 #include <sys/uio.h>
-#include <sys/vimage.h>
 
 #include <sys/event.h>
 #include <sys/file.h>
@@ -73,6 +72,7 @@
 #endif
 #include <net/bpf_zerocopy.h>
 #include <net/bpfdesc.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
Index: sys/net/if_stf.c
===================================================================
--- sys/net/if_stf.c	(revision 196012)
+++ sys/net/if_stf.c	(working copy)
@@ -92,7 +92,6 @@
 #include <machine/cpu.h>
 
 #include <sys/malloc.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_clone.h>
@@ -100,6 +99,7 @@
 #include <net/netisr.h>
 #include <net/if_types.h>
 #include <net/if_stf.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/net/if_clone.c
===================================================================
--- sys/net/if_clone.c	(revision 196012)
+++ sys/net/if_clone.c	(working copy)
@@ -39,7 +39,6 @@
 #include <sys/systm.h>
 #include <sys/types.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_clone.h>
Index: sys/net/flowtable.c
===================================================================
--- sys/net/flowtable.c	(revision 196012)
+++ sys/net/flowtable.c	(working copy)
@@ -48,7 +48,6 @@
 #include <sys/socket.h>
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_llatbl.h>
Index: sys/net/route.c
===================================================================
--- sys/net/route.c	(revision 196012)
+++ sys/net/route.c	(working copy)
@@ -51,11 +51,11 @@
 #include <sys/proc.h>
 #include <sys/domain.h>
 #include <sys/kernel.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #ifdef RADIX_MPATH
 #include <net/radix_mpath.h>
Index: sys/net/if_ef.c
===================================================================
--- sys/net/if_ef.c	(revision 196012)
+++ sys/net/if_ef.c	(working copy)
@@ -39,7 +39,6 @@
 #include <sys/syslog.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
-#include <sys/vimage.h>
 
 #include <net/ethernet.h>
 #include <net/if_llc.h>
Index: sys/net/if_bridge.c
===================================================================
--- sys/net/if_bridge.c	(revision 196012)
+++ sys/net/if_bridge.c	(working copy)
@@ -101,7 +101,6 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/rwlock.h>
-#include <sys/vimage.h>
 
 #include <net/bpf.h>
 #include <net/if.h>
Index: sys/net/vnet.c
===================================================================
--- sys/net/vnet.c	(revision 196012)
+++ sys/net/vnet.c	(working copy)
@@ -1,4 +1,12 @@
 /*-
+ * Copyright (c) 2004-2009 University of Zagreb
+ * Copyright (c) 2006-2009 FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by the University of Zagreb and the
+ * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
+ * FreeBSD Foundation.
+ *
  * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
  * Copyright (c) 2009 Robert N. M. Watson
  * All rights reserved.
@@ -28,30 +36,67 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");
 
+#include "opt_ddb.h"
+
 #include <sys/param.h>
 #include <sys/kernel.h>
+#include <sys/jail.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
 #include <sys/linker_set.h>
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/proc.h>
+#include <sys/socket.h>
 #include <sys/sx.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
+#ifdef DDB
+#include <ddb/ddb.h>
+#endif
+
+#include <net/if.h>
+#include <net/if_var.h>
 #include <net/vnet.h>
 
 /*-
  * This file implements core functions for virtual network stacks:
  *
+ * - Core virtual network stack management functions.
+ *
  * - Virtual network stack memory allocator, which virtualized global
  *   variables in the network stack
  *
  * - Virtualized SYSINIT's/SYSUNINIT's, which allow network stack subsystems
  *   to register startup/shutdown events to be run for each virtual network
  *   stack instance.
- *
+ */
+
+MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
+
+/*
+ * The virtual network stack list has two read-write locks, one sleepable and
+ * the other not, so that the list can be stablized and walked in a variety
+ * of network stack contexts.  Both must be acquired exclusively to modify
+ * the list.
+ */
+struct rwlock		vnet_rwlock;
+struct sx		vnet_sxlock;
+
+#define	VNET_LIST_WLOCK() do {						\
+	sx_xlock(&vnet_sxlock);						\
+	rw_wlock(&vnet_rwlock);						\
+} while (0)
+
+#define	VNET_LIST_WUNLOCK() do {					\
+	rw_wunlock(&vnet_rwlock);					\
+	sx_xunlock(&vnet_sxlock);					\
+} while (0)
+
+struct vnet_list_head vnet_head;
+struct vnet *vnet0;
+
+/*
  * The virtual network stack allocator provides storage for virtualized
  * global variables.  These variables are defined/declared using the
  * VNET_DEFINE()/VNET_DECLARE() macros, which place them in the 'set_vnet'
@@ -157,6 +202,114 @@
 static struct sx vnet_data_free_lock;
 
 /*
+ * Allocate a virtual network stack.
+ */
+struct vnet *
+vnet_alloc(void)
+{
+	struct vnet *vnet;
+
+	vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO);
+	vnet->vnet_magic_n = VNET_MAGIC_N;
+	vnet_data_init(vnet);
+
+	/* Initialize / attach vnet module instances. */
+	CURVNET_SET_QUIET(vnet);
+
+	sx_xlock(&vnet_sxlock);
+	vnet_sysinit();
+	CURVNET_RESTORE();
+
+	rw_wlock(&vnet_rwlock);
+	LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
+	VNET_LIST_WUNLOCK();
+
+	return (vnet);
+}
+
+/*
+ * Destroy a virtual network stack.
+ */
+void
+vnet_destroy(struct vnet *vnet)
+{
+	struct ifnet *ifp, *nifp;
+
+	KASSERT(vnet->vnet_sockcnt == 0,
+	    ("%s: vnet still has sockets", __func__));
+
+	VNET_LIST_WLOCK();
+	LIST_REMOVE(vnet, vnet_le);
+	rw_wunlock(&vnet_rwlock);
+
+	CURVNET_SET_QUIET(vnet);
+
+	/* Return all inherited interfaces to their parent vnets. */
+	TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
+		if (ifp->if_home_vnet != ifp->if_vnet)
+			if_vmove(ifp, ifp->if_home_vnet);
+	}
+
+	vnet_sysuninit();
+	sx_xunlock(&vnet_sxlock);
+
+	CURVNET_RESTORE();
+
+	/* Hopefully, we are OK to free the vnet container itself. */
+	vnet_data_destroy(vnet);
+	vnet->vnet_magic_n = 0xdeadbeef;
+	free(vnet, M_VNET);
+}
+
+static void
+vnet_foreach(void (*vnet_foreach_fn)(struct vnet *, void *), void *arg)
+{
+	struct vnet *vnet;
+
+	VNET_LIST_RLOCK();
+	LIST_FOREACH(vnet, &vnet_head, vnet_le)
+		vnet_foreach_fn(vnet, arg);
+	VNET_LIST_RUNLOCK();
+}
+
+/*
+ * Boot time initialization and allocation of virtual network stacks.
+ */
+static void
+vnet_init_prelink(void *arg)
+{
+
+	rw_init(&vnet_rwlock, "vnet_rwlock");
+	sx_init(&vnet_sxlock, "vnet_sxlock");
+	LIST_INIT(&vnet_head);
+}
+SYSINIT(vnet_init_prelink, SI_SUB_VNET_PRELINK, SI_ORDER_FIRST,
+    vnet_init_prelink, NULL);
+
+static void
+vnet0_init(void *arg)
+{
+
+	/*
+	 * We MUST clear curvnet in vi_init_done() before going SMP,
+	 * otherwise CURVNET_SET() macros would scream about unnecessary
+	 * curvnet recursions.
+	 */
+	curvnet = prison0.pr_vnet = vnet0 = vnet_alloc();
+}
+SYSINIT(vnet0_init, SI_SUB_VNET, SI_ORDER_FIRST, vnet0_init, NULL);
+
+static void
+vnet_init_done(void *unused)
+{
+
+	curvnet = NULL;
+}
+
+SYSINIT(vnet_init_done, SI_SUB_VNET_DONE, SI_ORDER_FIRST, vnet_init_done,
+    NULL);
+
+/*
  * Allocate storage for virtualized global variables in a new virtual network
  * stack instance, and copy in initial values from our 'master' copy.
  */
@@ -490,3 +643,20 @@
 		vs->func(vs->arg);
 	}
 }
+
+#ifdef DDB
+DB_SHOW_COMMAND(vnets, db_show_vnets)
+{
+	VNET_ITERATOR_DECL(vnet_iter);
+
+#if SIZE_MAX == UINT32_MAX /* 32-bit arch */
+	db_printf("      vnet ifs socks\n");
+#else /* 64-bit arch, most probaly... */
+	db_printf("              vnet ifs socks\n");
+#endif
+	VNET_FOREACH(vnet_iter) {
+		db_printf("%p %3d %5d\n", vnet_iter, vnet_iter->vnet_ifcnt,
+		    vnet_iter->vnet_sockcnt);
+	}
+}
+#endif
Index: sys/net/vnet.h
===================================================================
--- sys/net/vnet.h	(revision 196012)
+++ sys/net/vnet.h	(working copy)
@@ -1,4 +1,12 @@
 /*-
+ * Copyright (c) 2006-2009 University of Zagreb
+ * Copyright (c) 2006-2009 FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by the University of Zagreb and the
+ * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
+ * FreeBSD Foundation.
+ *
  * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
  * Copyright (c) 2009 Robert N. M. Watson
  * All rights reserved.
@@ -31,6 +39,9 @@
  * This header file defines several sets of interfaces supporting virtualized
  * network stacks:
  *
+ * - Definition of 'struct vnet' and functions and macros to allocate/free/
+ *   manipulate it.
+ *
  * - A virtual network stack memory allocator, which provides support for
  *   virtualized global variables via a special linker set, set_vnet.
  *
@@ -47,17 +58,133 @@
 #define	_NET_VNET_H_
 
 /*
- * Virtual network stack memory allocator, which allows global variables to
- * be automatically instantiated for each network stack instance.
+ * struct vnet describes a virtualized network stack, and is primarily a
+ * pointer to storage for virtualized global variables.  Expose to userspace
+ * as required for libkvm.
  */
 #if defined(_KERNEL) || defined(_WANT_VNET)
+#include <sys/queue.h>
+
+struct vnet {
+	LIST_ENTRY(vnet)	 vnet_le;	/* all vnets list */
+	u_int			 vnet_magic_n;
+	u_int			 vnet_ifcnt;
+	u_int			 vnet_sockcnt;
+	void			*vnet_data_mem;
+	uintptr_t		 vnet_data_base;
+};
+#define	VNET_MAGIC_N 0x3e0d8f29
+
+/*
+ * These two virtual network stack allocator definitions are also required
+ * for libkvm so that it can evaluate virtualized global variables.
+ */
 #define	VNET_SETNAME		"set_vnet"
 #define	VNET_SYMPREFIX		"vnet_entry_"
 #endif
 
 #ifdef _KERNEL
+
 #ifdef VIMAGE
+#include <sys/lock.h>
+#include <sys/proc.h>			/* for struct thread */
+#include <sys/rwlock.h>
+#include <sys/sx.h>
 
+/*
+ * Functions to allocate and destroy virtual network stacks.
+ */
+struct vnet *vnet_alloc(void);
+void	vnet_destroy(struct vnet *vnet);
+
+/*
+ * The current virtual network stack -- we may wish to move this to struct
+ * pcpu in the future.
+ */
+#define	curvnet curthread->td_vnet
+
+/*
+ * Various macros -- get and set the current network stack, but also
+ * assertions.
+ */
+#ifdef INVARIANTS
+#define	VNET_DEBUG
+#endif
+#ifdef VNET_DEBUG
+#define	VNET_ASSERT(condition)						\
+	if (!(condition)) {						\
+		printf("VNET_ASSERT @ %s:%d %s():\n",			\
+			__FILE__, __LINE__, __FUNCTION__);		\
+		panic(#condition);					\
+	}
+
+#define	CURVNET_SET_QUIET(arg)						\
+	VNET_ASSERT((arg)->vnet_magic_n == VNET_MAGIC_N);		\
+	struct vnet *saved_vnet = curvnet;				\
+	const char *saved_vnet_lpush = curthread->td_vnet_lpush;	\
+	curvnet = arg;							\
+	curthread->td_vnet_lpush = __FUNCTION__;
+ 
+#define	CURVNET_SET_VERBOSE(arg)					\
+	CURVNET_SET_QUIET(arg)						\
+	if (saved_vnet)							\
+		printf("CURVNET_SET(%p) in %s() on cpu %d, prev %p in %s()\n", \
+		       curvnet,	curthread->td_vnet_lpush, curcpu,	\
+		       saved_vnet, saved_vnet_lpush);
+
+#define	CURVNET_SET(arg)	CURVNET_SET_VERBOSE(arg)
+ 
+#define	CURVNET_RESTORE()						\
+	VNET_ASSERT(saved_vnet == NULL ||				\
+		    saved_vnet->vnet_magic_n == VNET_MAGIC_N);		\
+	curvnet = saved_vnet;						\
+	curthread->td_vnet_lpush = saved_vnet_lpush;
+#else /* !VNET_DEBUG */
+#define	VNET_ASSERT(condition)
+
+#define	CURVNET_SET(arg)						\
+	struct vnet *saved_vnet = curvnet;				\
+	curvnet = arg;	
+ 
+#define	CURVNET_SET_VERBOSE(arg)	CURVNET_SET(arg)
+#define	CURVNET_SET_QUIET(arg)		CURVNET_SET(arg)
+ 
+#define	CURVNET_RESTORE()						\
+	curvnet = saved_vnet;
+#endif /* VNET_DEBUG */
+
+extern struct vnet *vnet0;
+#define	IS_DEFAULT_VNET(arg)	((arg) == vnet0)
+
+#define	CRED_TO_VNET(cr)	(cr)->cr_prison->pr_vnet
+#define	TD_TO_VNET(td)		CRED_TO_VNET((td)->td_ucred)
+#define	P_TO_VNET(p)		CRED_TO_VNET((p)->p_ucred)
+
+/*
+ * Global linked list of all virtual network stacks, along with read locks to
+ * access it.  If a caller may sleep while accessing the list, it must use
+ * the sleepable lock macros.
+ */
+LIST_HEAD(vnet_list_head, vnet);
+extern struct vnet_list_head vnet_head;
+extern struct rwlock vnet_rwlock;
+extern struct sx vnet_sxlock;
+
+#define	VNET_LIST_RLOCK()		sx_slock(&vnet_sxlock)
+#define	VNET_LIST_RLOCK_NOSLEEP()	rw_rlock(&vnet_rwlock)
+#define	VNET_LIST_RUNLOCK()		sx_sunlock(&vnet_sxlock)
+#define	VNET_LIST_RUNLOCK_NOSLEEP()	rw_runlock(&vnet_rwlock)
+
+/*
+ * Iteration macros to walk the global list of virtual network stacks.
+ */
+#define	VNET_ITERATOR_DECL(arg) struct vnet *arg
+#define	VNET_FOREACH(arg)	LIST_FOREACH((arg), &vnet_head, vnet_le)
+
+/*
+ * Virtual network stack memory allocator, which allows global variables to
+ * be automatically instantiated for each network stack instance.
+ */
 #if defined(__arm__)
 __asm__(".section " VNET_SETNAME ", \"aw\", %progbits");
 #else
@@ -193,6 +320,28 @@
 #else /* !VIMAGE */
 
 /*
+ * Various virtual network stack macros compile to no-ops without VIMAGE.
+ */
+#define	curvnet			NULL
+
+#define	VNET_ASSERT(condition)
+#define	CURVNET_SET(arg)
+#define	CURVNET_SET_QUIET(arg)
+#define	CURVNET_RESTORE()
+
+#define	VNET_LIST_RLOCK()
+#define	VNET_LIST_RLOCK_NOSLEEP()
+#define	VNET_LIST_RUNLOCK()
+#define	VNET_LIST_RUNLOCK_NOSLEEP()
+#define	VNET_ITERATOR_DECL(arg)
+#define	VNET_FOREACH(arg)
+
+#define	IS_DEFAULT_VNET(arg)	1
+#define	CRED_TO_VNET(cr)	NULL
+#define	TD_TO_VNET(td)		NULL
+#define	P_TO_VNET(p)		NULL
+
+/*
  * Versions of the VNET macros that compile to normal global variables and
  * standard sysctl definitions.
  */
Index: sys/net/bridgestp.c
===================================================================
--- sys/net/bridgestp.c	(revision 196012)
+++ sys/net/bridgestp.c	(working copy)
@@ -49,7 +49,6 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/taskqueue.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/net/raw_cb.c
===================================================================
--- sys/net/raw_cb.c	(revision 196012)
+++ sys/net/raw_cb.c	(working copy)
@@ -42,7 +42,6 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/raw_cb.h>
Index: sys/net/if_vlan.c
===================================================================
--- sys/net/if_vlan.c	(revision 196012)
+++ sys/net/if_vlan.c	(working copy)
@@ -55,7 +55,6 @@
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/bpf.h>
 #include <net/ethernet.h>
Index: sys/net/if_ethersubr.c
===================================================================
--- sys/net/if_ethersubr.c	(revision 196012)
+++ sys/net/if_ethersubr.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_arp.h>
Index: sys/net/if_gif.c
===================================================================
--- sys/net/if_gif.c	(revision 196012)
+++ sys/net/if_gif.c	(working copy)
@@ -49,7 +49,6 @@
 #include <sys/proc.h>
 #include <sys/protosw.h>
 #include <sys/conf.h>
-#include <sys/vimage.h>
 #include <machine/cpu.h>
 
 #include <net/if.h>
@@ -58,6 +57,7 @@
 #include <net/netisr.h>
 #include <net/route.h>
 #include <net/bpf.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/net/if_mib.c
===================================================================
--- sys/net/if_mib.c	(revision 196012)
+++ sys/net/if_mib.c	(working copy)
@@ -34,7 +34,6 @@
 #include <sys/kernel.h>
 #include <sys/socket.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_mib.h>
Index: sys/net/if_loop.c
===================================================================
--- sys/net/if_loop.c	(revision 196012)
+++ sys/net/if_loop.c	(working copy)
@@ -49,7 +49,6 @@
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_clone.h>
Index: sys/net/if_llatbl.c
===================================================================
--- sys/net/if_llatbl.c	(revision 196012)
+++ sys/net/if_llatbl.c	(working copy)
@@ -41,7 +41,6 @@
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/rwlock.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
@@ -51,6 +50,7 @@
 #include <net/if_dl.h>
 #include <net/if_var.h>
 #include <net/route.h>
+#include <net/vnet.h>
 #include <netinet/if_ether.h>
 #include <netinet6/in6_var.h>
 #include <netinet6/nd6.h>
Index: sys/net/rtsock.c
===================================================================
--- sys/net/rtsock.c	(revision 196012)
+++ sys/net/rtsock.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/net/if_faith.c
===================================================================
--- sys/net/if_faith.c	(revision 196012)
+++ sys/net/if_faith.c	(working copy)
@@ -54,7 +54,6 @@
 #include <sys/queue.h>
 #include <sys/types.h>
 #include <sys/malloc.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_clone.h>
@@ -62,6 +61,7 @@
 #include <net/netisr.h>
 #include <net/route.h>
 #include <net/bpf.h>
+#include <net/vnet.h>
 
 #ifdef	INET
 #include <netinet/in.h>
Index: sys/net/if_epair.c
===================================================================
--- sys/net/if_epair.c	(revision 196012)
+++ sys/net/if_epair.c	(working copy)
@@ -38,7 +38,7 @@
 /*
  * Things to re-think once we have more experience:
  * - ifp->if_reassign function once we can test with vimage. Depending on
- *   how if_vomve() is going to be improved.
+ *   how if_vmove() is going to be improved.
  * - Real random etheraddrs that are checked to be uniquish; we would need
  *   to re-do them in case we move the interface between network stacks
  *   in a private if_reassign function.
@@ -61,7 +61,6 @@
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/types.h>
-#include <sys/vimage.h>
 
 #include <net/bpf.h>
 #include <net/ethernet.h>
@@ -70,6 +69,7 @@
 #include <net/if_var.h>
 #include <net/if_types.h>
 #include <net/netisr.h>
+#include <net/vnet.h>
 
 #define	EPAIRNAME	"epair"
 
Index: sys/net/if_enc.c
===================================================================
--- sys/net/if_enc.c	(revision 196012)
+++ sys/net/if_enc.c	(working copy)
@@ -38,7 +38,6 @@
 #include <sys/socket.h>
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_clone.h>
Index: sys/net/if_tun.c
===================================================================
--- sys/net/if_tun.c	(revision 196012)
+++ sys/net/if_tun.c	(working copy)
@@ -43,13 +43,13 @@
 #include <sys/uio.h>
 #include <sys/malloc.h>
 #include <sys/random.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_clone.h>
 #include <net/if_types.h>
 #include <net/netisr.h>
 #include <net/route.h>
+#include <net/vnet.h>
 #ifdef INET
 #include <netinet/in.h>
 #endif
Index: sys/net/raw_usrreq.c
===================================================================
--- sys/net/raw_usrreq.c	(revision 196012)
+++ sys/net/raw_usrreq.c	(working copy)
@@ -44,7 +44,6 @@
 #include <sys/socketvar.h>
 #include <sys/sx.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/raw_cb.h>
Index: sys/net/if_gre.c
===================================================================
--- sys/net/if_gre.c	(revision 196012)
+++ sys/net/if_gre.c	(working copy)
@@ -64,13 +64,13 @@
 #include <sys/sockio.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/ethernet.h>
 #include <net/if.h>
 #include <net/if_clone.h>
 #include <net/if_types.h>
 #include <net/route.h>
+#include <net/vnet.h>
 
 #ifdef INET
 #include <netinet/in.h>
Index: sys/net/if_spppsubr.c
===================================================================
--- sys/net/if_spppsubr.c	(revision 196012)
+++ sys/net/if_spppsubr.c	(working copy)
@@ -36,7 +36,6 @@
 #include <sys/random.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
-#include <sys/vimage.h>
 
 #include <sys/md5.h>
 
@@ -44,6 +43,7 @@
 #include <net/netisr.h>
 #include <net/if_types.h>
 #include <net/route.h>
+#include <net/vnet.h>
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
 #include <netinet/ip.h>
Index: sys/ddb/db_sym.c
===================================================================
--- sys/ddb/db_sym.c	(revision 196012)
+++ sys/ddb/db_sym.c	(working copy)
@@ -32,9 +32,9 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/pcpu.h>
 #include <sys/smp.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/vnet.h>
 
Index: sys/netinet6/in6_ifattach.c
===================================================================
--- sys/netinet6/in6_ifattach.c	(revision 196012)
+++ sys/netinet6/in6_ifattach.c	(working copy)
@@ -39,9 +39,9 @@
 #include <sys/sockio.h>
 #include <sys/jail.h>
 #include <sys/kernel.h>
+#include <sys/proc.h>
 #include <sys/syslog.h>
 #include <sys/md5.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/netinet6/scope6.c
===================================================================
--- sys/netinet6/scope6.c	(revision 196012)
+++ sys/netinet6/scope6.c	(working copy)
@@ -39,7 +39,6 @@
 #include <sys/systm.h>
 #include <sys/queue.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/vnet.h>
Index: sys/netinet6/frag6.c
===================================================================
--- sys/netinet6/frag6.c	(revision 196012)
+++ sys/netinet6/frag6.c	(working copy)
@@ -43,7 +43,6 @@
 #include <sys/time.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/raw_ip6.c
===================================================================
--- sys/netinet6/raw_ip6.c	(revision 196012)
+++ sys/netinet6/raw_ip6.c	(working copy)
@@ -79,7 +79,6 @@
 #include <sys/socketvar.h>
 #include <sys/sx.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet6/ip6_output.c
===================================================================
--- sys/netinet6/ip6_output.c	(revision 196012)
+++ sys/netinet6/ip6_output.c	(working copy)
@@ -79,7 +79,6 @@
 #include <sys/socketvar.h>
 #include <sys/syslog.h>
 #include <sys/ucred.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/netisr.h>
Index: sys/netinet6/icmp6.c
===================================================================
--- sys/netinet6/icmp6.c	(revision 196012)
+++ sys/netinet6/icmp6.c	(working copy)
@@ -74,6 +74,7 @@
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mbuf.h>
+#include <sys/proc.h>
 #include <sys/protosw.h>
 #include <sys/signalvar.h>
 #include <sys/socket.h>
@@ -82,7 +83,6 @@
 #include <sys/syslog.h>
 #include <sys/systm.h>
 #include <sys/time.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/netinet6/in6_proto.c
===================================================================
--- sys/netinet6/in6_proto.c	(revision 196012)
+++ sys/netinet6/in6_proto.c	(working copy)
@@ -82,7 +82,6 @@
 #include <sys/mbuf.h>
 #include <sys/systm.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/radix.h>
Index: sys/netinet6/udp6_usrreq.c
===================================================================
--- sys/netinet6/udp6_usrreq.c	(revision 196012)
+++ sys/netinet6/udp6_usrreq.c	(working copy)
@@ -84,7 +84,6 @@
 #include <sys/sysctl.h>
 #include <sys/syslog.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet6/ip6_ipsec.c
===================================================================
--- sys/netinet6/ip6_ipsec.c	(revision 196012)
+++ sys/netinet6/ip6_ipsec.c	(working copy)
@@ -43,7 +43,6 @@
 #include <sys/socket.h>
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/ip6_forward.c
===================================================================
--- sys/netinet6/ip6_forward.c	(revision 196012)
+++ sys/netinet6/ip6_forward.c	(working copy)
@@ -48,7 +48,6 @@
 #include <sys/time.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/in6_rmx.c
===================================================================
--- sys/netinet6/in6_rmx.c	(revision 196012)
+++ sys/netinet6/in6_rmx.c	(working copy)
@@ -87,7 +87,6 @@
 #include <sys/rwlock.h>
 #include <sys/syslog.h>
 #include <sys/callout.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/dest6.c
===================================================================
--- sys/netinet6/dest6.c	(revision 196012)
+++ sys/netinet6/dest6.c	(working copy)
@@ -45,7 +45,6 @@
 #include <sys/errno.h>
 #include <sys/time.h>
 #include <sys/kernel.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/nd6.c
===================================================================
--- sys/netinet6/nd6.c	(revision 196012)
+++ sys/netinet6/nd6.c	(working copy)
@@ -51,7 +51,6 @@
 #include <sys/rwlock.h>
 #include <sys/queue.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_arc.h>
Index: sys/netinet6/nd6_nbr.c
===================================================================
--- sys/netinet6/nd6_nbr.c	(revision 196012)
+++ sys/netinet6/nd6_nbr.c	(working copy)
@@ -52,7 +52,6 @@
 #include <sys/syslog.h>
 #include <sys/queue.h>
 #include <sys/callout.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet6/in6.c
===================================================================
--- sys/netinet6/in6.c	(revision 196012)
+++ sys/netinet6/in6.c	(working copy)
@@ -79,7 +79,6 @@
 #include <sys/time.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet6/mld6.c
===================================================================
--- sys/netinet6/mld6.c	(revision 196012)
+++ sys/netinet6/mld6.c	(working copy)
@@ -79,7 +79,6 @@
 #include <sys/callout.h>
 #include <sys/malloc.h>
 #include <sys/module.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/in6_src.c
===================================================================
--- sys/netinet6/in6_src.c	(revision 196012)
+++ sys/netinet6/in6_src.c	(working copy)
@@ -83,7 +83,6 @@
 #include <sys/jail.h>
 #include <sys/kernel.h>
 #include <sys/sx.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/ip6_input.c
===================================================================
--- sys/netinet6/ip6_input.c	(revision 196012)
+++ sys/netinet6/ip6_input.c	(working copy)
@@ -80,7 +80,6 @@
 #include <sys/time.h>
 #include <sys/kernel.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet6/nd6_rtr.c
===================================================================
--- sys/netinet6/nd6_rtr.c	(revision 196012)
+++ sys/netinet6/nd6_rtr.c	(working copy)
@@ -48,7 +48,6 @@
 #include <sys/rwlock.h>
 #include <sys/syslog.h>
 #include <sys/queue.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/netinet6/in6_pcb.c
===================================================================
--- sys/netinet6/in6_pcb.c	(revision 196012)
+++ sys/netinet6/in6_pcb.c	(working copy)
@@ -81,7 +81,6 @@
 #include <sys/priv.h>
 #include <sys/proc.h>
 #include <sys/jail.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
Index: sys/netinet6/in6_gif.c
===================================================================
--- sys/netinet6/in6_gif.c	(revision 196012)
+++ sys/netinet6/in6_gif.c	(working copy)
@@ -45,7 +45,6 @@
 #include <sys/syslog.h>
 #include <sys/protosw.h>
 #include <sys/malloc.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netinet6/in6_mcast.c
===================================================================
--- sys/netinet6/in6_mcast.c	(revision 196012)
+++ sys/netinet6/in6_mcast.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/priv.h>
 #include <sys/ktr.h>
 #include <sys/tree.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/netinet6/route6.c
===================================================================
--- sys/netinet6/route6.c	(revision 196012)
+++ sys/netinet6/route6.c	(working copy)
@@ -40,7 +40,6 @@
 #include <sys/socket.h>
 #include <sys/systm.h>
 #include <sys/queue.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 
Index: sys/netinet6/ip6_mroute.c
===================================================================
--- sys/netinet6/ip6_mroute.c	(revision 196012)
+++ sys/netinet6/ip6_mroute.c	(working copy)
@@ -103,7 +103,6 @@
 #include <sys/syslog.h>
 #include <sys/systm.h>
 #include <sys/time.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/contrib/altq/altq/altq_subr.c
===================================================================
--- sys/contrib/altq/altq/altq_subr.c	(revision 196012)
+++ sys/contrib/altq/altq/altq_subr.c	(working copy)
@@ -47,9 +47,6 @@
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
 #include <sys/queue.h>
-#ifdef __FreeBSD__
-#include <sys/vimage.h>
-#endif
 
 #include <net/if.h>
 #include <net/if_dl.h>
Index: sys/contrib/rdma/rdma_cma.c
===================================================================
--- sys/contrib/rdma/rdma_cma.c	(revision 196012)
+++ sys/contrib/rdma/rdma_cma.c	(working copy)
@@ -46,7 +46,6 @@
 #include <sys/taskqueue.h>
 #include <sys/priv.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <netinet/in.h>
Index: sys/contrib/pf/net/pf_ioctl.c
===================================================================
--- sys/contrib/pf/net/pf_ioctl.c	(revision 196012)
+++ sys/contrib/pf/net/pf_ioctl.c	(working copy)
@@ -83,7 +83,6 @@
 #include <sys/conf.h>
 #include <sys/proc.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 #else
 #include <sys/timeout.h>
 #include <sys/pool.h>
Index: sys/contrib/pf/net/pf_subr.c
===================================================================
--- sys/contrib/pf/net/pf_subr.c	(revision 196012)
+++ sys/contrib/pf/net/pf_subr.c	(working copy)
@@ -45,7 +45,6 @@
 #include <sys/socketvar.h>
 #include <sys/systm.h>
 #include <sys/time.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/contrib/pf/net/pf_if.c
===================================================================
--- sys/contrib/pf/net/pf_if.c	(revision 196012)
+++ sys/contrib/pf/net/pf_if.c	(working copy)
@@ -54,9 +54,6 @@
 #include <sys/device.h>
 #endif
 #include <sys/time.h>
-#ifdef __FreeBSD__
-#include <sys/vimage.h>
-#endif
 
 #include <net/if.h>
 #include <net/if_types.h>
Index: sys/contrib/pf/net/pf.c
===================================================================
--- sys/contrib/pf/net/pf.c	(revision 196012)
+++ sys/contrib/pf/net/pf.c	(working copy)
@@ -91,7 +91,6 @@
 #include <sys/kthread.h>
 #include <sys/lock.h>
 #include <sys/sx.h>
-#include <sys/vimage.h>
 #else
 #include <sys/rwlock.h>
 #endif
Index: sys/contrib/ipfilter/netinet/fil.c
===================================================================
--- sys/contrib/ipfilter/netinet/fil.c	(revision 196012)
+++ sys/contrib/ipfilter/netinet/fil.c	(working copy)
@@ -33,9 +33,6 @@
 #  if (__FreeBSD_version == 400019)
 #   define CSUM_DELAY_DATA
 #  endif
-#  if (__FreeBSD_version >= 800044)
-#   include <sys/vimage.h>
-#  endif
 # endif
 # include <sys/filio.h>
 #else
Index: sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
===================================================================
--- sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	(revision 196012)
+++ sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	(working copy)
@@ -63,7 +63,6 @@
 # include <sys/select.h>
 #endif
 #if __FreeBSD_version >= 800044
-# include <sys/vimage.h>
 # include <netinet/tcp_var.h>
 #else
 #define V_path_mtu_discovery path_mtu_discovery
Index: sys/netipsec/xform_tcp.c
===================================================================
--- sys/netipsec/xform_tcp.c	(revision 196012)
+++ sys/netipsec/xform_tcp.c	(working copy)
@@ -39,7 +39,6 @@
 #include <sys/kernel.h>
 #include <sys/protosw.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netipsec/xform_ipcomp.c
===================================================================
--- sys/netipsec/xform_ipcomp.c	(revision 196012)
+++ sys/netipsec/xform_ipcomp.c	(working copy)
@@ -41,7 +41,6 @@
 #include <sys/kernel.h>
 #include <sys/protosw.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <netinet/in.h>
 #include <netinet/in_systm.h>
Index: sys/netipsec/xform_esp.c
===================================================================
--- sys/netipsec/xform_esp.c	(revision 196012)
+++ sys/netipsec/xform_esp.c	(working copy)
@@ -46,7 +46,6 @@
 #include <sys/kernel.h>
 #include <sys/random.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/vnet.h>
Index: sys/netipsec/xform_ah.c
===================================================================
--- sys/netipsec/xform_ah.c	(revision 196012)
+++ sys/netipsec/xform_ah.c	(working copy)
@@ -46,7 +46,6 @@
 #include <sys/syslog.h>
 #include <sys/kernel.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/vnet.h>
Index: sys/netipsec/ipsec.c
===================================================================
--- sys/netipsec/ipsec.c	(revision 196012)
+++ sys/netipsec/ipsec.c	(working copy)
@@ -53,7 +53,6 @@
 #include <sys/syslog.h>
 #include <sys/sysctl.h>
 #include <sys/proc.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/netipsec/keysock.c
===================================================================
--- sys/netipsec/keysock.c	(revision 196012)
+++ sys/netipsec/keysock.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/socketvar.h>
 #include <sys/sysctl.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/raw_cb.h>
Index: sys/netipsec/ipsec_mbuf.c
===================================================================
--- sys/netipsec/ipsec_mbuf.c	(revision 196012)
+++ sys/netipsec/ipsec_mbuf.c	(working copy)
@@ -36,7 +36,6 @@
 #include <sys/systm.h>
 #include <sys/mbuf.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/route.h>
 #include <net/vnet.h>
Index: sys/netipsec/xform_ipip.c
===================================================================
--- sys/netipsec/xform_ipip.c	(revision 196012)
+++ sys/netipsec/xform_ipip.c	(working copy)
@@ -50,7 +50,6 @@
 #include <sys/kernel.h>
 #include <sys/protosw.h>
 #include <sys/sysctl.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/pfil.h>
Index: sys/netipsec/ipsec_input.c
===================================================================
--- sys/netipsec/ipsec_input.c	(revision 196012)
+++ sys/netipsec/ipsec_input.c	(working copy)
@@ -54,7 +54,6 @@
 #include <sys/socket.h>
 #include <sys/errno.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/pfil.h>
Index: sys/netipsec/ipsec_output.c
===================================================================
--- sys/netipsec/ipsec_output.c	(revision 196012)
+++ sys/netipsec/ipsec_output.c	(working copy)
@@ -42,7 +42,6 @@
 #include <sys/socket.h>
 #include <sys/errno.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/pfil.h>
Index: sys/netipsec/key.c
===================================================================
--- sys/netipsec/key.c	(revision 196012)
+++ sys/netipsec/key.c	(working copy)
@@ -56,7 +56,6 @@
 #include <sys/queue.h>
 #include <sys/refcount.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/route.h>
Index: sys/sys/vimage.h
===================================================================
--- sys/sys/vimage.h	(revision 196012)
+++ sys/sys/vimage.h	(working copy)
@@ -1,183 +0,0 @@
-/*-
- * Copyright (c) 2006-2009 University of Zagreb
- * Copyright (c) 2006-2009 FreeBSD Foundation
- *
- * This software was developed by the University of Zagreb and the
- * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
- * FreeBSD Foundation.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef	_SYS_VIMAGE_H_
-#define	_SYS_VIMAGE_H_
-
-/*
- * struct vnet describes a virtualized network stack, and is primarily a
- * pointer to storage for virtualized global variables.  Expose to userspace
- * as required for libkvm.
- */
-#if defined(_KERNEL) || defined(_WANT_VNET)
-#include <sys/queue.h>
-
-struct vnet {
-	LIST_ENTRY(vnet)	 vnet_le;	/* all vnets list */
-	u_int			 vnet_magic_n;
-	u_int			 vnet_ifcnt;
-	u_int			 vnet_sockcnt;
-	void			*vnet_data_mem;
-	uintptr_t		 vnet_data_base;
-};
-
-#define	VNET_MAGIC_N 0x3e0d8f29
-#endif
-
-#ifdef _KERNEL
-
-#include <sys/lock.h>
-#include <sys/sx.h>
-#include <sys/proc.h>
-
-#ifdef INVARIANTS
-#define	VNET_DEBUG
-#endif
-
-#ifdef VIMAGE
-
-struct vnet;
-struct ifnet;
-struct vnet *vnet_alloc(void);
-void	vnet_destroy(struct vnet *);
-void	vnet_foreach(void (*vnet_foreach_fn)(struct vnet *, void *),
-	    void *arg);
-
-#endif /* VIMAGE */
-
-#define	curvnet curthread->td_vnet
-
-#ifdef VIMAGE
-#ifdef VNET_DEBUG
-#define	VNET_ASSERT(condition)						\
-	if (!(condition)) {						\
-		printf("VNET_ASSERT @ %s:%d %s():\n",			\
-			__FILE__, __LINE__, __FUNCTION__);		\
-		panic(#condition);					\
-	}
-
-#define	CURVNET_SET_QUIET(arg)						\
-	VNET_ASSERT((arg)->vnet_magic_n == VNET_MAGIC_N);		\
-	struct vnet *saved_vnet = curvnet;				\
-	const char *saved_vnet_lpush = curthread->td_vnet_lpush;	\
-	curvnet = arg;							\
-	curthread->td_vnet_lpush = __FUNCTION__;
- 
-#define	CURVNET_SET_VERBOSE(arg)					\
-	CURVNET_SET_QUIET(arg)						\
-	if (saved_vnet)							\
-		printf("CURVNET_SET(%p) in %s() on cpu %d, prev %p in %s()\n", \
-		       curvnet,	curthread->td_vnet_lpush, curcpu,	\
-		       saved_vnet, saved_vnet_lpush);
-
-#define	CURVNET_SET(arg)	CURVNET_SET_VERBOSE(arg)
- 
-#define	CURVNET_RESTORE()						\
-	VNET_ASSERT(saved_vnet == NULL ||				\
-		    saved_vnet->vnet_magic_n == VNET_MAGIC_N);		\
-	curvnet = saved_vnet;						\
-	curthread->td_vnet_lpush = saved_vnet_lpush;
-#else /* !VNET_DEBUG */
-#define	VNET_ASSERT(condition)
-
-#define	CURVNET_SET(arg)						\
-	struct vnet *saved_vnet = curvnet;				\
-	curvnet = arg;	
- 
-#define	CURVNET_SET_VERBOSE(arg)	CURVNET_SET(arg)
-#define	CURVNET_SET_QUIET(arg)		CURVNET_SET(arg)
- 
-#define	CURVNET_RESTORE()						\
-	curvnet = saved_vnet;
-#endif /* VNET_DEBUG */
-#else /* !VIMAGE */
-#define	VNET_ASSERT(condition)
-#define	CURVNET_SET(arg)
-#define	CURVNET_SET_QUIET(arg)
-#define	CURVNET_RESTORE()
-#endif /* !VIMAGE */
-
-#ifdef VIMAGE
-/*
- * Global linked list of all virtual network stacks, along with read locks to
- * access it.  If a caller may sleep while accessing the list, it must use
- * the sleepable lock macros.
- */
-LIST_HEAD(vnet_list_head, vnet);
-extern struct vnet_list_head vnet_head;
-extern struct rwlock vnet_rwlock;
-extern struct sx vnet_sxlock;
-
-#define	VNET_LIST_RLOCK()		sx_slock(&vnet_sxlock)
-#define	VNET_LIST_RLOCK_NOSLEEP()	rw_rlock(&vnet_rwlock)
-#define	VNET_LIST_RUNLOCK()		sx_sunlock(&vnet_sxlock)
-#define	VNET_LIST_RUNLOCK_NOSLEEP()	rw_runlock(&vnet_rwlock)
-
-/*
- * Iteration macros to walk the global list of virtual network stacks.
- */
-#define	VNET_ITERATOR_DECL(arg) struct vnet *arg
-#define	VNET_FOREACH(arg)	LIST_FOREACH((arg), &vnet_head, vnet_le)
-
-#else /* !VIMAGE */
-/*
- * No-op macros for the !VIMAGE case.
- */
-#define	VNET_LIST_RLOCK()
-#define	VNET_LIST_RLOCK_NOSLEEP()
-#define	VNET_LIST_RUNLOCK()
-#define	VNET_LIST_RUNLOCK_NOSLEEP()
-#define	VNET_ITERATOR_DECL(arg)
-#define	VNET_FOREACH(arg)
-
-#endif /* VIMAGE */
-
-#ifdef VIMAGE
-extern struct vnet *vnet0;
-#define	IS_DEFAULT_VNET(arg)	((arg) == vnet0)
-#else
-#define	IS_DEFAULT_VNET(arg)	1
-#endif
-
-#ifdef VIMAGE
-#define	CRED_TO_VNET(cr)	(cr)->cr_prison->pr_vnet
-#define	TD_TO_VNET(td)		CRED_TO_VNET((td)->td_ucred)
-#define	P_TO_VNET(p)		CRED_TO_VNET((p)->p_ucred)
-#else /* !VIMAGE */
-#define	CRED_TO_VNET(cr)	NULL
-#define	TD_TO_VNET(td)		NULL
-#define	P_TO_VNET(p)		NULL
-#endif /* VIMAGE */
-
-#endif /* _KERNEL */
-
-#endif /* !_SYS_VIMAGE_H_ */
