Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netpfil/ipfw/ip_fw_dynamic.c
Show First 20 Lines • Show All 2,712 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* This function is used to perform various maintenance | * This function is used to perform various maintenance | ||||
* on dynamic hash lists. Currently it is called every second. | * on dynamic hash lists. Currently it is called every second. | ||||
*/ | */ | ||||
static void | static void | ||||
dyn_tick(void *vnetx) | dyn_tick(void *vnetx) | ||||
{ | { | ||||
struct epoch_tracker et; | |||||
uint32_t buckets; | uint32_t buckets; | ||||
CURVNET_SET((struct vnet *)vnetx); | CURVNET_SET((struct vnet *)vnetx); | ||||
/* | /* | ||||
* First free states unlinked in previous passes. | * First free states unlinked in previous passes. | ||||
*/ | */ | ||||
dyn_free_states(&V_layer3_chain); | dyn_free_states(&V_layer3_chain); | ||||
/* | /* | ||||
* Now unlink others expired states. | * Now unlink others expired states. | ||||
* We use IPFW_UH_WLOCK to avoid concurrent call of | * We use IPFW_UH_WLOCK to avoid concurrent call of | ||||
* dyn_expire_states(). It is the only function that does | * dyn_expire_states(). It is the only function that does | ||||
* deletion of state entries from states lists. | * deletion of state entries from states lists. | ||||
*/ | */ | ||||
IPFW_UH_WLOCK(&V_layer3_chain); | IPFW_UH_WLOCK(&V_layer3_chain); | ||||
dyn_expire_states(&V_layer3_chain, NULL); | dyn_expire_states(&V_layer3_chain, NULL); | ||||
IPFW_UH_WUNLOCK(&V_layer3_chain); | IPFW_UH_WUNLOCK(&V_layer3_chain); | ||||
/* | /* | ||||
* Send keepalives if they are enabled and the time has come. | * Send keepalives if they are enabled and the time has come. | ||||
*/ | */ | ||||
if (V_dyn_keepalive != 0 && | if (V_dyn_keepalive != 0 && | ||||
V_dyn_keepalive_last + V_dyn_keepalive_period <= time_uptime) { | V_dyn_keepalive_last + V_dyn_keepalive_period <= time_uptime) { | ||||
V_dyn_keepalive_last = time_uptime; | V_dyn_keepalive_last = time_uptime; | ||||
NET_EPOCH_ENTER(et); | |||||
dyn_send_keepalive_ipv4(&V_layer3_chain); | dyn_send_keepalive_ipv4(&V_layer3_chain); | ||||
#ifdef INET6 | #ifdef INET6 | ||||
dyn_send_keepalive_ipv6(&V_layer3_chain); | dyn_send_keepalive_ipv6(&V_layer3_chain); | ||||
#endif | #endif | ||||
NET_EPOCH_EXIT(et); | |||||
} | } | ||||
/* | /* | ||||
* Check if we need to resize the hash: | * Check if we need to resize the hash: | ||||
* if current number of states exceeds number of buckets in hash, | * if current number of states exceeds number of buckets in hash, | ||||
* and dyn_buckets_max permits to grow the number of buckets, then | * and dyn_buckets_max permits to grow the number of buckets, then | ||||
* do it. Grow hash size to the minimum power of 2 which is bigger | * do it. Grow hash size to the minimum power of 2 which is bigger | ||||
* than current states count. | * than current states count. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 511 Lines • Show Last 20 Lines |