Clean up kernel interaction in ip_fw_iface.c
Suggested by: ae
This commit is contained in:
parent
35d5a820e5
commit
98eff10e84
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/ipfw/; revision=269971
@ -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;
|
||||
|
@ -76,7 +76,7 @@ static void iface_khandler_deregister(void);
|
||||
|
||||
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 *ifp)
|
||||
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 *ch, struct ipfw_ifc *ic)
|
||||
|
||||
/*
|
||||
* 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)
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user