From owner-p4-projects@FreeBSD.ORG Thu Aug 13 04:50:22 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 480CB106566C; Thu, 13 Aug 2009 04:50:22 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F06D4106564A for ; Thu, 13 Aug 2009 04:50:21 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C59A38FC3E for ; Thu, 13 Aug 2009 04:50:21 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n7D4oL4p019678 for ; Thu, 13 Aug 2009 04:50:21 GMT (envelope-from julian@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n7D4oLFE019676 for perforce@freebsd.org; Thu, 13 Aug 2009 04:50:21 GMT (envelope-from julian@freebsd.org) Date: Thu, 13 Aug 2009 04:50:21 GMT Message-Id: <200908130450.n7D4oLFE019676@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to julian@freebsd.org using -f From: Julian Elischer To: Perforce Change Reviews Cc: Subject: PERFORCE change 167266 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Aug 2009 04:50:23 -0000 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