svn commit: r196019 - in head: . lib/libkvm sys/arm/arm sys/compat/linprocfs sys/compat/linux sys/compat/svr4 sys/conf sys/contrib/altq/altq sys/contrib/ipfilter/netinet sys/contrib/pf/net sys/cont...

Robert Watson rwatson at FreeBSD.org
Sat Aug 1 19:26:29 UTC 2009


Author: rwatson
Date: Sat Aug  1 19:26:27 2009
New Revision: 196019
URL: http://svn.freebsd.org/changeset/base/196019

Log:
  Merge the remainder of kern_vimage.c and vimage.h into vnet.c and
  vnet.h, we now use jails (rather than vimages) as the abstraction
  for virtualization management, and what remained was specific to
  virtual network stacks.  Minor cleanups are done in the process,
  and comments updated to reflect these changes.
  
  Reviewed by:	bz
  Approved by:	re (vimage blanket)

Deleted:
  head/sys/kern/kern_vimage.c
  head/sys/sys/vimage.h
Modified:
  head/ObsoleteFiles.inc
  head/lib/libkvm/kvm_vnet.c
  head/sys/arm/arm/minidump_machdep.c
  head/sys/compat/linprocfs/linprocfs.c
  head/sys/compat/linux/linux_ioctl.c
  head/sys/compat/linux/linux_socket.c
  head/sys/compat/svr4/svr4_sockio.c
  head/sys/conf/files
  head/sys/contrib/altq/altq/altq_subr.c
  head/sys/contrib/ipfilter/netinet/fil.c
  head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
  head/sys/contrib/pf/net/pf.c
  head/sys/contrib/pf/net/pf_if.c
  head/sys/contrib/pf/net/pf_ioctl.c
  head/sys/contrib/pf/net/pf_subr.c
  head/sys/contrib/rdma/rdma_cma.c
  head/sys/ddb/db_sym.c
  head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c
  head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
  head/sys/fs/nfs/nfsport.h
  head/sys/kern/kern_jail.c
  head/sys/kern/kern_linker.c
  head/sys/kern/kern_poll.c
  head/sys/kern/kern_sysctl.c
  head/sys/kern/kern_uuid.c
  head/sys/kern/sys_socket.c
  head/sys/kern/uipc_domain.c
  head/sys/kern/uipc_socket.c
  head/sys/kern/uipc_syscalls.c
  head/sys/kern/uipc_usrreq.c
  head/sys/net/bpf.c
  head/sys/net/bridgestp.c
  head/sys/net/flowtable.c
  head/sys/net/if.c
  head/sys/net/if_bridge.c
  head/sys/net/if_clone.c
  head/sys/net/if_ef.c
  head/sys/net/if_enc.c
  head/sys/net/if_epair.c
  head/sys/net/if_ethersubr.c
  head/sys/net/if_faith.c
  head/sys/net/if_gif.c
  head/sys/net/if_gre.c
  head/sys/net/if_llatbl.c
  head/sys/net/if_loop.c
  head/sys/net/if_mib.c
  head/sys/net/if_spppsubr.c
  head/sys/net/if_stf.c
  head/sys/net/if_tun.c
  head/sys/net/if_vlan.c
  head/sys/net/netisr.c
  head/sys/net/raw_cb.c
  head/sys/net/raw_usrreq.c
  head/sys/net/route.c
  head/sys/net/rtsock.c
  head/sys/net/vnet.c
  head/sys/net/vnet.h
  head/sys/net80211/ieee80211_ddb.c
  head/sys/net80211/ieee80211_freebsd.c
  head/sys/netgraph/atm/ng_atm.c
  head/sys/netgraph/ng_base.c
  head/sys/netgraph/ng_bridge.c
  head/sys/netgraph/ng_eiface.c
  head/sys/netgraph/ng_ether.c
  head/sys/netgraph/ng_gif.c
  head/sys/netgraph/ng_iface.c
  head/sys/netgraph/ng_pipe.c
  head/sys/netgraph/ng_source.c
  head/sys/netinet/if_ether.c
  head/sys/netinet/igmp.c
  head/sys/netinet/in.c
  head/sys/netinet/in_gif.c
  head/sys/netinet/in_mcast.c
  head/sys/netinet/in_pcb.c
  head/sys/netinet/in_proto.c
  head/sys/netinet/in_rmx.c
  head/sys/netinet/ip_carp.c
  head/sys/netinet/ip_divert.c
  head/sys/netinet/ip_fastfwd.c
  head/sys/netinet/ip_icmp.c
  head/sys/netinet/ip_input.c
  head/sys/netinet/ip_ipsec.c
  head/sys/netinet/ip_mroute.c
  head/sys/netinet/ip_options.c
  head/sys/netinet/ip_output.c
  head/sys/netinet/ipfw/ip_fw2.c
  head/sys/netinet/ipfw/ip_fw_nat.c
  head/sys/netinet/ipfw/ip_fw_pfil.c
  head/sys/netinet/raw_ip.c
  head/sys/netinet/sctp_os_bsd.h
  head/sys/netinet/tcp_hostcache.c
  head/sys/netinet/tcp_input.c
  head/sys/netinet/tcp_offload.c
  head/sys/netinet/tcp_output.c
  head/sys/netinet/tcp_reass.c
  head/sys/netinet/tcp_sack.c
  head/sys/netinet/tcp_subr.c
  head/sys/netinet/tcp_syncache.c
  head/sys/netinet/tcp_timer.c
  head/sys/netinet/tcp_timewait.c
  head/sys/netinet/tcp_usrreq.c
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet6/dest6.c
  head/sys/netinet6/frag6.c
  head/sys/netinet6/icmp6.c
  head/sys/netinet6/in6.c
  head/sys/netinet6/in6_gif.c
  head/sys/netinet6/in6_ifattach.c
  head/sys/netinet6/in6_mcast.c
  head/sys/netinet6/in6_pcb.c
  head/sys/netinet6/in6_proto.c
  head/sys/netinet6/in6_rmx.c
  head/sys/netinet6/in6_src.c
  head/sys/netinet6/ip6_forward.c
  head/sys/netinet6/ip6_input.c
  head/sys/netinet6/ip6_ipsec.c
  head/sys/netinet6/ip6_mroute.c
  head/sys/netinet6/ip6_output.c
  head/sys/netinet6/mld6.c
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6_nbr.c
  head/sys/netinet6/nd6_rtr.c
  head/sys/netinet6/raw_ip6.c
  head/sys/netinet6/route6.c
  head/sys/netinet6/scope6.c
  head/sys/netinet6/udp6_usrreq.c
  head/sys/netipsec/ipsec.c
  head/sys/netipsec/ipsec_input.c
  head/sys/netipsec/ipsec_mbuf.c
  head/sys/netipsec/ipsec_output.c
  head/sys/netipsec/key.c
  head/sys/netipsec/keysock.c
  head/sys/netipsec/xform_ah.c
  head/sys/netipsec/xform_esp.c
  head/sys/netipsec/xform_ipcomp.c
  head/sys/netipsec/xform_ipip.c
  head/sys/netipsec/xform_tcp.c
  head/sys/nfsclient/bootp_subr.c
  head/sys/nfsclient/nfs_diskless.c
  head/sys/nfsclient/nfs_vnops.c

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/ObsoleteFiles.inc	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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

Modified: head/lib/libkvm/kvm_vnet.c
==============================================================================
--- head/lib/libkvm/kvm_vnet.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/lib/libkvm/kvm_vnet.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/jail.h>
 #include <sys/proc.h>
 #include <sys/types.h>
-#include <sys/vimage.h>
 
 #include <net/vnet.h>
 

Modified: head/sys/arm/arm/minidump_machdep.c
==============================================================================
--- head/sys/arm/arm/minidump_machdep.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/arm/arm/minidump_machdep.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- head/sys/compat/linprocfs/linprocfs.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/compat/linprocfs/linprocfs.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -73,7 +73,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/user.h>
 #include <sys/vmmeter.h>
 #include <sys/vnode.h>
-#include <sys/vimage.h>
 #include <sys/bus.h>
 
 #include <net/if.h>

Modified: head/sys/compat/linux/linux_ioctl.c
==============================================================================
--- head/sys/compat/linux/linux_ioctl.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/compat/linux/linux_ioctl.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/compat/linux/linux_socket.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/uio.h>
 #include <sys/syslog.h>
 #include <sys/un.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <netinet/in.h>

Modified: head/sys/compat/svr4/svr4_sockio.c
==============================================================================
--- head/sys/compat/svr4/svr4_sockio.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/compat/svr4/svr4_sockio.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/filedesc.h>
 #include <sys/sockio.h>
 #include <sys/socket.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <net/vnet.h>

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/conf/files	Sat Aug  1 19:26:27 2009	(r196019)
@@ -1992,7 +1992,6 @@ kern/kern_time.c		standard
 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

Modified: head/sys/contrib/altq/altq/altq_subr.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_subr.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/altq/altq/altq_subr.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/contrib/ipfilter/netinet/fil.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/fil.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/ipfilter/netinet/fil.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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

Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -63,7 +63,6 @@ static const char rcsid[] = "@(#)$Id: ip
 # 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

Modified: head/sys/contrib/pf/net/pf.c
==============================================================================
--- head/sys/contrib/pf/net/pf.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/pf/net/pf.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -91,7 +91,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/kthread.h>
 #include <sys/lock.h>
 #include <sys/sx.h>
-#include <sys/vimage.h>
 #else
 #include <sys/rwlock.h>
 #endif

Modified: head/sys/contrib/pf/net/pf_if.c
==============================================================================
--- head/sys/contrib/pf/net/pf_if.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/pf/net/pf_if.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -54,9 +54,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/contrib/pf/net/pf_ioctl.c
==============================================================================
--- head/sys/contrib/pf/net/pf_ioctl.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/pf/net/pf_ioctl.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -83,7 +83,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/contrib/pf/net/pf_subr.c
==============================================================================
--- head/sys/contrib/pf/net/pf_subr.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/pf/net/pf_subr.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/contrib/rdma/rdma_cma.c
==============================================================================
--- head/sys/contrib/rdma/rdma_cma.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/contrib/rdma/rdma_cma.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/taskqueue.h>
 #include <sys/priv.h>
 #include <sys/syslog.h>
-#include <sys/vimage.h>
 
 #include <net/if.h>
 #include <netinet/in.h>

Modified: head/sys/ddb/db_sym.c
==============================================================================
--- head/sys/ddb/db_sym.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/ddb/db_sym.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>
 

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -54,9 +54,7 @@ __FBSDID("$FreeBSD$");
 #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
 

Modified: head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==============================================================================
--- head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$");
 #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

Modified: head/sys/fs/nfs/nfsport.h
==============================================================================
--- head/sys/fs/nfs/nfsport.h	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/fs/nfs/nfsport.h	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/kern/kern_jail.c
==============================================================================
--- head/sys/kern/kern_jail.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/kern_jail.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -58,9 +58,12 @@ __FBSDID("$FreeBSD$");
 #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

Modified: head/sys/kern/kern_linker.c
==============================================================================
--- head/sys/kern/kern_linker.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/kern_linker.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -51,7 +51,8 @@ __FBSDID("$FreeBSD$");
 #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>
 

Modified: head/sys/kern/kern_poll.c
==============================================================================
--- head/sys/kern/kern_poll.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/kern_poll.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #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		*/

Modified: head/sys/kern/kern_sysctl.c
==============================================================================
--- head/sys/kern/kern_sysctl.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/kern_sysctl.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/sx.h>
 #include <sys/sysproto.h>
 #include <sys/uio.h>
-#include <sys/vimage.h>
 #ifdef KTRACE
 #include <sys/ktrace.h>
 #endif

Modified: head/sys/kern/kern_uuid.c
==============================================================================
--- head/sys/kern/kern_uuid.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/kern_uuid.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/kern/sys_socket.c
==============================================================================
--- head/sys/kern/sys_socket.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/sys_socket.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -48,10 +48,10 @@ __FBSDID("$FreeBSD$");
 #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>
 

Modified: head/sys/kern/uipc_domain.c
==============================================================================
--- head/sys/kern/uipc_domain.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/uipc_domain.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -43,7 +43,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/mutex.h>
 #include <sys/socketvar.h>
 #include <sys/systm.h>
-#include <sys/vimage.h>
+
+#include <net/vnet.h>
+
 #include <vm/uma.h>
 
 /*

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/uipc_socket.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -129,7 +129,8 @@ __FBSDID("$FreeBSD$");
 #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>
 

Modified: head/sys/kern/uipc_syscalls.c
==============================================================================
--- head/sys/kern/uipc_syscalls.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/uipc_syscalls.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -64,12 +64,13 @@ __FBSDID("$FreeBSD$");
 #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>
 

Modified: head/sys/kern/uipc_usrreq.c
==============================================================================
--- head/sys/kern/uipc_usrreq.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/kern/uipc_usrreq.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -88,7 +88,8 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/net/bpf.c
==============================================================================
--- head/sys/net/bpf.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/bpf.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
 #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 @@ __FBSDID("$FreeBSD$");
 #endif
 #include <net/bpf_zerocopy.h>
 #include <net/bpfdesc.h>
+#include <net/vnet.h>
 
 #include <netinet/in.h>
 #include <netinet/if_ether.h>

Modified: head/sys/net/bridgestp.c
==============================================================================
--- head/sys/net/bridgestp.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/bridgestp.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/net/flowtable.c
==============================================================================
--- head/sys/net/flowtable.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/flowtable.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>
 

Modified: head/sys/net/if_bridge.c
==============================================================================
--- head/sys/net/if_bridge.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_bridge.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -101,7 +101,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/rwlock.h>
-#include <sys/vimage.h>
 
 #include <net/bpf.h>
 #include <net/if.h>

Modified: head/sys/net/if_clone.c
==============================================================================
--- head/sys/net/if_clone.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_clone.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_ef.c
==============================================================================
--- head/sys/net/if_ef.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_ef.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_enc.c
==============================================================================
--- head/sys/net/if_enc.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_enc.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_epair.c
==============================================================================
--- head/sys/net/if_epair.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_epair.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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 @@ __FBSDID("$FreeBSD$");
 #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 @@ __FBSDID("$FreeBSD$");
 #include <net/if_var.h>
 #include <net/if_types.h>
 #include <net/netisr.h>
+#include <net/vnet.h>
 
 #define	EPAIRNAME	"epair"
 

Modified: head/sys/net/if_ethersubr.c
==============================================================================
--- head/sys/net/if_ethersubr.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_ethersubr.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_faith.c
==============================================================================
--- head/sys/net/if_faith.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_faith.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_gif.c
==============================================================================
--- head/sys/net/if_gif.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_gif.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_gre.c
==============================================================================
--- head/sys/net/if_gre.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_gre.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_llatbl.c
==============================================================================
--- head/sys/net/if_llatbl.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_llatbl.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/mutex.h>
 #include <sys/rwlock.h>
-#include <sys/vimage.h>
 
 #include <vm/uma.h>
 
@@ -51,6 +50,7 @@ __FBSDID("$FreeBSD$");
 #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>

Modified: head/sys/net/if_loop.c
==============================================================================
--- head/sys/net/if_loop.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_loop.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_mib.c
==============================================================================
--- head/sys/net/if_mib.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_mib.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_spppsubr.c
==============================================================================
--- head/sys/net/if_spppsubr.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_spppsubr.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_stf.c
==============================================================================
--- head/sys/net/if_stf.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_stf.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/if_tun.c
==============================================================================
--- head/sys/net/if_tun.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_tun.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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

Modified: head/sys/net/if_vlan.c
==============================================================================
--- head/sys/net/if_vlan.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/if_vlan.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/netisr.c
==============================================================================
--- head/sys/net/netisr.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/netisr.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -78,7 +78,6 @@ __FBSDID("$FreeBSD$");
 #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 @@ __FBSDID("$FreeBSD$");
 #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;

Modified: head/sys/net/raw_cb.c
==============================================================================
--- head/sys/net/raw_cb.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/raw_cb.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/raw_usrreq.c
==============================================================================
--- head/sys/net/raw_usrreq.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/raw_usrreq.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/route.c
==============================================================================
--- head/sys/net/route.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/route.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/rtsock.c
==============================================================================
--- head/sys/net/rtsock.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/rtsock.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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>

Modified: head/sys/net/vnet.c
==============================================================================
--- head/sys/net/vnet.c	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/vnet.c	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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 at 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 TAILQ_HEAD(, vnet_data_free) vnet
 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 @@ vnet_sysuninit(void)
 		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

Modified: head/sys/net/vnet.h
==============================================================================
--- head/sys/net/vnet.h	Sat Aug  1 15:40:22 2009	(r196018)
+++ head/sys/net/vnet.h	Sat Aug  1 19:26:27 2009	(r196019)
@@ -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 at 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;	\

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list