Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 14 Jul 2009 22:48:30 +0000 (UTC)
From:      Robert Watson <rwatson@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r195699 - in head: . sys/compat/linprocfs sys/compat/linux sys/compat/svr4 sys/conf sys/contrib/altq/altq sys/contrib/ipfilter/netinet sys/contrib/pf/net sys/contrib/rdma sys/ddb sys/de...
Message-ID:  <200907142248.n6EMmUVd073453@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rwatson
Date: Tue Jul 14 22:48:30 2009
New Revision: 195699
URL: http://svn.freebsd.org/changeset/base/195699

Log:
  Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
  (DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
  network stack memory allocator.  Modify vnet to use the allocator
  instead of monolithic global container structures (vinet, ...).  This
  change solves many binary compatibility problems associated with
  VIMAGE, and restores ELF symbols for virtualized global variables.
  
  Each virtualized global variable exists as a "reference copy", and also
  once per virtual network stack.  Virtualized global variables are
  tagged at compile-time, placing the in a special linker set, which is
  loaded into a contiguous region of kernel memory.  Virtualized global
  variables in the base kernel are linked as normal, but those in modules
  are copied and relocated to a reserved portion of the kernel's vnet
  region with the help of a the kernel linker.
  
  Virtualized global variables exist in per-vnet memory set up when the
  network stack instance is created, and are initialized statically from
  the reference copy.  Run-time access occurs via an accessor macro, which
  converts from the current vnet and requested symbol to a per-vnet
  address.  When "options VIMAGE" is not compiled into the kernel, normal
  global ELF symbols will be used instead and indirection is avoided.
  
  This change restores static initialization for network stack global
  variables, restores support for non-global symbols and types, eliminates
  the need for many subsystem constructors, eliminates large per-subsystem
  structures that caused many binary compatibility issues both for
  monitoring applications (netstat) and kernel modules, removes the
  per-function INIT_VNET_*() macros throughout the stack, eliminates the
  need for vnet_symmap ksym(2) munging, and eliminates duplicate
  definitions of virtualized globals under VIMAGE_GLOBALS.
  
  Bump __FreeBSD_version and update UPDATING.
  
  Portions submitted by:  bz
  Reviewed by:            bz, zec
  Discussed with:         gnn, jamie, jeff, jhb, julian, sam
  Suggested by:           peter
  Approved by:            re (kensmith)

Added:
  head/sys/net/vnet.c   (contents, props changed)
Deleted:
  head/sys/netinet/vinet.h
  head/sys/netinet6/vinet6.h
  head/sys/netipsec/vipsec.h
Modified:
  head/ObsoleteFiles.inc
  head/UPDATING
  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/conf/options
  head/sys/contrib/altq/altq/altq_subr.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/pf/net/pfvar.h
  head/sys/contrib/rdma/rdma_cma.c
  head/sys/ddb/db_expr.c
  head/sys/ddb/db_sym.c
  head/sys/ddb/db_variables.c
  head/sys/ddb/db_variables.h
  head/sys/ddb/ddb.h
  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/fs/nfsclient/nfs_clvnops.c
  head/sys/fs/nfsserver/nfs_nfsdport.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/kern_vimage.c
  head/sys/kern/link_elf.c
  head/sys/kern/link_elf_obj.c
  head/sys/kern/uipc_domain.c
  head/sys/net/bridgestp.c
  head/sys/net/flowtable.c
  head/sys/net/flowtable.h
  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_ethersubr.c
  head/sys/net/if_faith.c
  head/sys/net/if_gif.c
  head/sys/net/if_gif.h
  head/sys/net/if_gre.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_var.h
  head/sys/net/if_vlan.c
  head/sys/net/raw_cb.c
  head/sys/net/raw_cb.h
  head/sys/net/raw_usrreq.c
  head/sys/net/route.c
  head/sys/net/rtsock.c
  head/sys/net/vnet.h
  head/sys/net80211/ieee80211_ddb.c
  head/sys/netgraph/atm/ng_atm.c
  head/sys/netgraph/netgraph.h
  head/sys/netgraph/ng_base.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/netinet/icmp6.h
  head/sys/netinet/icmp_var.h
  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_pcb.h
  head/sys/netinet/in_rmx.c
  head/sys/netinet/in_var.h
  head/sys/netinet/ip_carp.c
  head/sys/netinet/ip_divert.c
  head/sys/netinet/ip_fastfwd.c
  head/sys/netinet/ip_fw.h
  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/ip_var.h
  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/tcp_var.h
  head/sys/netinet/udp_usrreq.c
  head/sys/netinet/udp_var.h
  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/in6_var.h
  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/ip6_var.h
  head/sys/netinet6/mld6.c
  head/sys/netinet6/nd6.c
  head/sys/netinet6/nd6.h
  head/sys/netinet6/nd6_nbr.c
  head/sys/netinet6/nd6_rtr.c
  head/sys/netinet6/raw_ip6.c
  head/sys/netinet6/raw_ip6.h
  head/sys/netinet6/route6.c
  head/sys/netinet6/scope6.c
  head/sys/netinet6/tcp6_var.h
  head/sys/netinet6/udp6_usrreq.c
  head/sys/netipsec/ah_var.h
  head/sys/netipsec/esp_var.h
  head/sys/netipsec/ipcomp_var.h
  head/sys/netipsec/ipip_var.h
  head/sys/netipsec/ipsec.c
  head/sys/netipsec/ipsec.h
  head/sys/netipsec/ipsec6.h
  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/key_debug.c
  head/sys/netipsec/key_debug.h
  head/sys/netipsec/keysock.c
  head/sys/netipsec/keysock.h
  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
  head/sys/sys/param.h
  head/sys/sys/pcpu.h
  head/sys/sys/sysctl.h
  head/sys/sys/vimage.h

Modified: head/ObsoleteFiles.inc
==============================================================================
--- head/ObsoleteFiles.inc	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/ObsoleteFiles.inc	Tue Jul 14 22:48:30 2009	(r195699)
@@ -14,6 +14,10 @@
 # The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
 #
 
+# 20090713: vimage container structs removed.
+OLD_FILES+=usr/include/netinet/vinet.h
+OLD_FILES+=usr/include/netinet6/vinet6.h
+OLD_FILES+=usr/include/netipsec/vipsec.h
 # 20090709: msgctl.3 msgget.3 msgrcv.3 msgsnd.3 manual pages moved
 OLD_FILES+=usr/share/man/man3/msgctl.3.gz
 OLD_FILES+=usr/share/man/man3/msgget.3.gz

Modified: head/UPDATING
==============================================================================
--- head/UPDATING	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/UPDATING	Tue Jul 14 22:48:30 2009	(r195699)
@@ -22,6 +22,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.
 	to maximize performance.  (To disable malloc debugging, run
 	ln -s aj /etc/malloc.conf.)
 
+20090714:
+	Due to changes in the implementation of virtual network stack
+	support, all network-related kernel modules must be recompiled.
+	As this change breaks the ABI, bump __FreeBSD_version to 800104.
+
 20090713:
 	The TOE interface to the TCP syncache has been modified to remove struct
 	tcpopt (<netinet/tcp_var.h>) from the ABI of the network stack.  The

Modified: head/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- head/sys/compat/linprocfs/linprocfs.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/compat/linprocfs/linprocfs.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -1078,7 +1078,6 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
 static int
 linprocfs_donetdev(PFS_FILL_ARGS)
 {
-	INIT_VNET_NET(TD_TO_VNET(td));
 	char ifname[16]; /* XXX LINUX_IFNAMSIZ */
 	struct ifnet *ifp;
 

Modified: head/sys/compat/linux/linux_ioctl.c
==============================================================================
--- head/sys/compat/linux/linux_ioctl.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/compat/linux/linux_ioctl.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -2059,7 +2059,6 @@ linux_ioctl_console(struct thread *td, s
 int
 linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
 {
-	INIT_VNET_NET(ifp->if_vnet);
 	struct ifnet *ifscan;
 	int ethno;
 
@@ -2093,7 +2092,6 @@ linux_ifname(struct ifnet *ifp, char *bu
 static struct ifnet *
 ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
 {
-	INIT_VNET_NET(TD_TO_VNET(td));
 	struct ifnet *ifp;
 	int len, unit;
 	char *ep;
@@ -2134,7 +2132,6 @@ ifname_linux_to_bsd(struct thread *td, c
 static int
 linux_ifconf(struct thread *td, struct ifconf *uifc)
 {
-	INIT_VNET_NET(TD_TO_VNET(td));
 #ifdef COMPAT_LINUX32
 	struct l_ifconf ifc;
 #else

Modified: head/sys/compat/linux/linux_socket.c
==============================================================================
--- head/sys/compat/linux/linux_socket.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/compat/linux/linux_socket.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/ip6.h>
 #include <netinet6/ip6_var.h>
 #include <netinet6/in6_var.h>
-#include <netinet6/vinet6.h>
 #endif
 
 #ifdef COMPAT_LINUX32
@@ -599,11 +598,6 @@ struct linux_socket_args {
 static int
 linux_socket(struct thread *td, struct linux_socket_args *args)
 {
-#ifdef INET6
-#ifndef KLD_MODULE
-	INIT_VNET_INET6(curvnet);
-#endif
-#endif
 	struct socket_args /* {
 		int domain;
 		int type;

Modified: head/sys/compat/svr4/svr4_sockio.c
==============================================================================
--- head/sys/compat/svr4/svr4_sockio.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/compat/svr4/svr4_sockio.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -89,7 +89,6 @@ svr4_sock_ioctl(fp, td, retval, fd, cmd,
 	switch (cmd) {
 	case SVR4_SIOCGIFNUM:
 		{
-			INIT_VNET_NET(curvnet);
 			struct ifnet *ifp;
 			struct ifaddr *ifa;
 			int ifnum = 0;

Modified: head/sys/conf/files
==============================================================================
--- head/sys/conf/files	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/conf/files	Tue Jul 14 22:48:30 2009	(r195699)
@@ -1989,7 +1989,7 @@ kern/kern_time.c		standard
 kern/kern_timeout.c		standard
 kern/kern_umtx.c		standard
 kern/kern_uuid.c		standard
-kern/kern_vimage.c		standard
+kern/kern_vimage.c		optional vimage
 kern/kern_xxx.c			standard
 kern/link_elf.c			standard
 kern/linker_if.m		standard
@@ -2231,6 +2231,7 @@ net/route.c			standard
 net/rtsock.c			standard
 net/slcompress.c		optional netgraph_vjc | sppp | \
 					 netgraph_sppp
+net/vnet.c			optional vimage
 net/zlib.c			optional crypto | geom_uzip | ipsec | \
 					 mxge | netgraph_deflate | \
 					 ddb_ctf

Modified: head/sys/conf/options
==============================================================================
--- head/sys/conf/options	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/conf/options	Tue Jul 14 22:48:30 2009	(r195699)
@@ -823,7 +823,6 @@ TDMA_TXRATE_11NG_DEFAULT	opt_tdma.h
 
 # Virtualize the network stack
 VIMAGE			opt_global.h
-VIMAGE_GLOBALS		opt_global.h
 
 # Common Flash Interface (CFI) options
 CFI_SUPPORT_STRATAFLASH	opt_cfi.h

Modified: head/sys/contrib/altq/altq/altq_subr.c
==============================================================================
--- head/sys/contrib/altq/altq/altq_subr.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/altq/altq/altq_subr.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -469,7 +469,6 @@ tbr_timeout(arg)
 	VNET_LIST_RLOCK();
 	VNET_FOREACH(vnet_iter) {
 		CURVNET_SET(vnet_iter);
-		INIT_VNET_NET(vnet_iter);
 #endif
 		for (ifp = TAILQ_FIRST(&V_ifnet); ifp;
 		    ifp = TAILQ_NEXT(ifp, if_list)) {

Modified: head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c
==============================================================================
--- head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -64,6 +64,7 @@ static const char rcsid[] = "@(#)$Id: ip
 #endif
 #if __FreeBSD_version >= 800044
 # include <sys/vimage.h>
+# include <netinet/tcp_var.h>
 #else
 #define V_path_mtu_discovery path_mtu_discovery
 #define V_ipforwarding ipforwarding
@@ -92,9 +93,6 @@ static const char rcsid[] = "@(#)$Id: ip
 #include <netinet/udp.h>
 #include <netinet/tcpip.h>
 #include <netinet/ip_icmp.h>
-#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800056)
-# include <netinet/vinet.h>
-#endif
 #ifndef _KERNEL
 # include "netinet/ipf.h"
 #endif
@@ -213,7 +211,6 @@ char *s;
 
 int ipfattach()
 {
-	INIT_VNET_INET(curvnet);
 #ifdef USE_SPL
 	int s;
 #endif
@@ -265,7 +262,6 @@ int ipfattach()
  */
 int ipfdetach()
 {
-	INIT_VNET_INET(curvnet);
 #ifdef USE_SPL
 	int s;
 #endif
@@ -654,7 +650,6 @@ static int fr_send_ip(fin, m, mpp)
 fr_info_t *fin;
 mb_t *m, **mpp;
 {
-	INIT_VNET_INET(curvnet);
 	fr_info_t fnew;
 	ip_t *ip, *oip;
 	int hlen;

Modified: head/sys/contrib/pf/net/pf.c
==============================================================================
--- head/sys/contrib/pf/net/pf.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/pf/net/pf.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -119,9 +119,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/udp_var.h>
 #include <netinet/icmp_var.h>
 #include <netinet/if_ether.h>
-#ifdef __FreeBSD__
-#include <netinet/vinet.h>
-#endif
 
 #ifndef __FreeBSD__
 #include <dev/rndvar.h>
@@ -141,7 +138,6 @@ __FBSDID("$FreeBSD$");
 #ifdef __FreeBSD__
 #include <netinet6/ip6_var.h>
 #include <netinet6/in6_pcb.h>
-#include <netinet6/vinet6.h>
 #endif
 #endif /* INET6 */
 
@@ -1762,7 +1758,6 @@ pf_send_tcp(const struct pf_rule *r, sa_
     u_int8_t flags, u_int16_t win, u_int16_t mss, u_int8_t ttl, int tag,
     u_int16_t rtag, struct ether_header *eh, struct ifnet *ifp)
 {
-	INIT_VNET_INET(curvnet);
 	struct mbuf	*m;
 	int		 len, tlen;
 #ifdef INET
@@ -2926,7 +2921,6 @@ pf_socket_lookup(int direction, struct p
 pf_socket_lookup(int direction, struct pf_pdesc *pd)
 #endif
 {
-	INIT_VNET_INET(curvnet);
 	struct pf_addr		*saddr, *daddr;
 	u_int16_t		 sport, dport;
 #ifdef __FreeBSD__
@@ -3096,7 +3090,6 @@ pf_get_wscale(struct mbuf *m, int off, u
 u_int16_t
 pf_get_mss(struct mbuf *m, int off, u_int16_t th_off, sa_family_t af)
 {
-	INIT_VNET_INET(curvnet);
 	int		 hlen;
 	u_int8_t	 hdr[60];
 	u_int8_t	*opt, optlen;
@@ -3136,7 +3129,6 @@ u_int16_t
 pf_calc_mss(struct pf_addr *addr, sa_family_t af, u_int16_t offer)
 {
 #ifdef INET
-	INIT_VNET_INET(curvnet);
 	struct sockaddr_in	*dst;
 	struct route		 ro;
 #endif /* INET */
@@ -3239,7 +3231,6 @@ pf_test_tcp(struct pf_rule **rm, struct 
     struct ifqueue *ifq)
 #endif
 {
-	INIT_VNET_INET(curvnet);
 	struct pf_rule		*nr = NULL;
 	struct pf_addr		*saddr = pd->src, *daddr = pd->dst;
 	struct tcphdr		*th = pd->hdr.tcp;
@@ -6094,7 +6085,6 @@ void
 pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
     struct pf_state *s, struct pf_pdesc *pd)
 {
-	INIT_VNET_INET(curvnet);
 	struct mbuf		*m0, *m1;
 	struct route		 iproute;
 	struct route		*ro = NULL;
@@ -6633,26 +6623,22 @@ pf_check_proto_cksum(struct mbuf *m, int
 		switch (p) {
 		case IPPROTO_TCP:
 		    {
-			INIT_VNET_INET(curvnet);
 			TCPSTAT_INC(tcps_rcvbadsum);
 			break;
 		    }
 		case IPPROTO_UDP:
 		    {
-			INIT_VNET_INET(curvnet);
 			UDPSTAT_INC(udps_badsum);
 			break;
 		    }
 		case IPPROTO_ICMP:
 		    {
-			INIT_VNET_INET(curvnet);
 			ICMPSTAT_INC(icps_checksum);
 			break;
 		    }
 #ifdef INET6
 		case IPPROTO_ICMPV6:
 		    {
-			INIT_VNET_INET6(curvnet);
 			ICMP6STAT_INC(icp6s_checksum);
 			break;
 		    }

Modified: head/sys/contrib/pf/net/pf_if.c
==============================================================================
--- head/sys/contrib/pf/net/pf_if.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/pf/net/pf_if.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -115,9 +115,6 @@ void		 pfi_change_group_event(void * __u
 void		 pfi_detach_group_event(void * __unused, struct ifg_group *);
 void		 pfi_ifaddr_event(void * __unused, struct ifnet *);
 
-#ifdef VIMAGE_GLOBALS
-extern struct ifgrouphead ifg_head;
-#endif
 #endif
 
 RB_PROTOTYPE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
@@ -129,7 +126,6 @@ RB_GENERATE(pfi_ifhead, pfi_kif, pfik_tr
 void
 pfi_initialize(void)
 {
-	INIT_VNET_NET(curvnet);
 
 	if (pfi_all != NULL)	/* already initialized */
 		return;

Modified: head/sys/contrib/pf/net/pf_ioctl.c
==============================================================================
--- head/sys/contrib/pf/net/pf_ioctl.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/pf/net/pf_ioctl.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -3703,7 +3703,6 @@ static int
 pf_check6_in(void *arg, struct mbuf **m, struct ifnet *ifp, int dir,
     struct inpcb *inp)
 {
-	INIT_VNET_NET(curvnet);
 
 	/*
 	 * IPv6 is not affected by ip_len/ip_off byte order changes.

Modified: head/sys/contrib/pf/net/pf_subr.c
==============================================================================
--- head/sys/contrib/pf/net/pf_subr.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/pf/net/pf_subr.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
 #include <netinet/if_ether.h>
-#include <netinet/vinet.h>
 #include <net/pfvar.h>
 
 /*

Modified: head/sys/contrib/pf/net/pfvar.h
==============================================================================
--- head/sys/contrib/pf/net/pfvar.h	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/pf/net/pfvar.h	Tue Jul 14 22:48:30 2009	(r195699)
@@ -1855,12 +1855,4 @@ int	pf_osfp_match(struct pf_osfp_enlist 
 struct pf_os_fingerprint *
 	pf_osfp_validate(void);
 
-/*
- * Symbol translation macros
- */
-#define	INIT_VNET_PF(vnet) \
-	INIT_FROM_VNET(vnet, VNET_MOD_PF, struct vnet_pf, vnet_pf)
-
-#define	VNET_PF(sym)	VSYM(vnet_pf, sym)
-
 #endif /* _NET_PFVAR_H_ */

Modified: head/sys/contrib/rdma/rdma_cma.c
==============================================================================
--- head/sys/contrib/rdma/rdma_cma.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/contrib/rdma/rdma_cma.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
 #include <net/if.h>
 #include <netinet/in.h>
 #include <netinet/in_pcb.h>
-#include <netinet/vinet.h>
 
 #include <contrib/rdma/rdma_cm.h>
 #include <contrib/rdma/ib_cache.h>
@@ -1950,7 +1949,6 @@ err1:
 
 static int cma_alloc_any_port(struct kvl *ps, struct rdma_id_private *id_priv)
 {
-	INIT_VNET_INET(curvnet);
 	struct rdma_bind_list *bind_list;
 	int port, ret;
 
@@ -1995,7 +1993,6 @@ err1:
 
 static int cma_use_port(struct kvl *ps, struct rdma_id_private *id_priv)
 {
-	INIT_VNET_INET(curvnet);
 	struct rdma_id_private *cur_id;
 	struct sockaddr_in *sin, *cur_sin;
 	struct rdma_bind_list *bind_list;
@@ -2915,7 +2912,6 @@ static void cma_remove_one(struct ib_dev
 
 static int cma_init(void)
 {
-	INIT_VNET_INET(curvnet);
 	int ret;
 
 	LIST_INIT(&listen_any_list);

Modified: head/sys/ddb/db_expr.c
==============================================================================
--- head/sys/ddb/db_expr.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/ddb/db_expr.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -51,7 +51,9 @@ db_term(db_expr_t *valuep)
 
 	t = db_read_token();
 	if (t == tIDENT) {
-	    if (!db_value_of_name(db_tok_string, valuep)) {
+	    if (!db_value_of_name(db_tok_string, valuep) &&
+		!db_value_of_name_pcpu(db_tok_string, valuep) &&
+		!db_value_of_name_vnet(db_tok_string, valuep)) {
 		db_error("Symbol not found\n");
 		/*NOTREACHED*/
 	    }

Modified: head/sys/ddb/db_sym.c
==============================================================================
--- head/sys/ddb/db_sym.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/ddb/db_sym.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -32,10 +32,15 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/smp.h>
 #include <sys/systm.h>
+#include <sys/vimage.h>
+
+#include <net/vnet.h>
 
 #include <ddb/ddb.h>
 #include <ddb/db_sym.h>
+#include <ddb/db_variables.h>
 
 #include <opt_ddb.h>
 
@@ -56,6 +61,117 @@ static char		*db_qualify(c_db_sym_t sym,
 static boolean_t	db_symbol_is_ambiguous(c_db_sym_t sym);
 static boolean_t	db_line_at_pc(c_db_sym_t, char **, int *, db_expr_t);
 
+static int db_cpu = -1;
+
+#ifdef VIMAGE
+extern uintptr_t	*__start_set_vnet;
+extern uintptr_t	*__stop_set_vnet;
+
+#define	VNET_START	(uintptr_t)&__start_set_vnet
+#define	VNET_STOP	(uintptr_t)&__stop_set_vnet
+
+static void *db_vnet = NULL;
+#endif
+
+/*
+ * Validate the CPU number used to interpret per-CPU variables so we can
+ * avoid later confusion if an invalid CPU is requested.
+ */
+int
+db_var_db_cpu(struct db_variable *vp, db_expr_t *valuep, int op)
+{
+
+	switch (op) {
+	case DB_VAR_GET:
+		*valuep = db_cpu;
+		return (1);
+
+	case DB_VAR_SET:
+		if (*(int *)valuep < -1 && *(int *)valuep > mp_maxid) {
+			db_printf("Invalid value: %d", *(int*)valuep);
+			return (0);
+		}
+		db_cpu = *(int *)valuep;
+		return (1);
+
+	default:
+		db_printf("db_var_db_cpu: unknown operation\n");
+		return (0);
+	}
+}
+
+/*
+ * Read-only variable reporting the current CPU, which is what we use when
+ * db_cpu is set to -1.
+ */
+int
+db_var_curcpu(struct db_variable *vp, db_expr_t *valuep, int op)
+{
+
+	switch (op) {
+	case DB_VAR_GET:
+		*valuep = curcpu;
+		return (1);
+
+	case DB_VAR_SET:
+		db_printf("Read-only variable.\n");
+		return (0);
+
+	default:
+		db_printf("db_var_curcpu: unknown operation\n");
+		return (0);
+	}
+}
+
+#ifdef VIMAGE
+/*
+ * Validate the virtual network pointer used to interpret per-vnet global
+ * variable expansion.  Right now we don't do much here, really we should
+ * walk the global vnet list to check it's an OK pointer.
+ */
+int
+db_var_db_vnet(struct db_variable *vp, db_expr_t *valuep, int op)
+{
+
+	switch (op) {
+	case DB_VAR_GET:
+		*valuep = (db_expr_t)db_vnet;
+		return (1);
+
+	case DB_VAR_SET:
+		db_vnet = *(void **)valuep;
+		return (1);
+
+	default:
+		db_printf("db_var_db_vnet: unknown operation\n");
+		return (0);
+	}
+}
+
+/*
+ * Read-only variable reporting the current vnet, which is what we use when
+ * db_vnet is set to NULL.
+ */
+int
+db_var_curvnet(struct db_variable *vp, db_expr_t *valuep, int op)
+{
+
+	switch (op) {
+	case DB_VAR_GET:
+		*valuep = (db_expr_t)curvnet;
+		return (1);
+
+	case DB_VAR_SET:
+		db_printf("Read-only variable.\n");
+		return (0);
+
+	default:
+		db_printf("db_var_curcpu: unknown operation\n");
+		return (0);
+	}
+}
+#endif
+
 /*
  * Add symbol table, with given name, to list of symbol tables.
  */
@@ -125,6 +241,59 @@ db_value_of_name(name, valuep)
 	return (TRUE);
 }
 
+boolean_t
+db_value_of_name_pcpu(name, valuep)
+	const char	*name;
+	db_expr_t	*valuep;
+{
+	static char     tmp[256];
+	db_expr_t	value;
+	c_db_sym_t	sym;
+	int		cpu;
+
+	if (db_cpu != -1)
+		cpu = db_cpu;
+	else
+		cpu = curcpu;
+	snprintf(tmp, sizeof(tmp), "pcpu_entry_%s", name);
+	sym = db_lookup(tmp);
+	if (sym == C_DB_SYM_NULL)
+		return (FALSE);
+	db_symbol_values(sym, &name, &value);
+	if (value < DPCPU_START || value >= DPCPU_STOP)
+		return (FALSE);
+	*valuep = (db_expr_t)((uintptr_t)value + dpcpu_off[cpu]);
+	return (TRUE);
+}
+
+boolean_t
+db_value_of_name_vnet(name, valuep)
+	const char	*name;
+	db_expr_t	*valuep;
+{
+#ifdef VIMAGE
+	static char     tmp[256];
+	db_expr_t	value;
+	c_db_sym_t	sym;
+	struct vnet	*vnet;
+
+	if (db_vnet != NULL)
+		vnet = db_vnet;
+	else
+		vnet = curvnet;
+	snprintf(tmp, sizeof(tmp), "vnet_entry_%s", name);
+	sym = db_lookup(tmp);
+	if (sym == C_DB_SYM_NULL)
+		return (FALSE);
+	db_symbol_values(sym, &name, &value);
+	if (value < VNET_START || value >= VNET_STOP)
+		return (FALSE);
+	*valuep = (db_expr_t)((uintptr_t)value + vnet->vnet_data_base);
+	return (TRUE);
+#else
+	return (FALSE);
+#endif
+}
 
 /*
  * Lookup a symbol.

Modified: head/sys/ddb/db_variables.c
==============================================================================
--- head/sys/ddb/db_variables.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/ddb/db_variables.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -46,6 +46,12 @@ static struct db_variable db_vars[] = {
 	{ "maxwidth",	&db_max_width, FCN_NULL },
 	{ "tabstops",	&db_tab_stop_width, FCN_NULL },
 	{ "lines",	&db_lines_per_page, FCN_NULL },
+	{ "curcpu",	NULL, db_var_curcpu },
+	{ "db_cpu",	NULL, db_var_db_cpu },
+#ifdef VIMAGE
+	{ "curvnet",	NULL, db_var_curvnet },
+	{ "db_vnet",	NULL, db_var_db_vnet },
+#endif
 };
 static struct db_variable *db_evars =
 	db_vars + sizeof(db_vars)/sizeof(db_vars[0]);

Modified: head/sys/ddb/db_variables.h
==============================================================================
--- head/sys/ddb/db_variables.h	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/ddb/db_variables.h	Tue Jul 14 22:48:30 2009	(r195699)
@@ -52,6 +52,11 @@ struct db_variable {
 extern struct db_variable	db_regs[];	/* machine registers */
 extern struct db_variable	*db_eregs;
 
+extern db_varfcn_t	db_var_curcpu;		/* DPCPU default CPU */
+extern db_varfcn_t	db_var_curvnet;		/* Default vnet */
+extern db_varfcn_t	db_var_db_cpu;		/* DPCPU active CPU */
+extern db_varfcn_t	db_var_db_vnet;		/* Active vnet */
+
 int db_read_variable(struct db_variable *, db_expr_t *);
 int db_write_variable(struct db_variable *, db_expr_t);
 

Modified: head/sys/ddb/ddb.h
==============================================================================
--- head/sys/ddb/ddb.h	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/ddb/ddb.h	Tue Jul 14 22:48:30 2009	(r195699)
@@ -213,6 +213,8 @@ boolean_t	db_stop_at_pc(boolean_t *is_br
 void		db_trace_self(void);
 int		db_trace_thread(struct thread *, int);
 int		db_value_of_name(const char *name, db_expr_t *valuep);
+int		db_value_of_name_pcpu(const char *name, db_expr_t *valuep);
+int		db_value_of_name_vnet(const char *name, db_expr_t *valuep);
 int		db_write_bytes(vm_offset_t addr, size_t size, char *data);
 void		db_command_register(struct command_table *, struct command *);
 void		db_command_unregister(struct command_table *, struct command *);

Modified: head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c
==============================================================================
--- head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/dev/cxgb/ulp/iw_cxgb/iw_cxgb.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -240,7 +240,6 @@ iwch_init_module(void)
 	VNET_LIST_RLOCK();
 	VNET_FOREACH(vnet_iter) {
 		CURVNET_SET(vnet_iter); /* XXX CURVNET_SET_QUIET() ? */
-		INIT_VNET_NET(vnet_iter);
 		TAILQ_FOREACH(ifp, &V_ifnet, if_link)
 			(void)ifaddr_event_handler(NULL, ifp);
 		CURVNET_RESTORE();

Modified: head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c
==============================================================================
--- head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/dev/cxgb/ulp/tom/cxgb_cpl_io.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -78,9 +78,6 @@ __FBSDID("$FreeBSD$");
 #include <netinet/tcp_seq.h>
 #include <netinet/tcp_syncache.h>
 #include <netinet/tcp_timer.h>
-#if __FreeBSD_version >= 800056
-#include <netinet/vinet.h>
-#endif
 #include <net/route.h>
 
 #include <t3cdev.h>
@@ -274,7 +271,6 @@ mk_tid_release(struct mbuf *m, const str
 static inline void
 make_tx_data_wr(struct socket *so, struct mbuf *m, int len, struct mbuf *tail)
 {
-	INIT_VNET_INET(so->so_vnet);
 	struct tcpcb *tp = so_sototcpcb(so);
 	struct toepcb *toep = tp->t_toe;
 	struct tx_data_wr *req;
@@ -1219,7 +1215,6 @@ install_offload_ops(struct socket *so)
 static __inline int
 select_rcv_wscale(int space, struct vnet *vnet)
 {
-	INIT_VNET_INET(vnet);
 	int wscale = 0;
 
 	if (space > MAX_RCV_WND)
@@ -1237,7 +1232,6 @@ select_rcv_wscale(int space, struct vnet
 static unsigned long
 select_rcv_wnd(struct toedev *dev, struct socket *so)
 {
-	INIT_VNET_INET(so->so_vnet);
 	struct tom_data *d = TOM_DATA(dev);
 	unsigned int wnd;
 	unsigned int max_rcv_wnd;
@@ -3780,7 +3774,6 @@ fixup_and_send_ofo(struct toepcb *toep)
 static void
 socket_act_establish(struct socket *so, struct mbuf *m)
 {
-	INIT_VNET_INET(so->so_vnet);
 	struct cpl_act_establish *req = cplhdr(m);
 	u32 rcv_isn = ntohl(req->rcv_isn);	/* real RCV_ISN + 1 */
 	struct tcpcb *tp = so_sototcpcb(so);

Modified: head/sys/fs/nfs/nfsport.h
==============================================================================
--- head/sys/fs/nfs/nfsport.h	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/fs/nfs/nfsport.h	Tue Jul 14 22:48:30 2009	(r195699)
@@ -95,7 +95,6 @@
 #include <netinet/tcp_seq.h>
 #include <netinet/tcp_timer.h>
 #include <netinet/tcp_var.h>
-#include <netinet/vinet.h>
 #include <machine/in_cksum.h>
 #include <crypto/des/des.h>
 #include <sys/md5.h>

Modified: head/sys/fs/nfsclient/nfs_clvnops.c
==============================================================================
--- head/sys/fs/nfsclient/nfs_clvnops.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/fs/nfsclient/nfs_clvnops.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
 #include <fs/nfsclient/nfs_lock.h>
 
 #include <net/if.h>
-#include <netinet/vinet.h>
 #include <netinet/in.h>
 #include <netinet/in_var.h>
 
@@ -1401,7 +1400,6 @@ again:
 
 	CURVNET_SET(P_TO_VNET(&proc0));
 #ifdef INET
-	INIT_VNET_INET(curvnet);
 	IN_IFADDR_RLOCK();
 	if (!TAILQ_EMPTY(&V_in_ifaddrhead))
 		cverf.lval[0] = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr;

Modified: head/sys/fs/nfsserver/nfs_nfsdport.c
==============================================================================
--- head/sys/fs/nfsserver/nfs_nfsdport.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/fs/nfsserver/nfs_nfsdport.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -2671,7 +2671,6 @@ nfsrv_v4rootexport(void *argp, struct uc
 int
 nfsrv_getsocksndseq(struct socket *so, tcp_seq *maxp, tcp_seq *unap)
 {
-	INIT_VNET_INET(so->so_vnet);
 	struct inpcb *inp;
 	struct tcpcb *tp;
 	int error = EPIPE;

Modified: head/sys/kern/kern_linker.c
==============================================================================
--- head/sys/kern/kern_linker.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/kern/kern_linker.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -1334,23 +1334,8 @@ kldsym(struct thread *td, struct kldsym_
 				break;
 			}
 		}
-#ifndef VIMAGE_GLOBALS
-		/*
-		 * If the symbol is not found in global namespace,
-		 * try to look it up in the current vimage namespace.
-		 */
-		if (lf == NULL) {
-			CURVNET_SET(TD_TO_VNET(td));
-			error = vi_symlookup(&lookup, symstr);
-			CURVNET_RESTORE();
-			if (error == 0)
-				error = copyout(&lookup, uap->data,
-						sizeof(lookup));
-		}
-#else
 		if (lf == NULL)
 			error = ENOENT;
-#endif
 	}
 	KLD_UNLOCK();
 out:

Modified: head/sys/kern/kern_poll.c
==============================================================================
--- head/sys/kern/kern_poll.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/kern/kern_poll.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -545,7 +545,6 @@ ether_poll_deregister(struct ifnet *ifp)
 static int
 poll_switch(SYSCTL_HANDLER_ARGS)
 {
-	INIT_VNET_NET(curvnet);
 	struct ifnet *ifp;
 	int error;
 	int val = polling;

Modified: head/sys/kern/kern_sysctl.c
==============================================================================
--- head/sys/kern/kern_sysctl.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/kern/kern_sysctl.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -59,6 +59,8 @@ __FBSDID("$FreeBSD$");
 #include <sys/ktrace.h>
 #endif
 
+#include <net/vnet.h>
+
 #include <security/mac/mac_framework.h>
 
 #include <vm/vm.h>
@@ -936,33 +938,9 @@ sysctl_handle_int(SYSCTL_HANDLER_ARGS)
 	return (error);
 }
 
-#ifdef VIMAGE
-int
-sysctl_handle_v_int(SYSCTL_HANDLER_ARGS)
-{
-	int tmpout, error = 0;
- 
-	SYSCTL_RESOLVE_V_ARG1();
- 
-	/*
-	 * Attempt to get a coherent snapshot by making a copy of the data.
-	 */
-	tmpout = *(int *)arg1;
-	error = SYSCTL_OUT(req, &tmpout, sizeof(int));
-
-	if (error || !req->newptr)
-		return (error);
-
-	if (!arg1)
-		error = EPERM;
-	else
-		error = SYSCTL_IN(req, arg1, sizeof(int));
-	return (error);
-}
-#endif
-
 /*
  * Based on on sysctl_handle_int() convert milliseconds into ticks.
+ * Note: this is used by TCP.
  */
 
 int
@@ -970,8 +948,11 @@ sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS
 {
 	int error, s, tt;
 
-	SYSCTL_RESOLVE_V_ARG1();
-
+#ifdef VIMAGE
+	if (arg1 != NULL)
+		arg1 = (void *)(TD_TO_VNET(req->td)->vnet_data_base +
+		    (uintptr_t)arg1);
+#endif
 	tt = *(int *)arg1;
 	s = (int)((int64_t)tt * 1000 / hz);
 
@@ -1097,47 +1078,6 @@ retry:
 	return (error);
 }
 
-#ifdef VIMAGE
-int
-sysctl_handle_v_string(SYSCTL_HANDLER_ARGS)
-{
-	int error=0;
-	char *tmparg;
-	size_t outlen;
-
-	SYSCTL_RESOLVE_V_ARG1();
-
-	/*
-	 * Attempt to get a coherent snapshot by copying to a
-	 * temporary kernel buffer.
-	 */
-retry:
-	outlen = strlen((char *)arg1)+1;
-	tmparg = malloc(outlen, M_SYSCTLTMP, M_WAITOK);
-
-	if (strlcpy(tmparg, (char *)arg1, outlen) >= outlen) {
-		free(tmparg, M_SYSCTLTMP);
-		goto retry;
-	}
-
-	error = SYSCTL_OUT(req, tmparg, outlen);
-	free(tmparg, M_SYSCTLTMP);
-
-	if (error || !req->newptr)
-		return (error);
-
-	if ((req->newlen - req->newidx) >= arg2) {
-		error = EINVAL;
-	} else {
-		arg2 = (req->newlen - req->newidx);
-		error = SYSCTL_IN(req, arg1, arg2);
-		((char *)arg1)[arg2] = '\0';
-	}
-
-	return (error);
-}
-#endif
-
 /*
  * Handle any kind of opaque data.
  * arg1 points to it, arg2 is the size.
@@ -1175,35 +1115,6 @@ retry:
 	return (error);
 }
 
-#ifdef VIMAGE
-int
-sysctl_handle_v_opaque(SYSCTL_HANDLER_ARGS)
-{
-	int error, tries;
-	u_int generation;
-	struct sysctl_req req2;
-
-	SYSCTL_RESOLVE_V_ARG1();
-
-	tries = 0;
-	req2 = *req;
-retry:
-	generation = curthread->td_generation;
-	error = SYSCTL_OUT(req, arg1, arg2);
-	if (error)
-		return (error);
-	tries++;
-	if (generation != curthread->td_generation && tries < 3) {
-		*req = req2;
-		goto retry;
-	}
-
-	error = SYSCTL_IN(req, arg1, arg2);
-
-	return (error);
-}
-#endif
-
 /*
  * Transfer functions to/from kernel space.
  * XXX: rather untested at this point

Modified: head/sys/kern/kern_uuid.c
==============================================================================
--- head/sys/kern/kern_uuid.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/kern/kern_uuid.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -89,7 +89,6 @@ MTX_SYSINIT(uuid_lock, &uuid_mutex, "UUI
 static void
 uuid_node(uint16_t *node)
 {
-	INIT_VNET_NET(curvnet);
 	struct ifnet *ifp;
 	struct ifaddr *ifa;
 	struct sockaddr_dl *sdl;

Modified: head/sys/kern/kern_vimage.c
==============================================================================
--- head/sys/kern/kern_vimage.c	Tue Jul 14 22:16:32 2009	(r195698)
+++ head/sys/kern/kern_vimage.c	Tue Jul 14 22:48:30 2009	(r195699)
@@ -53,8 +53,6 @@ __FBSDID("$FreeBSD$");
 #include <net/route.h>
 #include <net/vnet.h>
 
-#ifndef VIMAGE_GLOBALS
-
 MALLOC_DEFINE(M_VIMAGE, "vimage", "vimage resource container");
 MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
 MALLOC_DEFINE(M_VPROCG, "vprocg", "process group control block");
@@ -65,13 +63,11 @@ static void vnet_mod_complete_registrati
 static int vnet_mod_constructor(struct vnet_modlink *);
 static int vnet_mod_destructor(struct vnet_modlink *);
 
-#ifdef VIMAGE
 static struct vimage *vi_alloc(struct vimage *, char *);
 static int vi_destroy(struct vimage *);
 static struct vimage *vimage_get_next(struct vimage *, struct vimage *, int);
 static void vimage_relative_name(struct vimage *, struct vimage *,
     char *, int);
-#endif
 
 #define	VNET_LIST_WLOCK()						\
 	mtx_lock(&vnet_list_refc_mtx);					\
@@ -81,17 +77,11 @@ static void vimage_relative_name(struct 
 #define	VNET_LIST_WUNLOCK()						\
 	mtx_unlock(&vnet_list_refc_mtx);
 
-#ifdef VIMAGE
 struct vimage_list_head vimage_head;
 struct vnet_list_head vnet_head;
 struct vprocg_list_head vprocg_head;
-#else
-#ifndef VIMAGE_GLOBALS
 struct vprocg vprocg_0;
-#endif
-#endif
 
-#ifdef VIMAGE
 struct cv vnet_list_condvar;
 struct mtx vnet_list_refc_mtx;
 int vnet_list_refc = 0;
@@ -100,9 +90,7 @@ static u_int last_vi_id = 0;
 static u_int last_vprocg_id = 0;
 
 struct vnet *vnet0;
-#endif
 
-#ifdef VIMAGE
 
 /*
  * Move an ifnet to or from another vnet, specified by the jail id.  If a
@@ -396,8 +384,6 @@ vimage_get_next(struct vimage *top, stru
 	return (NULL);
 }
 
-#endif /* VIMAGE */ /* User interface block */
-
 
 /*
  * Kernel interfaces and handlers.
@@ -540,25 +526,11 @@ vnet_mod_constructor(struct vnet_modlink
 	if (vml->vml_iarg)
 		printf("/%s", vml->vml_iname);
 	printf(": ");
-#ifdef VIMAGE
-	if (vmi->vmi_size)
-		printf("malloc(%zu); ", vmi->vmi_size);
-#endif
 	if (vmi->vmi_iattach != NULL)
 		printf("iattach()");
 	printf("\n");
 #endif
 
-#ifdef VIMAGE
-	if (vmi->vmi_size) {
-		void *mem = malloc(vmi->vmi_size, M_VNET,
-		    M_NOWAIT | M_ZERO);
-		if (mem == NULL) /* XXX should return error, not panic. */
-			panic("malloc for %s\n", vmi->vmi_name);
-		curvnet->mod_data[vmi->vmi_id] = mem;
-	}
-#endif
-
 	if (vmi->vmi_iattach != NULL)
 		vmi->vmi_iattach(vml->vml_iarg);
 
@@ -577,63 +549,15 @@ vnet_mod_destructor(struct vnet_modlink 
 	printf(": ");
 	if (vmi->vmi_idetach != NULL)
 		printf("idetach(); ");
-#ifdef VIMAGE
-	if (vmi->vmi_size)
-		printf("free()");
-#endif
 	printf("\n");
 #endif
 
 	if (vmi->vmi_idetach)
 		vmi->vmi_idetach(vml->vml_iarg);
 
-#ifdef VIMAGE
-	if (vmi->vmi_size) {
-		if (curvnet->mod_data[vmi->vmi_id] == NULL)
-			panic("vi_destroy: %s\n", vmi->vmi_name);
-		free(curvnet->mod_data[vmi->vmi_id], M_VNET);

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200907142248.n6EMmUVd073453>