Changeset View
Changeset View
Standalone View
Standalone View
sys/netpfil/pf/pf.c
Show First 20 Lines • Show All 413 Lines • ▼ Show 20 Lines | SYSCTL_ULONG(_net_pf, OID_AUTO, request_maxcount, CTLFLAG_RWTUN, | ||||
&pf_ioctl_maxcount, 0, "Maximum number of tables, addresses, ... in a single ioctl() call"); | &pf_ioctl_maxcount, 0, "Maximum number of tables, addresses, ... in a single ioctl() call"); | ||||
VNET_DEFINE(void *, pf_swi_cookie); | VNET_DEFINE(void *, pf_swi_cookie); | ||||
VNET_DEFINE(struct intr_event *, pf_swi_ie); | VNET_DEFINE(struct intr_event *, pf_swi_ie); | ||||
VNET_DEFINE(uint32_t, pf_hashseed); | VNET_DEFINE(uint32_t, pf_hashseed); | ||||
#define V_pf_hashseed VNET(pf_hashseed) | #define V_pf_hashseed VNET(pf_hashseed) | ||||
#ifdef __LP64__ | |||||
static int | |||||
pf_bcmp_state_key(struct pf_state_key *k1_orig, struct pf_state_key_cmp *k2_orig) | |||||
{ | |||||
unsigned long *k1 = (unsigned long *)k1_orig; | |||||
unsigned long *k2 = (unsigned long *)k2_orig; | |||||
if (k1[0] != k2[0]) | |||||
return (1); | |||||
kp: s1ptr (and s2ptr) is not declared anywhere. Do you mean `var1 = k1[0]`? | |||||
Done Inline Actionsi somehow upload the older version mjg: i somehow upload the older version | |||||
if (k1[1] != k2[1]) | |||||
return (1); | |||||
Done Inline ActionsCan't we do if (k1[0] != k2[0])? kp: Can't we do `if (k1[0] != k2[0])`? | |||||
if (k1[2] != k2[2]) | |||||
return (1); | |||||
if (k1[3] != k2[3]) | |||||
return (1); | |||||
if (k1[4] != k2[4]) | |||||
return (1); | |||||
return (0); | |||||
} | |||||
_Static_assert(sizeof(struct pf_state_key_cmp) == 40, "bad size of pf_state_key_cmp"); | |||||
#else | |||||
static inline int | |||||
pf_bcmp_state_key(struct pf_state_key *k1_orig, struct pf_state_key_cmp *k2_orig) | |||||
{ | |||||
return (bcmp(k1_orig, k2_orig, sizeof(struct pf_state_key_cmp))); | |||||
} | |||||
#endif | |||||
int | int | ||||
pf_addr_cmp(struct pf_addr *a, struct pf_addr *b, sa_family_t af) | pf_addr_cmp(struct pf_addr *a, struct pf_addr *b, sa_family_t af) | ||||
{ | { | ||||
switch (af) { | switch (af) { | ||||
#ifdef INET | #ifdef INET | ||||
case AF_INET: | case AF_INET: | ||||
if (a->addr32[0] > b->addr32[0]) | if (a->addr32[0] > b->addr32[0]) | ||||
▲ Show 20 Lines • Show All 739 Lines • ▼ Show 20 Lines | #define KEYS_UNLOCK() do { \ | ||||
kh = khw; | kh = khw; | ||||
idx = PF_SK_WIRE; | idx = PF_SK_WIRE; | ||||
MPASS(s->lock == NULL); | MPASS(s->lock == NULL); | ||||
s->lock = &V_pf_idhash[PF_IDHASH(s)].lock; | s->lock = &V_pf_idhash[PF_IDHASH(s)].lock; | ||||
keyattach: | keyattach: | ||||
LIST_FOREACH(cur, &kh->keys, entry) | LIST_FOREACH(cur, &kh->keys, entry) | ||||
if (bcmp(cur, sk, sizeof(struct pf_state_key_cmp)) == 0) | if (pf_bcmp_state_key(cur, (struct pf_state_key_cmp *)sk) == 0) | ||||
break; | break; | ||||
if (cur != NULL) { | if (cur != NULL) { | ||||
/* Key exists. Check for same kif, if none, add to key. */ | /* Key exists. Check for same kif, if none, add to key. */ | ||||
TAILQ_FOREACH(si, &cur->states[idx], key_list[idx]) { | TAILQ_FOREACH(si, &cur->states[idx], key_list[idx]) { | ||||
struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(si)]; | struct pf_idhash *ih = &V_pf_idhash[PF_IDHASH(si)]; | ||||
PF_HASHROW_LOCK(ih); | PF_HASHROW_LOCK(ih); | ||||
▲ Show 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | pf_find_state(struct pfi_kkif *kif, struct pf_state_key_cmp *key, u_int dir) | ||||
int idx; | int idx; | ||||
pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); | pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); | ||||
kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; | kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; | ||||
PF_HASHROW_LOCK(kh); | PF_HASHROW_LOCK(kh); | ||||
LIST_FOREACH(sk, &kh->keys, entry) | LIST_FOREACH(sk, &kh->keys, entry) | ||||
if (bcmp(sk, key, sizeof(struct pf_state_key_cmp)) == 0) | if (pf_bcmp_state_key(sk, key) == 0) | ||||
break; | break; | ||||
if (sk == NULL) { | if (sk == NULL) { | ||||
PF_HASHROW_UNLOCK(kh); | PF_HASHROW_UNLOCK(kh); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK); | idx = (dir == PF_IN ? PF_SK_WIRE : PF_SK_STACK); | ||||
Show All 30 Lines | pf_find_state_all(struct pf_state_key_cmp *key, u_int dir, int *more) | ||||
int idx, inout = 0; | int idx, inout = 0; | ||||
pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); | pf_counter_u64_add(&V_pf_status.fcounters[FCNT_STATE_SEARCH], 1); | ||||
kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; | kh = &V_pf_keyhash[pf_hashkey((struct pf_state_key *)key)]; | ||||
PF_HASHROW_LOCK(kh); | PF_HASHROW_LOCK(kh); | ||||
LIST_FOREACH(sk, &kh->keys, entry) | LIST_FOREACH(sk, &kh->keys, entry) | ||||
if (bcmp(sk, key, sizeof(struct pf_state_key_cmp)) == 0) | if (pf_bcmp_state_key(sk, key) == 0) | ||||
break; | break; | ||||
if (sk == NULL) { | if (sk == NULL) { | ||||
PF_HASHROW_UNLOCK(kh); | PF_HASHROW_UNLOCK(kh); | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
switch (dir) { | switch (dir) { | ||||
case PF_IN: | case PF_IN: | ||||
idx = PF_SK_WIRE; | idx = PF_SK_WIRE; | ||||
▲ Show 20 Lines • Show All 5,830 Lines • Show Last 20 Lines |
s1ptr (and s2ptr) is not declared anywhere. Do you mean var1 = k1[0]?