diff options
author | Ruslan Ermilov <ru@FreeBSD.org> | 2005-02-05 08:28:36 +0000 |
---|---|---|
committer | Ruslan Ermilov <ru@FreeBSD.org> | 2005-02-05 08:28:36 +0000 |
commit | 30aabc9afd5b14ce95bbf898be4cc0704d67a1b7 (patch) | |
tree | bfef15bd02ae3fbb3862287846c919bc7439e24a /sys/netgraph/ng_iface.c | |
parent | 6ab93aca6d5a89f333759b9cbb314816097d59ac (diff) | |
download | src-30aabc9afd5b14ce95bbf898be4cc0704d67a1b7.tar.gz src-30aabc9afd5b14ce95bbf898be4cc0704d67a1b7.zip |
Create a per-module mutex on MOD_LOAD, and destroy it on MOD_UNLOAD.
(This fixes witness_destroy() panic after module unload.)
OK'ed by: rwatson, julian
Notes
Notes:
svn path=/head/; revision=141341
Diffstat (limited to 'sys/netgraph/ng_iface.c')
-rw-r--r-- | sys/netgraph/ng_iface.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/sys/netgraph/ng_iface.c b/sys/netgraph/ng_iface.c index 7014c057a570..c7dee9d80fe0 100644 --- a/sys/netgraph/ng_iface.c +++ b/sys/netgraph/ng_iface.c @@ -130,6 +130,7 @@ static void ng_iface_print_ioctl(struct ifnet *ifp, int cmd, caddr_t data); #endif /* Netgraph methods */ +static int ng_iface_mod_event(module_t, int, void *); static ng_constructor_t ng_iface_constructor; static ng_rcvmsg_t ng_iface_rcvmsg; static ng_shutdown_t ng_iface_shutdown; @@ -195,6 +196,7 @@ static const struct ng_cmdlist ng_iface_cmds[] = { static struct ng_type typestruct = { .version = NG_ABI_VERSION, .name = NG_IFACE_NODE_TYPE, + .mod_event = ng_iface_mod_event, .constructor = ng_iface_constructor, .rcvmsg = ng_iface_rcvmsg, .shutdown = ng_iface_shutdown, @@ -214,7 +216,6 @@ static int ng_units_in_use = 0; #define UNITS_BITSPERWORD (sizeof(*ng_iface_units) * NBBY) static struct mtx ng_iface_mtx; -MTX_SYSINIT(ng_iface, &ng_iface_mtx, "ng_iface", MTX_DEF); /************************************************************************ HELPER STUFF @@ -836,3 +837,24 @@ ng_iface_disconnect(hook_p hook) return (0); } +/* + * Handle loading and unloading for this node type. + */ +static int +ng_iface_mod_event(module_t mod, int event, void *data) +{ + int error = 0; + + switch (event) { + case MOD_LOAD: + mtx_init(&ng_iface_mtx, "ng_iface", NULL, MTX_DEF); + break; + case MOD_UNLOAD: + mtx_destroy(&ng_iface_mtx); + break; + default: + error = EOPNOTSUPP; + break; + } + return (error); +} |