PERFORCE change 161475 for review

Marko Zec zec at FreeBSD.org
Sat May 2 10:53:45 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=161475

Change 161475 by zec at zec_tpx32 on 2009/05/02 10:52:44

	Set / clear vnet context when kldloading / kldunloading
	modules.

Affected files ...

.. //depot/projects/vimage-commit2/src/sys/kern/kern_linker.c#10 edit

Differences ...

==== //depot/projects/vimage-commit2/src/sys/kern/kern_linker.c#10 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_linker.c,v 1.166 2009/02/10 15:50:19 attilio Exp $");
+__FBSDID("$FreeBSD: head/sys/kern/kern_linker.c 188440 2009-02-10 15:50:19Z attilio $");
 
 #include "opt_ddb.h"
 #include "opt_hwpmc_hooks.h"
@@ -993,6 +993,12 @@
 		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 @@
 		*fileid = lf->id;
 unlock:
 	KLD_UNLOCK();
+	CURVNET_RESTORE();
 	return (error);
 }
 
@@ -1056,6 +1063,7 @@
 	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 @@
 		PMC_CALL_HOOK(td, PMC_FN_KLD_UNLOAD, (void *) &pkm);
 #endif
 	KLD_UNLOCK();
+	CURVNET_RESTORE();
 	return (error);
 }
 


More information about the p4-projects mailing list