From owner-p4-projects@FreeBSD.ORG Wed Aug 1 17:05:31 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id E097D16A41F; Wed, 1 Aug 2007 17:05:30 +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 A048D16A41A for ; Wed, 1 Aug 2007 17:05:30 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 9140B13C442 for ; Wed, 1 Aug 2007 17:05:30 +0000 (UTC) (envelope-from zec@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id l71H5Uia052782 for ; Wed, 1 Aug 2007 17:05:30 GMT (envelope-from zec@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id l71H5Ulh052779 for perforce@freebsd.org; Wed, 1 Aug 2007 17:05:30 GMT (envelope-from zec@FreeBSD.org) Date: Wed, 1 Aug 2007 17:05:30 GMT Message-Id: <200708011705.l71H5Ulh052779@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to zec@FreeBSD.org using -f From: Marko Zec To: Perforce Change Reviews Cc: Subject: PERFORCE change 124477 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: Wed, 01 Aug 2007 17:05:31 -0000 http://perforce.freebsd.org/chv.cgi?CH=124477 Change 124477 by zec@zec_tpx32 on 2007/08/01 17:04:33 Register netgraph as a vnet module from a SYSINIT-triggered function, not modevent handler. This ensures that netgraph will be registered as (one of) the last vnet modules, regardless whether netgraph is kldloaded at run time, kldloaded before booting, or statically compiled in the kernel. In effect, a per vnet module destructor for netgsaph will be always invoked before other protocol module's destructors, ensuring ng nodes and thus ifnets will be gone before other protocol instances begin to vanish. Before this change, if netgraph were kldloaded before booting, netgraph nodes and associated ifnets would still be hanging around during network protocols shutting down, leading to random panics. Affected files ... .. //depot/projects/vimage/src/sys/netgraph/ng_base.c#16 edit Differences ... ==== //depot/projects/vimage/src/sys/netgraph/ng_base.c#16 (text+ko) ==== @@ -251,7 +251,9 @@ static vnet_attach_fn vnet_netgraph_iattach; #ifdef VIMAGE static vnet_detach_fn vnet_netgraph_idetach; -#endif +static void netgraph_register(void *); +SYSINIT(netgraph, SI_SUB_PROTO_END, SI_ORDER_FIRST, netgraph_register, NULL) +#endif /* VIMAGE */ VNET_MOD_DECLARE(NETGRAPH, netgraph, NULL, vnet_netgraph_iattach, vnet_netgraph_idetach) @@ -3189,11 +3191,9 @@ uma_zone_set_max(ng_qzone, maxalloc); netisr_register(NETISR_NETGRAPH, (netisr_t *)ngintr, NULL, NETISR_MPSAFE); -#ifdef VIMAGE - vnet_mod_register(&vnet_netgraph_modinfo); -#else +#ifndef VIMAGE vnet_netgraph_iattach(NULL); -#endif +#endif /* !VIMAGE */ break; case MOD_UNLOAD: /* You can't unload it because an interface may be using it. */ @@ -3215,7 +3215,7 @@ return 0; } -#ifdef VIMAGE +#ifdef VIMAGE static int vnet_netgraph_idetach(const void *unused) { INIT_VNET_NETGRAPH(curvnet); @@ -3239,7 +3239,12 @@ return 0; } -#endif + +void netgraph_register(void *unused) +{ + vnet_mod_register(&vnet_netgraph_modinfo); +} +#endif /* VIMAGE */ static moduledata_t netgraph_mod = { "netgraph",