Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 27 Jul 2007 19:06:42 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 124200 for review
Message-ID:  <200707271906.l6RJ6gBh049222@repoman.freebsd.org>

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

Change 124200 by zec@zec_tpx32 on 2007/07/27 19:06:17

	Arrange that the (yet to be implemented) cleanups of IPSEC
	state will be invoked through the new dom_destroy() mechanism,
	instead of registering the cleanup function as a vnet module.
	
	While here, do some whitespace / indentation cleanups.

Affected files ...

.. //depot/projects/vimage/src/sys/netipsec/ipsec.c#11 edit
.. //depot/projects/vimage/src/sys/netipsec/key.c#12 edit
.. //depot/projects/vimage/src/sys/netipsec/key.h#2 edit
.. //depot/projects/vimage/src/sys/netipsec/keysock.c#7 edit
.. //depot/projects/vimage/src/sys/sys/vimage.h#26 edit

Differences ...

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

@@ -108,7 +108,7 @@
 #endif
 #endif
 
-static int  vnet_ipsec_iattach(void *);
+static int vnet_ipsec_iattach(void *);
 #ifdef VIMAGE
 static int vnet_ipsec_idetach(void *);
 #endif
@@ -2004,16 +2004,16 @@
 #ifdef VIMAGE
 	struct vnet_ipsec *vnet_ipsec;
 
-    if (IS_VNET_0(curvnet)) {
-        vnet_ipsec = &vnet_ipsec_0;
-    } else {
-        vnet_ipsec = malloc(sizeof(struct vnet_ipsec),
-                   M_IPSEC, M_NOWAIT | M_ZERO);
-        if (vnet_ipsec == NULL)
-            panic("couldn't allocate memory for vnet_ipsec");
-    }
-    curvnet->mod_data[vnet_ipsec_modinfo.id] = vnet_ipsec;
-    vnet_ipsec->parent_vnet = curvnet;
+	if (IS_VNET_0(curvnet)) {
+		vnet_ipsec = &vnet_ipsec_0;
+	} else {
+		vnet_ipsec = malloc(sizeof(struct vnet_ipsec),
+				    M_IPSEC, M_NOWAIT | M_ZERO);
+	if (vnet_ipsec == NULL)
+		panic("couldn't allocate memory for vnet_ipsec");
+	}
+	curvnet->mod_data[vnet_ipsec_modinfo.id] = vnet_ipsec;
+	vnet_ipsec->parent_vnet = curvnet;
 #endif
 
 	#ifdef IPSEC_DEBUG

==== //depot/projects/vimage/src/sys/netipsec/key.c#12 (text+ko) ====

@@ -131,18 +131,6 @@
 static u_int32_t acq_seq = 0;
 #endif
 
-static int  key_iattach(void *);
-static int  key_idetach(void *);
-
-#ifdef VIMAGE
-static struct vnet_modinfo vnet_key_modinfo = {
-	.id			= VNET_MOD_KEY,
-	.name		= "key",
-	.i_attach	= key_iattach,
-	.i_detach	= key_idetach
-};
-#endif
-
 #ifndef VIMAGE
 static LIST_HEAD(_sptree, secpolicy) sptree[IPSEC_DIR_MAX];	/* SPD */
 #endif
@@ -7180,18 +7168,6 @@
 void
 key_init(void)
 {
-#ifdef VIMAGE
-    if (IS_VNET_0(curvnet))
-		vnet_mod_register(&vnet_key_modinfo);
-#else
-	key_iattach(NULL);
-#endif
-
-	return;
-}
-
-static int key_iattach(unused) void *unused;
-{
 	INIT_VNET_IPSEC(curvnet);
 	int i;
 
@@ -7244,10 +7220,12 @@
 	V_ip4_def_policy.policy = IPSEC_POLICY_NONE;
 	V_ip4_def_policy.refcnt++;	/*never reclaim this*/
 
-#ifndef IPSEC_DEBUG2
 #ifdef VIMAGE
-	if (IS_VNET_0(curvnet))
+	if (!IS_VNET_0(curvnet))
+		return;
 #endif
+
+#ifndef IPSEC_DEBUG2
 	timeout((void *)key_timehandler, (void *)0, hz);
 #endif /*IPSEC_DEBUG2*/
 
@@ -7255,18 +7233,14 @@
 	keystat.getspi_count = 1;
 
 	printf("Fast IPsec: Initialized Security Association Processing.\n");
-
-	return 0;
 }
 
 #ifdef VIMAGE
-static int key_idetach(unused) void *unused;
+void key_destroy(void)
 {
-	INIT_VNET_IPSEC(curvnet);
 	/*
 	 * Flush: spdtree, sahtree, regtree, acqtree, sacqtree
-	*/
-	return 0;
+	 */
 }
 #endif
 

==== //depot/projects/vimage/src/sys/netipsec/key.h#2 (text+ko) ====

@@ -96,6 +96,9 @@
 extern void key_freereg __P((struct socket *));
 extern int key_parse __P((struct mbuf *, struct socket *));
 extern void key_init __P((void));
+#ifdef VIMAGE
+extern void key_destroy(void);
+#endif
 extern void key_sa_recordxfer __P((struct secasvar *, struct mbuf *));
 extern void key_sa_routechange __P((struct sockaddr *));
 extern void key_sa_stir_iv __P((struct secasvar *));

==== //depot/projects/vimage/src/sys/netipsec/keysock.c#7 (text+ko) ====

@@ -589,6 +589,9 @@
 	.dom_family =		PF_KEY,
 	.dom_name =		"key",
 	.dom_init =		key_init0,
+#ifdef VIMAGE
+	.dom_destroy =		key_destroy,
+#endif
 	.dom_protosw =		keysw,
 	.dom_protoswNPROTOSW =	&keysw[sizeof(keysw)/sizeof(keysw[0])]
 };

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

@@ -81,7 +81,6 @@
 #define VNET_MOD_AH		15
 #define VNET_MOD_GIF		16
 #define VNET_MOD_IPCOMP	 	17	
-#define VNET_MOD_KEY		18
 #define VNET_MOD_ARP		28
 #define VNET_MOD_RTABLE		29
 #define VNET_MOD_LOIF		30



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