diff options
author | John Baldwin <jhb@FreeBSD.org> | 2006-06-13 21:36:23 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2006-06-13 21:36:23 +0000 |
commit | edd32c2da270644caf802098bd2aaa5344dc5fe0 (patch) | |
tree | 6bdda3a80fe25172e30b3b25fc2a0ae45191cc84 /sys/netgraph/ng_socket.c | |
parent | b21c9288cef919b48f4676955549ba697f17d224 (diff) | |
download | src-edd32c2da270644caf802098bd2aaa5344dc5fe0.tar.gz src-edd32c2da270644caf802098bd2aaa5344dc5fe0.zip |
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.
Notes
Notes:
svn path=/head/; revision=159590
Diffstat (limited to 'sys/netgraph/ng_socket.c')
-rw-r--r-- | sys/netgraph/ng_socket.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/netgraph/ng_socket.c b/sys/netgraph/ng_socket.c index c977c435b53a..72bff98f6da4 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; } |