Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 16 Apr 2009 12:41:32 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 160693 for review
Message-ID:  <200904161241.n3GCfWue093071@repoman.freebsd.org>

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

Change 160693 by zec@zec_amdx2 on 2009/04/16 12:41:22

	Make GENERIC + options VIMAGE + nooptions SCTP compile.

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/compat/linux/linux_socket.c#12 edit
.. //depot/projects/vimage-commit2/src/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c#16 edit
.. //depot/projects/vimage-commit2/src/sys/kern/kern_mib.c#12 edit
.. //depot/projects/vimage-commit2/src/sys/kern/kern_sysctl.c#8 edit
.. //depot/projects/vimage-commit2/src/sys/kern/kern_vimage.c#16 edit
.. //depot/projects/vimage-commit2/src/sys/net/if.c#43 edit
.. //depot/projects/vimage-commit2/src/sys/net/if_gif.c#23 edit
.. //depot/projects/vimage-commit2/src/sys/netgraph/ng_base.c#24 edit
.. //depot/projects/vimage-commit2/src/sys/netgraph/ng_eiface.c#18 edit
.. //depot/projects/vimage-commit2/src/sys/netgraph/ng_ether.c#12 edit
.. //depot/projects/vimage-commit2/src/sys/netgraph/ng_iface.c#16 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/ip_divert.c#24 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/ip_fw2.c#38 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/ip_input.c#34 edit
.. //depot/projects/vimage-commit2/src/sys/netinet/ip_mroute.c#13 edit
.. //depot/projects/vimage-commit2/src/sys/netinet6/ip6_input.c#28 edit
.. //depot/projects/vimage-commit2/src/sys/netipsec/ipsec.c#28 edit
.. //depot/projects/vimage-commit2/src/sys/sys/sysctl.h#18 edit
.. //depot/projects/vimage-commit2/src/sys/sys/vimage.h#39 edit

Differences ...

==== //depot/projects/vimage-commit2/src/sys/compat/linux/linux_socket.c#12 (text+ko) ====

@@ -584,8 +584,10 @@
 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;

==== //depot/projects/vimage-commit2/src/sys/contrib/ipfilter/netinet/ip_fil_freebsd.c#16 (text+ko) ====

@@ -213,6 +213,7 @@
 
 int ipfattach()
 {
+	INIT_VNET_INET(curvnet);
 #ifdef USE_SPL
 	int s;
 #endif
@@ -264,6 +265,7 @@
  */
 int ipfdetach()
 {
+	INIT_VNET_INET(curvnet);
 #ifdef USE_SPL
 	int s;
 #endif
@@ -646,6 +648,7 @@
 fr_info_t *fin;
 mb_t *m, **mpp;
 {
+	INIT_VNET_INET(curvnet);
 	fr_info_t fnew;
 	ip_t *ip, *oip;
 	int hlen;

==== //depot/projects/vimage-commit2/src/sys/kern/kern_mib.c#12 (text+ko) ====

@@ -208,9 +208,8 @@
 SYSCTL_STRING(_hw, HW_MACHINE_ARCH, machine_arch, CTLFLAG_RD,
     machine_arch, 0, "System architecture");
 
-#ifndef VIMAGE
+/* should become #ifndef VIMAGE */
 char hostname[MAXHOSTNAMELEN];
-#endif
 
 /*
  * This mutex is used to protect the hostname and domainname variables, and
@@ -349,9 +348,8 @@
     0, 0, sysctl_kern_config, "", "Kernel configuration file");
 #endif
 
-#ifndef VIMAGE
+/* should become #ifndef VIMAGE */
 char domainname[MAXHOSTNAMELEN];	/* Protected by hostname_mtx. */
-#endif
 
 static int
 sysctl_domainname(SYSCTL_HANDLER_ARGS)

==== //depot/projects/vimage-commit2/src/sys/kern/kern_sysctl.c#8 (text+ko) ====

@@ -934,6 +934,30 @@
 	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.
@@ -1069,6 +1093,47 @@
 	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.
@@ -1106,6 +1171,35 @@
 	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

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

@@ -49,9 +49,10 @@
 static void vnet_mod_complete_registration(struct vnet_modlink *);
 static int vnet_mod_constructor(struct vnet_modlink *);
 
+#ifdef VIMAGE
 /* curvnet should be thread-local - this is only a temporary step */
-#ifdef VIMAGE
 struct vnet *curvnet;
+struct vnet_list_head vnet_head;
 #endif
 
 void
@@ -159,16 +160,16 @@
 	if (vml->vml_iarg)
 		printf("/%s", vml->vml_iname);
 	printf(": ");
-	if (vmi->vmi_struct_size)
-		printf("malloc(%zu); ", vmi->vmi_struct_size);
+	if (vmi->vmi_size)
+		printf("malloc(%zu); ", vmi->vmi_size);
 	if (vmi->vmi_iattach != NULL)
 		printf("iattach()");
 	printf("\n");
 #endif
 
 #ifdef VIMAGE
-	if (vmi->vmi_struct_size) {
-		void *mem = malloc(vmi->vmi_struct_size, M_VNET,
+	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("vi_alloc: malloc for %s\n", vmi->vmi_name);
@@ -218,7 +219,9 @@
 static void
 vi_init(void *unused)
 {
+#ifdef VIMAGE
 	struct vnet *vnet;
+#endif
 
 	TAILQ_INIT(&vnet_modlink_head);
 	TAILQ_INIT(&vnet_modpending_head);

==== //depot/projects/vimage-commit2/src/sys/net/if.c#43 (text+ko) ====

@@ -186,6 +186,7 @@
 static const vnet_modinfo_t vnet_net_modinfo = {
 	.vmi_id		= VNET_MOD_NET,
 	.vmi_name	= "net",
+	.vmi_size	= sizeof(struct vnet_net),
 	.vmi_symmap	= vnet_net_symmap,
 	.vmi_iattach	= vnet_net_iattach
 };

==== //depot/projects/vimage-commit2/src/sys/net/if_gif.c#23 (text+ko) ====

@@ -127,6 +127,7 @@
 static const vnet_modinfo_t vnet_gif_modinfo = {
 	.vmi_id		= VNET_MOD_GIF,
 	.vmi_name	= "gif",
+	.vmi_size	= sizeof(struct vnet_gif),
 	.vmi_dependson	= VNET_MOD_NET,
 	.vmi_iattach	= vnet_gif_iattach
 };

==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_base.c#24 (text+ko) ====

@@ -3075,6 +3075,7 @@
 static int
 ngb_mod_event(module_t mod, int event, void *data)
 {
+	INIT_VNET_NETGRAPH(curvnet); /* XXX move to iattach - revisit! */
 	struct proc *p;
 	struct thread *td;
 	int i, error = 0;

==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_eiface.c#18 (text+ko) ====

@@ -583,6 +583,7 @@
 static int
 ng_eiface_mod_event(module_t mod, int event, void *data)
 {
+	INIT_VNET_NETGRAPH(curvnet); /* XXX move to iattach -> revisit! */
 	int error = 0;
 
 	switch (event) {

==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_ether.c#12 (text+ko) ====

@@ -741,6 +741,7 @@
 static int
 ng_ether_mod_event(module_t mod, int event, void *data)
 {
+	INIT_VNET_NET(curvnet); /* XXX move to iattach - revisit! */
 	struct ifnet *ifp;
 	int error = 0;
 	int s;

==== //depot/projects/vimage-commit2/src/sys/netgraph/ng_iface.c#16 (text+ko) ====

@@ -829,6 +829,7 @@
 static int
 ng_iface_mod_event(module_t mod, int event, void *data)
 {
+	INIT_VNET_NETGRAPH(curvnet); /* XXX move to iattach - revisit! */
 	int error = 0;
 
 	switch (event) {

==== //depot/projects/vimage-commit2/src/sys/netinet/ip_divert.c#24 (text+ko) ====

@@ -132,6 +132,7 @@
 static void
 div_zone_change(void *tag)
 {
+	INIT_VNET_INET(curvnet);
 
 	uma_zone_set_max(V_divcbinfo.ipi_zone, maxsockets);
 }
@@ -719,6 +720,7 @@
 static int
 div_modevent(module_t mod, int type, void *unused)
 {
+	INIT_VNET_INET(curvnet); /* XXX move to iattach - revisit!!! */
 	int err = 0;
 	int n;
 

==== //depot/projects/vimage-commit2/src/sys/netinet/ip_fw2.c#38 (text+ko) ====

@@ -1810,7 +1810,6 @@
 add_table_entry(struct ip_fw_chain *ch, uint16_t tbl, in_addr_t addr,
     uint8_t mlen, uint32_t value)
 {
-	INIT_VNET_IPFW(curvnet);
 	struct radix_node_head *rnh;
 	struct table_entry *ent;
 	struct radix_node *rn;
@@ -4527,6 +4526,7 @@
 static void
 ipfw_tick(void * __unused unused)
 {
+	INIT_VNET_IPFW(curvnet);
 	struct mbuf *m0, *m, *mnext, **mtailp;
 	int i;
 	ipfw_dyn_rule *q;
@@ -4710,6 +4710,7 @@
 void
 ipfw_destroy(void)
 {
+	INIT_VNET_IPFW(curvnet);
 	struct ip_fw *reap;
 
 	ip_fw_chk_ptr = NULL;

==== //depot/projects/vimage-commit2/src/sys/netinet/ip_input.c#34 (text+ko) ====

@@ -230,6 +230,7 @@
 static const vnet_modinfo_t vnet_inet_modinfo = {
 	.vmi_id		= VNET_MOD_INET,
 	.vmi_name	= "inet",
+	.vmi_size	= sizeof(struct vnet_inet)
 };
  
 static void vnet_inet_register()

==== //depot/projects/vimage-commit2/src/sys/netinet/ip_mroute.c#13 (text+ko) ====

@@ -1709,6 +1709,7 @@
 static void
 X_rsvp_input(struct mbuf *m, int off __unused)
 {
+	INIT_VNET_INET(curvnet);
 
 	if (!V_rsvp_on)
 		m_freem(m);

==== //depot/projects/vimage-commit2/src/sys/netinet6/ip6_input.c#28 (text+ko) ====

@@ -161,6 +161,7 @@
 static const vnet_modinfo_t vnet_inet6_modinfo = {
 	.vmi_id		= VNET_MOD_INET6,
 	.vmi_name	= "inet6",
+	.vmi_size	= sizeof(struct vnet_inet6),
 	.vmi_dependson	= VNET_MOD_INET	/* XXX revisit - TCP/UDP needs this? */
 };
  

==== //depot/projects/vimage-commit2/src/sys/netipsec/ipsec.c#28 (text+ko) ====

@@ -248,6 +248,7 @@
 static const vnet_modinfo_t vnet_ipsec_modinfo = {
 	.vmi_id		= VNET_MOD_IPSEC,
 	.vmi_name	= "ipsec",
+	.vmi_size	= sizeof(struct vnet_inet),
 	.vmi_dependson	= VNET_MOD_INET,	/* XXX revisit - INET6 ? */
 	.vmi_iattach	= ipsec_iattach
 };

==== //depot/projects/vimage-commit2/src/sys/sys/sysctl.h#18 (text+ko) ====

@@ -442,6 +442,29 @@
 #define	FEATURE(name, desc)						\
 	SYSCTL_INT(_kern_features, OID_AUTO, name, CTLFLAG_RD, 0, 1, desc)
 	
+/*
+ * Resolve void *arg1 in a proper virtualization container.
+ */
+#ifdef VIMAGE
+#define SYSCTL_RESOLVE_V_ARG1() do {					\
+	char *cp;							\
+	switch (oidp->oid_v_subs) {					\
+	case V_GLOBAL:							\
+		/* do nothing - this is NOT a virtualized variable! */	\
+		break;							\
+	case V_NET:							\
+		cp = (char *)						\
+		    TD_TO_VNET(curthread)->mod_data[oidp->oid_v_mod];	\
+		arg1 = cp + (size_t) arg1;				\
+		break;							\
+	default:							\
+		panic("unsupported module id %d", oidp->oid_v_subs);	\
+	}								\
+} while (0)
+#else
+#define SYSCTL_RESOLVE_V_ARG1()
+#endif
+
 #endif /* _KERNEL */
 
 /*

==== //depot/projects/vimage-commit2/src/sys/sys/vimage.h#39 (text+ko) ====

@@ -59,7 +59,7 @@
 	char				*vmi_name;
 	vnet_attach_fn			*vmi_iattach;
 	vnet_detach_fn			*vmi_idetach;
-	size_t				 vmi_struct_size;
+	size_t				 vmi_size;
 	struct vnet_symmap		*vmi_symmap;
 };
 typedef struct vnet_modinfo vnet_modinfo_t;
@@ -139,7 +139,7 @@
 	sizeof(((struct vnet_ ## mod *) curthread)->_ ## name) }
 #else
 #define	VNET_SYMMAP(mod, name)						\
-	{ #name, &(vnet_ ## mod ## _0._ ## name),			\
+	{ #name, (size_t) &(vnet_ ## mod ## _0._ ## name),		\
 	sizeof(vnet_ ## mod ## _0._ ## name) }
 #endif
 #define	VNET_SYMMAP_END		{ NULL, 0 }
@@ -181,6 +181,12 @@
 #define	VNET_FOREACH(arg)
 #endif
 
+#ifdef VIMAGE
+#define	TD_TO_VNET(td)	curvnet
+#else
+#define	TD_TO_VNET(td)
+#endif
+
 /* Non-VIMAGE null-macros */
 #define	IS_DEFAULT_VNET(arg) 1
 #define	CURVNET_SET(arg)
@@ -192,7 +198,6 @@
 #define	INIT_VPROCG(arg)
 #define	INIT_VCPU(arg)
 #define	TD_TO_VIMAGE(td)
-#define	TD_TO_VNET(td)
 #define	TD_TO_VPROCG(td)
 #define	TD_TO_VCPU(td)
 #define	P_TO_VIMAGE(p)



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