Date: Thu, 14 Aug 2014 13:25:00 +0000 (UTC) From: "Alexander V. Chernikov" <melifaro@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r269971 - projects/ipfw/sys/netpfil/ipfw Message-ID: <201408141325.s7EDP0Fh094967@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408141325.s7EDP0Fh094967>