mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
ng_socket: Treat EEXIST from kern_kldload() as success
EEXIST is possible in a race condition.
Inspired by: ffc72591b1 (Don't worry if a module is already loaded ...)
Reviewed by: glebius
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44633
(cherry picked from commit f6f67f58c19db4f25f5c2cf4869efc7054493a55)
This commit is contained in:
parent
936c6d5c96
commit
2e8d60c685
1 changed files with 8 additions and 3 deletions
|
|
@ -285,11 +285,15 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
|||
if (ng_findtype(mkp->type) == NULL) {
|
||||
char filename[NG_TYPESIZ + 3];
|
||||
int fileid;
|
||||
bool loaded;
|
||||
|
||||
/* Not found, try to load it as a loadable module. */
|
||||
snprintf(filename, sizeof(filename), "ng_%s",
|
||||
mkp->type);
|
||||
error = kern_kldload(curthread, filename, &fileid);
|
||||
loaded = (error == 0);
|
||||
if (error == EEXIST)
|
||||
error = 0;
|
||||
if (error != 0) {
|
||||
free(msg, M_NETGRAPH_MSG);
|
||||
goto release;
|
||||
|
|
@ -298,9 +302,10 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr,
|
|||
/* See if type has been loaded successfully. */
|
||||
if (ng_findtype(mkp->type) == NULL) {
|
||||
free(msg, M_NETGRAPH_MSG);
|
||||
(void)kern_kldunload(curthread, fileid,
|
||||
LINKER_UNLOAD_NORMAL);
|
||||
error = ENXIO;
|
||||
if (loaded)
|
||||
(void)kern_kldunload(curthread, fileid,
|
||||
LINKER_UNLOAD_NORMAL);
|
||||
error = ENXIO;
|
||||
goto release;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue