Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netpfil/pf/pf_norm.c
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | |||||
struct pf_fragment_tag { | struct pf_fragment_tag { | ||||
uint16_t ft_hdrlen; /* header length of reassembled pkt */ | uint16_t ft_hdrlen; /* header length of reassembled pkt */ | ||||
uint16_t ft_extoff; /* last extension header offset or 0 */ | uint16_t ft_extoff; /* last extension header offset or 0 */ | ||||
uint16_t ft_maxlen; /* maximum fragment payload length */ | uint16_t ft_maxlen; /* maximum fragment payload length */ | ||||
uint32_t ft_id; /* fragment id */ | uint32_t ft_id; /* fragment id */ | ||||
}; | }; | ||||
static struct mtx pf_frag_mtx; | VNET_DEFINE_STATIC(struct mtx, pf_frag_mtx); | ||||
MTX_SYSINIT(pf_frag_mtx, &pf_frag_mtx, "pf fragments", MTX_DEF); | #define V_pf_frag_mtx VNET(pf_frag_mtx) | ||||
#define PF_FRAG_LOCK() mtx_lock(&pf_frag_mtx) | #define PF_FRAG_LOCK() mtx_lock(&V_pf_frag_mtx) | ||||
#define PF_FRAG_UNLOCK() mtx_unlock(&pf_frag_mtx) | #define PF_FRAG_UNLOCK() mtx_unlock(&V_pf_frag_mtx) | ||||
#define PF_FRAG_ASSERT() mtx_assert(&pf_frag_mtx, MA_OWNED) | #define PF_FRAG_ASSERT() mtx_assert(&V_pf_frag_mtx, MA_OWNED) | ||||
VNET_DEFINE(uma_zone_t, pf_state_scrub_z); /* XXX: shared with pfsync */ | VNET_DEFINE(uma_zone_t, pf_state_scrub_z); /* XXX: shared with pfsync */ | ||||
VNET_DEFINE_STATIC(uma_zone_t, pf_frent_z); | VNET_DEFINE_STATIC(uma_zone_t, pf_frent_z); | ||||
#define V_pf_frent_z VNET(pf_frent_z) | #define V_pf_frent_z VNET(pf_frent_z) | ||||
VNET_DEFINE_STATIC(uma_zone_t, pf_frag_z); | VNET_DEFINE_STATIC(uma_zone_t, pf_frag_z); | ||||
#define V_pf_frag_z VNET(pf_frag_z) | #define V_pf_frag_z VNET(pf_frag_z) | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | pf_normalize_init(void) | ||||
V_pf_frag_z = uma_zcreate("pf frags", sizeof(struct pf_fragment), | V_pf_frag_z = uma_zcreate("pf frags", sizeof(struct pf_fragment), | ||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | ||||
V_pf_frent_z = uma_zcreate("pf frag entries", sizeof(struct pf_frent), | V_pf_frent_z = uma_zcreate("pf frag entries", sizeof(struct pf_frent), | ||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | ||||
V_pf_state_scrub_z = uma_zcreate("pf state scrubs", | V_pf_state_scrub_z = uma_zcreate("pf state scrubs", | ||||
sizeof(struct pf_state_scrub), NULL, NULL, NULL, NULL, | sizeof(struct pf_state_scrub), NULL, NULL, NULL, NULL, | ||||
UMA_ALIGN_PTR, 0); | UMA_ALIGN_PTR, 0); | ||||
mtx_init(&V_pf_frag_mtx, "pf fragments", NULL, MTX_DEF); | |||||
V_pf_limits[PF_LIMIT_FRAGS].zone = V_pf_frent_z; | V_pf_limits[PF_LIMIT_FRAGS].zone = V_pf_frent_z; | ||||
V_pf_limits[PF_LIMIT_FRAGS].limit = PFFRAG_FRENT_HIWAT; | V_pf_limits[PF_LIMIT_FRAGS].limit = PFFRAG_FRENT_HIWAT; | ||||
uma_zone_set_max(V_pf_frent_z, PFFRAG_FRENT_HIWAT); | uma_zone_set_max(V_pf_frent_z, PFFRAG_FRENT_HIWAT); | ||||
uma_zone_set_warning(V_pf_frent_z, "PF frag entries limit reached"); | uma_zone_set_warning(V_pf_frent_z, "PF frag entries limit reached"); | ||||
TAILQ_INIT(&V_pf_fragqueue); | TAILQ_INIT(&V_pf_fragqueue); | ||||
} | } | ||||
void | void | ||||
pf_normalize_cleanup(void) | pf_normalize_cleanup(void) | ||||
{ | { | ||||
uma_zdestroy(V_pf_state_scrub_z); | uma_zdestroy(V_pf_state_scrub_z); | ||||
uma_zdestroy(V_pf_frent_z); | uma_zdestroy(V_pf_frent_z); | ||||
uma_zdestroy(V_pf_frag_z); | uma_zdestroy(V_pf_frag_z); | ||||
mtx_destroy(&V_pf_frag_mtx); | |||||
} | } | ||||
static int | static int | ||||
pf_frag_compare(struct pf_fragment *a, struct pf_fragment *b) | pf_frag_compare(struct pf_fragment *a, struct pf_fragment *b) | ||||
{ | { | ||||
int diff; | int diff; | ||||
if ((diff = a->fr_id - b->fr_id) != 0) | if ((diff = a->fr_id - b->fr_id) != 0) | ||||
▲ Show 20 Lines • Show All 1,788 Lines • Show Last 20 Lines |