Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 May 2009 10:53:44 GMT
From:      Marko Zec <zec@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 161475 for review
Message-ID:  <200905021053.n42Ariii031849@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=161475

Change 161475 by zec@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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200905021053.n42Ariii031849>