From owner-svn-src-projects@FreeBSD.ORG Thu Aug 14 13:25:00 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B4725141; Thu, 14 Aug 2014 13:25:00 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A0E3D2691; Thu, 14 Aug 2014 13:25:00 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s7EDP0Lh094979; Thu, 14 Aug 2014 13:25:00 GMT (envelope-from melifaro@FreeBSD.org) Received: (from melifaro@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s7EDP0Fh094967; Thu, 14 Aug 2014 13:25:00 GMT (envelope-from melifaro@FreeBSD.org) Message-Id: <201408141325.s7EDP0Fh094967@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: melifaro set sender to melifaro@FreeBSD.org using -f From: "Alexander V. Chernikov" Date: Thu, 14 Aug 2014 13:25:00 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r269971 - projects/ipfw/sys/netpfil/ipfw X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Aug 2014 13:25:00 -0000 Author: melifaro Date: Thu Aug 14 13:24:59 2014 New Revision: 269971 URL: http://svnweb.freebsd.org/changeset/base/269971 Log: Clean up kernel interaction in ip_fw_iface.c Suggested by: ae Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw2.c projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw2.c ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw2.c Thu Aug 14 12:50:25 2014 (r269970) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw2.c Thu Aug 14 13:24:59 2014 (r269971) @@ -102,10 +102,6 @@ __FBSDID("$FreeBSD$"); * All ipfw global variables are here. */ -/* ipfw_vnet_ready controls when we are open for business */ -static VNET_DEFINE(int, ipfw_vnet_ready) = 0; -#define V_ipfw_vnet_ready VNET(ipfw_vnet_ready) - static VNET_DEFINE(int, fw_deny_unknown_exthdrs); #define V_fw_deny_unknown_exthdrs VNET(fw_deny_unknown_exthdrs) @@ -152,6 +148,9 @@ VNET_DEFINE(int, verbose_limit); /* layer3_chain contains the list of rules for layer 3 */ VNET_DEFINE(struct ip_fw_chain, layer3_chain); +/* ipfw_vnet_ready controls when we are open for business */ +VNET_DEFINE(int, ipfw_vnet_ready) = 0; + VNET_DEFINE(int, ipfw_nat_ready) = 0; ipfw_nat_t *ipfw_nat_ptr = NULL; Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c Thu Aug 14 12:50:25 2014 (r269970) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_iface.c Thu Aug 14 13:24:59 2014 (r269971) @@ -76,7 +76,7 @@ static void iface_khandler_deregister(vo static eventhandler_tag ipfw_ifdetach_event, ipfw_ifattach_event; static int num_vnets = 0; -struct mtx vnet_mtx; +static struct mtx vnet_mtx; /* * Checks if kernel interface is contained in our tracked @@ -90,19 +90,20 @@ ipfw_kifhandler(void *arg, struct ifnet struct namedobj_instance *ii; uintptr_t htype; + if (V_ipfw_vnet_ready == 0) + return; + ch = &V_layer3_chain; htype = (uintptr_t)arg; - if (ch == NULL) - return; - IPFW_UH_WLOCK(ch); ii = CHAIN_TO_II(ch); if (ii == NULL) { IPFW_UH_WUNLOCK(ch); return; } - iif = (struct ipfw_iface*)ipfw_objhash_lookup_name(ii, 0,ifp->if_xname); + iif = (struct ipfw_iface*)ipfw_objhash_lookup_name(ii, 0, + if_name(ifp)); if (iif != NULL) { if (htype == 1) handle_ifattach(ch, iif, ifp->if_index); @@ -154,8 +155,9 @@ iface_khandler_deregister() destroy = 0; mtx_lock(&vnet_mtx); - if (--num_vnets == 0) + if (num_vnets == 1) destroy = 1; + num_vnets--; mtx_unlock(&vnet_mtx); if (destroy == 0) @@ -242,14 +244,9 @@ static void destroy_iface(struct namedobj_instance *ii, struct named_object *no, void *arg) { - struct ipfw_iface *iif; - struct ip_fw_chain *ch; - - ch = (struct ip_fw_chain *)arg; - iif = (struct ipfw_iface *)no; /* Assume all consumers have been already detached */ - free(iif, M_IPFW); + free(no, M_IPFW); } /* @@ -376,7 +373,7 @@ ipfw_iface_add_notify(struct ip_fw_chain /* * Unlinks interface tracker object @ic from interface. - * Must be called whi holding UH lock. + * Must be called while holding UH lock. */ void ipfw_iface_del_notify(struct ip_fw_chain *ch, struct ipfw_ifc *ic) Modified: projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h ============================================================================== --- projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Thu Aug 14 12:50:25 2014 (r269970) +++ projects/ipfw/sys/netpfil/ipfw/ip_fw_private.h Thu Aug 14 13:24:59 2014 (r269971) @@ -207,6 +207,9 @@ VNET_DECLARE(int, fw_verbose); VNET_DECLARE(struct ip_fw_chain, layer3_chain); #define V_layer3_chain VNET(layer3_chain) +VNET_DECLARE(int, ipfw_vnet_ready); +#define V_ipfw_vnet_ready VNET(ipfw_vnet_ready) + VNET_DECLARE(u_int32_t, set_disable); #define V_set_disable VNET(set_disable)