Source-Changes-HG archive

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

[src/trunk]: src/sys/net/npf prevent the lookup function from autoloading rec...



details:   https://anonhg.NetBSD.org/src/rev/8a0bb3e536b3
branches:  trunk
changeset: 785382:8a0bb3e536b3
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 11 01:56:37 2013 +0000

description:
prevent the lookup function from autoloading recursively.

diffstat:

 sys/net/npf/npf_rproc.c |  16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diffs (64 lines):

diff -r f4eb3725dbc0 -r 8a0bb3e536b3 sys/net/npf/npf_rproc.c
--- a/sys/net/npf/npf_rproc.c   Mon Mar 11 01:43:50 2013 +0000
+++ b/sys/net/npf/npf_rproc.c   Mon Mar 11 01:56:37 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_rproc.c,v 1.8 2013/03/11 01:43:50 christos Exp $   */
+/*     $NetBSD: npf_rproc.c,v 1.9 2013/03/11 01:56:37 christos Exp $   */
 
 /*-
  * Copyright (c) 2009-2013 The NetBSD Foundation, Inc.
@@ -102,11 +102,11 @@
 #define NPF_EXT_PREFLEN (sizeof(npf_ext_prefix) - 1)
 
 static npf_ext_t *
-npf_ext_lookup(const char *name)
+npf_ext_lookup(const char *name, bool autoload)
 {
        npf_ext_t *ext;
        char modname[RPROC_NAME_LEN + NPF_EXT_PREFLEN];
-       int error, loaded = 0;
+       int error;
 
        KASSERT(mutex_owned(&ext_lock));
 
@@ -115,11 +115,11 @@
                if (strcmp(ext->ext_callname, name) == 0)
                        break;
 
-       if (ext != NULL || loaded != 0)
+       if (ext != NULL || !autoload)
                return ext;
 
        mutex_exit(&ext_lock);
-       loaded++;
+       autoload = false;
        snprintf(modname, sizeof(modname), "%s%s", npf_ext_prefix, name);
        error = module_autoload(modname, MODULE_CLASS_MISC);
        mutex_enter(&ext_lock);
@@ -139,7 +139,7 @@
        ext->ext_ops = ops;
 
        mutex_enter(&ext_lock);
-       if (npf_ext_lookup(name)) {
+       if (npf_ext_lookup(name, false)) {
                mutex_exit(&ext_lock);
                kmem_free(ext, sizeof(npf_ext_t));
                return NULL;
@@ -167,7 +167,7 @@
                mutex_exit(&ext_lock);
                return EBUSY;
        }
-       KASSERT(npf_ext_lookup(ext->ext_callname));
+       KASSERT(npf_ext_lookup(ext->ext_callname, false));
        LIST_REMOVE(ext, ext_entry);
        mutex_exit(&ext_lock);
 
@@ -188,7 +188,7 @@
        }
 
        mutex_enter(&ext_lock);
-       ext = npf_ext_lookup(name);
+       ext = npf_ext_lookup(name, true);
        if (ext) {
                atomic_inc_uint(&ext->ext_refcnt);
        }



Home | Main Index | Thread Index | Old Index