Module Name: src
Committed By: christos
Date: Mon Mar 11 01:56:37 UTC 2013
Modified Files:
src/sys/net/npf: npf_rproc.c
Log Message:
prevent the lookup function from autoloading recursively.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/net/npf/npf_rproc.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/net/npf/npf_rproc.c
diff -u src/sys/net/npf/npf_rproc.c:1.8 src/sys/net/npf/npf_rproc.c:1.9
--- src/sys/net/npf/npf_rproc.c:1.8 Sun Mar 10 21:43:50 2013
+++ src/sys/net/npf/npf_rproc.c Sun Mar 10 21:56:37 2013
@@ -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 @@ static const char npf_ext_prefix[] = "np
#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 @@ again:
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 @@ npf_ext_register(const char *name, const
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 @@ npf_ext_unregister(void *extid)
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 @@ npf_ext_construct(const char *name, npf_
}
mutex_enter(&ext_lock);
- ext = npf_ext_lookup(name);
+ ext = npf_ext_lookup(name, true);
if (ext) {
atomic_inc_uint(&ext->ext_refcnt);
}