Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 May 2009 12:03:12 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 161614 for review
Message-ID:  <200905051203.n45C3CPS039594@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=161614

Change 161614 by zec@zec_tpx32 on 2009/05/05 12:03:05

	Unbreak GENERIC builds (VIMAGE still broken).

Affected files ...

.. //depot/projects/vimage/src/sys/kern/kern_vimage.c#87 edit
.. //depot/projects/vimage/src/sys/kern/uipc_socket.c#33 edit
.. //depot/projects/vimage/src/sys/net/if_var.h#36 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#91 edit

Differences ...

==== //depot/projects/vimage/src/sys/kern/kern_vimage.c#87 (text+ko) ====


==== //depot/projects/vimage/src/sys/kern/uipc_socket.c#33 (text+ko) ====

@@ -2065,7 +2065,7 @@
 soshutdown(struct socket *so, int how)
 {
 	struct protosw *pr = so->so_proto;
-	int error;
+	int error = 0;
 
 	if (!(how == SHUT_RD || how == SHUT_WR || how == SHUT_RDWR))
 		return (EINVAL);
@@ -2075,13 +2075,11 @@
 	if (how != SHUT_WR)
 		sorflush(so);
 	if (how != SHUT_RD) {
-		int error;
 		CURVNET_SET(so->so_vnet);
 		error = (*pr->pr_usrreqs->pru_shutdown)(so);
 		CURVNET_RESTORE();
-		return (error);
 	}
-	return (0);
+	return (error);
 }
 
 void

==== //depot/projects/vimage/src/sys/net/if_var.h#36 (text+ko) ====

@@ -172,7 +172,6 @@
 		(struct ifnet *, struct mbuf *);
 	void	(*if_reassign)		/* reassign to vnet routine */
 		(struct ifnet *, struct vnet *, char *);
-	struct	vnet *if_vnet;		/* network stack instance */
 	struct	vnet *if_home_vnet;	/* where this ifnet originates from */
 	struct	ifaddr	*if_addr;	/* pointer to link-level address */
 	void	*if_llsoftc;		/* link layer softc */

==== //depot/projects/vimage/src/sys/sys/vimage.h#91 (text+ko) ====

@@ -34,15 +34,8 @@
 #define	_SYS_VIMAGE_H_
 
 #include <sys/proc.h>
-#include <sys/lock.h>
-#include <sys/proc.h>
-#include <sys/condvar.h>
-#include <sys/mutex.h>
+#include <sys/queue.h>
 
-#ifdef INVARIANTS
-#define VNET_DEBUG
-#endif
-
 #if defined(VIMAGE) && defined(VIMAGE_GLOBALS)
 #error "You cannot have both option VIMAGE and option VIMAGE_GLOBALS!"
 #endif
@@ -54,31 +47,10 @@
 typedef int vnet_attach_fn(const void *);
 typedef int vnet_detach_fn(const void *);
 
-struct	vimage;
-struct	vprocg;
-struct	vnet;
-struct	vi_req;
-struct	kld_sym_lookup; 
+#ifndef VIMAGE_GLOBALS
 
-struct	ifnet;		/* XXX must go away */
-
-#ifdef VIMAGE_GLOBALS
-#define	VSYM(base, sym) (sym)
-#else
-#ifdef VIMAGE
-#define VSYM(base, sym) ((base)->_##sym)
-#else
-#define	VSYM(base, sym) (base ## _0._ ## sym)
-#endif
-#endif
+struct kld_sym_lookup;
 
-#ifdef VIMAGE
-#define curvnet curthread->td_vnet
-#else
-#define curvnet NULL
-#endif
-
-#ifndef VIMAGE_GLOBALS
 struct vnet_symmap {
 	char	*name;
 	size_t	 offset;
@@ -104,18 +76,6 @@
 	const char			*vml_iname;
 };
 
-#ifdef VIMAGE
-#define	VNET_SYMMAP(mod, name)						\
-	{ #name, offsetof(struct vnet_ ## mod, _ ## name),		\
-	sizeof(((struct vnet_ ## mod *) curthread)->_ ## name) }
-#else
-#define	VNET_SYMMAP(mod, name)						\
-	{ #name, (size_t) &(vnet_ ## mod ## _0._ ## name),		\
-	sizeof(vnet_ ## mod ## _0._ ## name) }
-#endif
-
-#define	VNET_SYMMAP_END		{ NULL, 0 }
-
 /* Stateful modules. */
 #define	VNET_MOD_NET		 0	/* MUST be 0 - implicit dependency */
 #define	VNET_MOD_NETGRAPH	 1
@@ -162,35 +122,17 @@
 #define	V_MOD_vnet_gif		VNET_MOD_GIF
 #define	V_MOD_vnet_ipsec	VNET_MOD_IPSEC
 
-#define basevnet thread0.td_ucred->cr_vimage->v_net
-#define basevprocg thread0.td_ucred->cr_vimage->v_procg
-#define basevcpu thread0.td_ucred->cr_vimage->v_cpu
-
-#define	V_GLOBAL	0
-#define	V_NET		1
-#define	V_PROCG		2
-#define	V_CPU		3
-
-#define V_MOD_vprocg		0
-#define V_MOD_vcpu		0
+int	vi_symlookup(struct kld_sym_lookup *, char *);
+void	vnet_mod_register(const struct vnet_modinfo *);
+void	vnet_mod_register_multi(const struct vnet_modinfo *, void *, char *);
+void	vnet_mod_deregister(const struct vnet_modinfo *);
+void	vnet_mod_deregister_multi(const struct vnet_modinfo *, void *, char *);
 
-#ifdef VIMAGE
-struct vnet {
-	void	*mod_data[VNET_MOD_MAX];
-
-	u_int	vnet_ref;		/* reference count */
-	LIST_ENTRY(vnet) vnet_le;	/* all vnets list */
-	u_int	vnet_id;		/* ID num */
-
-	u_int	ifccnt;
-	u_int	sockcnt;
-
-	u_int	vnet_magic_n;
-};
-#endif /* VIMAGE */
 #endif /* !VIMAGE_GLOBALS */
 
-#define VNET_MAGIC_N 0x3e0d8f29
+#ifdef VIMAGE_GLOBALS
+#define	VSYM(base, sym) (sym)
+#else
 #ifdef VIMAGE
 #define	VSYM(base, sym) ((base)->_ ## sym)
 #else
@@ -225,6 +167,16 @@
 };
 #endif
 
+struct vprocg {
+	LIST_ENTRY(vprocg) vprocg_le;
+	u_int		vprocg_ref;	/* reference count */
+	u_int		vprocg_id;	/* ID num */
+	u_int		nprocs;
+	char		_hostname[MAXHOSTNAMELEN];
+	char		_domainname[MAXHOSTNAMELEN];
+	int		_morphing_symlinks;
+};
+
 #ifdef VIMAGE
 #define curvnet curthread->td_vnet
 #else
@@ -285,62 +237,37 @@
 
 #ifdef VIMAGE
 #ifdef VNET_DEBUG
- 
-#define INIT_FROM_VNET(vnet, modindex, modtype, sym)			\
-	if (vnet != curvnet) 						\
+#define	INIT_FROM_VNET(vnet, modindex, modtype, sym)			\
+	if (vnet == NULL || vnet != curvnet)				\
 		panic("in %s:%d %s()\n vnet=%p curvnet=%p",		\
 		    __FILE__, __LINE__, __FUNCTION__,			\
 		    vnet, curvnet);					\
 	modtype *sym = (vnet)->mod_data[modindex];
 #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;
- 
-#define INIT_FROM_VNET(vnet, modindex, modtype, sym)			\
+#define	INIT_FROM_VNET(vnet, modindex, modtype, sym)			\
 	modtype *sym = (vnet)->mod_data[modindex];
 #endif /* !VNET_DEBUG */
+#else /* !VIMAGE */
+#define	INIT_FROM_VNET(vnet, modindex, modtype, sym)
+#endif
 
-#define VNET_ITERATOR_DECL(arg)	struct vnet *arg;
-#define VNET_FOREACH(arg) LIST_FOREACH(arg, &vnet_head, vnet_le)
+#ifdef VIMAGE
+LIST_HEAD(vnet_list_head, vnet);
+extern struct vnet_list_head vnet_head;
+#define	VNET_ITERATOR_DECL(arg) struct vnet *arg;
+#define	VNET_FOREACH(arg) LIST_FOREACH(arg, &vnet_head, vnet_le)
+#else
+#define	VNET_ITERATOR_DECL(arg)
+#define	VNET_FOREACH(arg)
+#endif
 
-#define INIT_VPROCG(arg)	struct vprocg *vprocg = (arg);
-
-#define VPROCG_ITERLOOP_BEGIN()						\
-	struct vprocg *vprocg_iter;					\
-	LIST_FOREACH(vprocg_iter, &vprocg_head, vprocg_le) {		\
-
-#define VPROCG_ITERLOOP_END()						\
-	}								\
-
-#define INIT_VCPU(arg)		struct vcpu *vcpu = (arg);
-
-#define TD_TO_VIMAGE(td)	(td)->td_ucred->cr_vimage
-#define TD_TO_VNET(td)		(td)->td_ucred->cr_vimage->v_net
-#define TD_TO_VPROCG(td)	(td)->td_ucred->cr_vimage->v_procg
-#define TD_TO_VCPU(td)		(td)->td_ucred->cr_vimage->v_cpu
-#define P_TO_VIMAGE(p)		(p)->p_ucred->cr_vimage
-#define P_TO_VNET(p)		(p)->p_ucred->cr_vimage->v_net
-#define P_TO_VPROCG(p)		(p)->p_ucred->cr_vimage->v_procg
-#define P_TO_VCPU(p)		(p)->p_ucred->cr_vimage->v_cpu
+#define	TD_TO_VNET(td)	(td)->td_ucred->cr_vnet
 
-#else /* !VIMAGE */
-
 /* Non-VIMAGE null-macros */
 #define	IS_DEFAULT_VNET(arg) 1
 #define	VNET_LIST_RLOCK()
 #define	VNET_LIST_RUNLOCK()
 #define	INIT_VPROCG(arg)
-#define	VPROCG_ITERLOOP_BEGIN()
-#define	VPROCG_ITERLOOP_END()
 #define	INIT_VCPU(arg)
 #define	TD_TO_VIMAGE(td)
 #define	TD_TO_VPROCG(td)
@@ -350,160 +277,13 @@
 #define	P_TO_VPROCG(p)
 #define	P_TO_VCPU(p)
 
-#endif /* !VIMAGE */
-
 /* XXX those defines bellow should probably go into vprocg.h and vcpu.h */
-#define	VPROCG(sym)		VSYM(vprocg, sym)
-#define	VCPU(sym)		VSYM(vcpu, sym)
+#define	VPROCG(sym)		(sym)
+#define	VCPU(sym)		(sym)
 
-#define V_hostname		VPROCG(hostname)
-#ifdef VIMAGE
-#define G_hostname		VSYM(basevprocg, hostname) /* global hostname */
-#else
-#define G_hostname		VSYM(vprocg, hostname) /* global hostname */
-#endif
-#define V_domainname		VPROCG(domainname)
-#define V_morphing_symlinks	VPROCG(morphing_symlinks)
-
-#define V_acc_statcalls		VCPU(acc_statcalls)
-#define V_avg1_fixp		VCPU(avg1_fixp)
-#define V_avg2_fixp		VCPU(avg2_fixp)
-
-#ifndef VIMAGE_GLOBALS
-void vnet_mod_register(const struct vnet_modinfo *);
-void vnet_mod_deregister(const struct vnet_modinfo *);
-void vnet_mod_register_multi(const struct vnet_modinfo *, void *, char *);
-void vnet_mod_deregister_multi(const struct vnet_modinfo *, void *, char *);
-int vi_symlookup(struct kld_sym_lookup *, char *);
-#endif
-
-#ifdef VIMAGE
-int	vi_td_ioctl(u_long, struct vi_req *, struct thread *);
-int	vi_if_move(struct vi_req *, struct ifnet *, struct vimage *);
-void	if_reassign_common(struct ifnet *, struct vnet *, const char *);
-
-struct	vimage *vnet2vimage(struct vnet *);
-struct	vimage *vimage_by_name(struct vimage *, char *);
-char	*vnet_name(struct vnet *);
-int	vi_child_of(struct vimage *, struct vimage *);
-
-LIST_HEAD(vimage_list_head, vimage);
-extern struct vimage_list_head vimage_head;
-
-LIST_HEAD(vprocg_list_head, vprocg);
-extern struct vprocg_list_head vprocg_head;
-
-LIST_HEAD(vcpu_list_head, vcpu);
-extern struct vcpu_list_head vcpu_head;
-
-LIST_HEAD(vnet_list_head, vnet);
-extern struct vnet_list_head vnet_head;
-extern int vnet_list_refc;
-extern struct mtx vnet_list_refc_mtx;
-extern struct cv vnet_list_condvar;
-extern struct mtx vcpu_list_mtx;
-
-#define VNET_LIST_RLOCK() do {						\
-	mtx_lock(&vnet_list_refc_mtx);					\
-	vnet_list_refc++;						\
-	mtx_unlock(&vnet_list_refc_mtx);				\
-} while (0)
-
-#define VNET_LIST_RUNLOCK() do {					\
-	mtx_lock(&vnet_list_refc_mtx);					\
-	vnet_list_refc--;						\
-	mtx_unlock(&vnet_list_refc_mtx);				\
-	cv_signal(&vnet_list_condvar);					\
-} while (0)
-
-#define IS_DEFAULT_VIMAGE(arg)		((arg)->vi_id == 0)
-#define IS_DEFAULT_VNET(arg)		((arg)->vnet_id == 0)
-
-struct vimage {
-	LIST_ENTRY(vimage) vi_le;	/* all vimage list */
-	LIST_ENTRY(vimage) vi_sibling;	/* vimages with same parent */
-	LIST_HEAD(, vimage) vi_child_head;	/* direct offspring list */
-	struct	vimage *vi_parent;	/* ptr to parent vimage */
-	u_int	vi_id;			/* ID num */
-	u_int	vi_ucredrefc;		/* refc of ucreds pointing to us */
-
-	char	vi_name[MAXHOSTNAMELEN]; /* assigned by parent */
-
-	struct	vprocg *v_procg;
-	struct	vcpu *v_cpu;
-	struct	vnet *v_net;
-};
-
-#endif /* VIMAGE */
-
-struct vprocg {
-	LIST_ENTRY(vprocg) vprocg_le;
-	u_int	vprocg_ref;		/* reference count */
-	u_int	vprocg_id;		/* ID num */
-
-	u_int	nprocs;	
-
-	char	_hostname[MAXHOSTNAMELEN];
-	char	_domainname[MAXHOSTNAMELEN];
-
-	int	_morphing_symlinks;
-};
-
-struct vcpu {
-	LIST_ENTRY(vcpu) vcpu_le;
-	u_int	vcpu_ref;		/* reference count */
-	u_int	vcpu_id;		/* ID num */
-
-	u_int	_acc_statcalls;		/* statclocks since last avg update*/
-	u_int	_avg1_fixp;		/* "fast" avg in 16:16 bit fixedpoint */
-	u_int	_avg2_fixp;		/* "slow" avg in 16:16 bit fixedpoint */
-};
-
-#ifndef VIMAGE_GLOBALS
-#ifndef VIMAGE
-extern struct vprocg vprocg_0;
-#endif
-#endif
-
-struct vi_req {
-	int	req_action;		/* What to do with this reqest? */
-	u_int	vi_cpu_min;		/* Guaranteed CPU share */
-	u_int	vi_cpu_max;		/* Maximum average CPU usage */
-	u_int	vi_cpu_weight;		/* Prop. share scheduling priority */
-	int	vi_intr_limit;		/* Limit on CPU usage in intr ctx */
-	int	vi_maxsockets;
-	u_short vi_proc_limit;		/* max. number of processes */
-	u_short vi_proc_count;		/* current number of processes */
-	u_short vi_child_limit;		/* max. number of child vnets */
-	u_short vi_child_count;		/* current number of child vnets */
-	int	vi_if_count;		/* current number network interfaces */
-	int	vi_sock_count;
-	char	vi_name[MAXPATHLEN];
-	char	vi_chroot[MAXPATHLEN];
-	char	vi_if_xname[MAXPATHLEN]; /* XXX should be IFNAMSIZ */
-	u_int	cp_time_avg;
-	struct	loadavg averunnable;
-};
-
-#define VI_CREATE		0x00000001
-#define VI_DESTROY		0x00000002
-#define VI_MODIFY		0x00000004
-#define VI_SWITCHTO		0x00000008
-#define VI_IFACE		0x00000010
-
-#define VI_GET			0x00000100
-#define VI_GETNEXT		0x00000200
-#define VI_GETNEXT_RECURSE	0x00000300
-
-#define VI_SET_CPU_MIN		0x00001000
-#define VI_SET_CPU_MAX		0x00002000
-#define VI_SET_CPU_WEIGHT	0x00004000
-#define VI_SET_INTR_LIMIT	0x00008000
-#define VI_SET_PROC_LIMIT	0x00010000
-#define VI_SET_CHILD_LIMIT	0x00020000
-#define VI_SET_SOCK_LIMIT	0x00040000
-#define VI_SET_NAME		0x00100000
-#define VI_SET_CHROOT		0x00200000
+#define	V_hostname		VPROCG(hostname)
+#define	G_hostname		VPROCG(hostname) /* global hostname */
+#define	V_domainname		VPROCG(domainname)
 
 /*
  * Size-guards for the vimage structures.



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