Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet refactor: merge encap_init_once() to encapinit()



details:   https://anonhg.NetBSD.org/src/rev/57569fe29dbf
branches:  trunk
changeset: 816408:57569fe29dbf
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Jul 04 04:38:14 2016 +0000

description:
refactor: merge encap_init_once() to encapinit()

diffstat:

 sys/netinet/ip_encap.c |  30 +++++++-----------------------
 1 files changed, 7 insertions(+), 23 deletions(-)

diffs (86 lines):

diff -r 8146d63966bd -r 57569fe29dbf sys/netinet/ip_encap.c
--- a/sys/netinet/ip_encap.c    Mon Jul 04 04:35:09 2016 +0000
+++ b/sys/netinet/ip_encap.c    Mon Jul 04 04:38:14 2016 +0000
@@ -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 @@
 #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 @@
 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 @@
 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 @@
        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 @@
        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 @@
        int error;
        int s;
 
-       RUN_ONCE(&encap_init_control, encap_init_once);
-
        s = splsoftnet();
        /* sanity check on args */
        if (!func) {



Home | Main Index | Thread Index | Old Index