1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-15 10:17:20 +00:00

Utilize Jenkins hash with random seed for source nodes storage.

This commit is contained in:
Gleb Smirnoff 2012-09-20 06:52:05 +00:00
parent e8574be32c
commit 22c914789e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240736
2 changed files with 21 additions and 22 deletions

View File

@ -1730,28 +1730,6 @@ extern int pf_state_insert(struct pfi_kif *,
struct pf_state *);
extern void pf_free_state(struct pf_state *);
static __inline u_int
pf_hashsrc(struct pf_addr *addr, sa_family_t af)
{
u_int h;
#define ADDR_HASH(a) ((a) ^ ((a) >> 16))
switch (af) {
case AF_INET:
h = ADDR_HASH(addr->v4.s_addr);
break;
case AF_INET6:
h = ADDR_HASH(addr->v6.__u6_addr.__u6_addr32[3]);
break;
default:
panic("%s: unknown address family %u", __func__, af);
}
#undef ADDR_HASH
return (h & V_pf_srchashmask);
}
static __inline void
pf_ref_state(struct pf_state *s)
{

View File

@ -387,6 +387,27 @@ pf_hashkey(struct pf_state_key *sk)
return (h & V_pf_hashmask);
}
static __inline uint32_t
pf_hashsrc(struct pf_addr *addr, sa_family_t af)
{
uint32_t h;
switch (af) {
case AF_INET:
h = jenkins_hash32((uint32_t *)&addr->v4,
sizeof(addr->v4)/sizeof(uint32_t), V_pf_hashseed);
break;
case AF_INET6:
h = jenkins_hash32((uint32_t *)&addr->v6,
sizeof(addr->v6)/sizeof(uint32_t), V_pf_hashseed);
break;
default:
panic("%s: unknown address family %u", __func__, af);
}
return (h & V_pf_srchashmask);
}
#ifdef INET6
void
pf_addrcpy(struct pf_addr *dst, struct pf_addr *src, sa_family_t af)