summaryrefslogtreecommitdiffstats
path: root/sys/netgraph
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2006-06-13 21:36:23 +0000
committerjhb <jhb@FreeBSD.org>2006-06-13 21:36:23 +0000
commit9af5dd68e4cafc61cd39c93a9cbb404beec42308 (patch)
tree6bdda3a80fe25172e30b3b25fc2a0ae45191cc84 /sys/netgraph
parent00130e4f0c49136fca94a71afa4a22642743681e (diff)
downloadFreeBSD-src-9af5dd68e4cafc61cd39c93a9cbb404beec42308.zip
FreeBSD-src-9af5dd68e4cafc61cd39c93a9cbb404beec42308.tar.gz
Use kern_kldload() and kern_kldunload() to load and unload modules when
we intend for the user to be able to unload them later via kldunload(2) instead of calling linker_load_module() and then directly adjusting the ref count on the linker file structure. This makes the resulting consumer code simpler and cleaner and better hides the linker internals making it possible to sanely lock the linker.
Diffstat (limited to 'sys/netgraph')
-rw-r--r--sys/netgraph/ng_socket.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c
index c977c43..72bff98 100644
--- a/sys/netgraph/ng_socket.c
+++ b/sys/netgraph/ng_socket.c
@@ -65,6 +65,7 @@
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sx.h>
+#include <sys/syscallsubr.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#ifdef NOTYET
@@ -271,24 +272,22 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
if ((type = ng_findtype(mkp->type)) == NULL) {
char filename[NG_TYPESIZ + 3];
- linker_file_t lf;
+ int fileid;
/* Not found, try to load it as a loadable module. */
snprintf(filename, sizeof(filename), "ng_%s",
mkp->type);
- mtx_lock(&Giant);
- error = linker_load_module(NULL, filename, NULL, NULL,
- &lf);
- mtx_unlock(&Giant);
+ error = kern_kldload(curthread, filename, &fileid);
if (error != 0) {
FREE(msg, M_NETGRAPH_MSG);
goto release;
}
- lf->userrefs++;
/* See if type has been loaded successfully. */
if ((type = ng_findtype(mkp->type)) == NULL) {
FREE(msg, M_NETGRAPH_MSG);
+ (void)kern_kldunload(curthread, fileid,
+ LINKER_UNLOAD_NORMAL);
error = ENXIO;
goto release;
}
OpenPOWER on IntegriCloud