Module Name:    src
Committed By:   knakahara
Date:           Mon Jul  4 04:38:14 UTC 2016

Modified Files:
        src/sys/netinet: ip_encap.c

Log Message:
refactor: merge encap_init_once() to encapinit()


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/netinet/ip_encap.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.59 src/sys/netinet/ip_encap.c:1.60
--- src/sys/netinet/ip_encap.c:1.59	Mon Jul  4 04:35:09 2016
+++ src/sys/netinet/ip_encap.c	Mon Jul  4 04:38:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_encap.c,v 1.59 2016/07/04 04:35:09 knakahara Exp $	*/
+/*	$NetBSD: ip_encap.c,v 1.60 2016/07/04 04:38:14 knakahara Exp $	*/
 /*	$KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $	*/
 
 /*
@@ -68,7 +68,7 @@
 #define USE_RADIX
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.59 2016/07/04 04:35:09 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.60 2016/07/04 04:38:14 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -83,7 +83,6 @@ __KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v
 #include <sys/errno.h>
 #include <sys/queue.h>
 #include <sys/kmem.h>
-#include <sys/once.h>
 #include <sys/mutex.h>
 #include <sys/condvar.h>
 #include <sys/psref.h>
@@ -157,10 +156,6 @@ struct radix_node_head *encap_head[2];	/
 static bool encap_head_updating = false;
 #endif
 
-static ONCE_DECL(encap_init_control);
-
-static int encap_init_once(void);
-
 /*
  * must be done before other encap interfaces initialization.
  */
@@ -168,6 +163,11 @@ void
 encapinit(void)
 {
 
+	encaptab.psz = pserialize_create();
+	encaptab.elem_class = psref_class_create("encapelem", IPL_SOFTNET);
+	if (encaptab.elem_class == NULL)
+		panic("encaptab.elem_class cannot be allocated.\n");
+
 	mutex_init(&encap_whole.lock, MUTEX_DEFAULT, IPL_NONE);
 	cv_init(&encap_whole.cv, "ip_encap cv");
 	encap_whole.busy = NULL;
@@ -635,18 +635,6 @@ encap_afcheck(int af, const struct socka
 	return 0;
 }
 
-static int
-encap_init_once(void)
-{
-
-	encaptab.psz = pserialize_create();
-	encaptab.elem_class = psref_class_create("encapelem", IPL_SOFTNET);
-	if (encaptab.elem_class == NULL)
-		panic("encaptab.elem_class cannot be allocated.\n");
-
-	return 0;
-}
-
 /*
  * sp (src ptr) is always my side, and dp (dst ptr) is always remote side.
  * length of mask (sm and dm) is assumed to be same as sp/dp.
@@ -667,8 +655,6 @@ encap_attach(int af, int proto,
 	struct ip_pack6 *pack6;
 #endif
 
-	RUN_ONCE(&encap_init_control, encap_init_once);
-
 	s = splsoftnet();
 	/* sanity check on args */
 	error = encap_afcheck(af, sp, dp);
@@ -799,8 +785,6 @@ encap_attach_func(int af, int proto,
 	int error;
 	int s;
 
-	RUN_ONCE(&encap_init_control, encap_init_once);
-
 	s = splsoftnet();
 	/* sanity check on args */
 	if (!func) {

Reply via email to