prevent the lookup function from autoloading recursively.
This commit is contained in:
parent
7e25e6910f
commit
fea1d0b382
|
@ -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[] = "npf_ext_";
|
|||
#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 npf_ext_ops_t *ops)
|
|||
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_rproc_t *rp, prop_dictionary_t params)
|
|||
}
|
||||
|
||||
mutex_enter(&ext_lock);
|
||||
ext = npf_ext_lookup(name);
|
||||
ext = npf_ext_lookup(name, true);
|
||||
if (ext) {
|
||||
atomic_inc_uint(&ext->ext_refcnt);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue