summaryrefslogtreecommitdiff
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authorMarko Zec <zec@FreeBSD.org>2009-05-05 10:56:12 +0000
committerMarko Zec <zec@FreeBSD.org>2009-05-05 10:56:12 +0000
commit21ca7b57bd9be4aa0b7f4e8d2fb62075319086b6 (patch)
tree79a0bccccf2c92504cdf23ad15f7c1813bb3f926 /sys/kern/kern_linker.c
parent49939083a0543593d9c2729c7d5a835cfb0ac2dd (diff)
Notes
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index 93507134da69..2237107e3704 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -993,6 +993,12 @@ kern_kldload(struct thread *td, const char *file, int *fileid)
return (error);
/*
+ * It's possible that kldloaded module will attach a new ifnet,
+ * so vnet context must be set when this ocurs.
+ */
+ CURVNET_SET(TD_TO_VNET(td));
+
+ /*
* If file does not contain a qualified name or any dot in it
* (kldname.ko, or kldname.ver.ko) treat it as an interface
* name.
@@ -1019,6 +1025,7 @@ kern_kldload(struct thread *td, const char *file, int *fileid)
*fileid = lf->id;
unlock:
KLD_UNLOCK();
+ CURVNET_RESTORE();
return (error);
}
@@ -1056,6 +1063,7 @@ kern_kldunload(struct thread *td, int fileid, int flags)
if ((error = priv_check(td, PRIV_KLD_UNLOAD)) != 0)
return (error);
+ CURVNET_SET(TD_TO_VNET(td));
KLD_LOCK();
lf = linker_find_file_by_id(fileid);
if (lf) {
@@ -1092,6 +1100,7 @@ kern_kldunload(struct thread *td, int fileid, int flags)
PMC_CALL_HOOK(td, PMC_FN_KLD_UNLOAD, (void *) &pkm);
#endif
KLD_UNLOCK();
+ CURVNET_RESTORE();
return (error);
}