Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Aug 2009 04:50:21 GMT
From:      Julian Elischer <julian@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 167266 for review
Message-ID:  <200908130450.n7D4oLFE019676@repoman.freebsd.org>

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

Change 167266 by julian@julian-mac on 2009/08/13 04:49:23

	Add a bit about initializing protocols and protocol domains
	using VNET_PROTO_SET() and friends.

Affected files ...

.. //depot/projects/vimage/porting_to_vimage.txt#15 edit

Differences ...

==== //depot/projects/vimage/porting_to_vimage.txt#15 (text+ko) ====

@@ -62,7 +62,7 @@
 socket->vnet binding gets established, it cannot be changed for the entire
 socket lifetime.
 
-The mapping of a from a thread to a vnet is should always be doen via the 
+The mapping of a from a thread to a vnet should always be done via the 
 TD_TO_VNET macro as the path may change in the future as we get more
 experience with using the system.
 
@@ -254,7 +254,8 @@
 
 When a new loadable module is virtualised the module definitions
 and intializers need to be examined. The following example illustrates
-what is needed:
+what is needed in the case that you are not loading a new protocol, or domain.
+(for that see later)
 
 ============= sample skeleton code ==========
 
@@ -412,6 +413,29 @@
 Sometimes there is a need to iterate through the vnets.
 See the modevent shutdown handler (above) for an example of how to do this.
 
+In the case where you are loading a new protocol, or domain (protocol family)
+there are some "shortcuts" that are in place to allow you to maintain a bit
+more source compatibility with older revisions of FreeBSD. It must be
+added that the sample code above works just fine for protocols, however 
+protcols also have an aditional initialization vector which is via the
+prtocol structure, which has a pr_init() entry.
+When a protocol is registered using pf_proto_register(), the pr_init()
+for the protocol is called once for every existing vnet. in addition, 
+it will be called for each new vnet. The pr_destroy() method will be called
+as well on vnet teardown. The pf_proto_register() funcion can be called
+either from a modevent handler of from the SYSINIT() if you have one, and
+the pf_proto_unregister() called from the SYSUNINIT or the unload 
+modevent handler.
+
+If you are adding a whole new protocol domain, (protocol family) then
+you should add the VNET_DOMAIN_SET(domainname) (e,g, inet, inet6)
+macro. These use VNET_SYSINIT internally to indirectly call the
+dom_init() and pr_init()  functions for each vnet, (and the equivalent for  
+teardown.)  In this case one needs to be absolutely sure that both your
+domain and protocol initializers can be called multiple times, once for
+each vnet. One can still add SYSINITs for once only initialization, 
+or use the modevent handler
+
 finally: 
 The command to make a new jail with a new vnet:
 jail -c host.hostname=test path=/ vnet command=/bin/tcsh



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