diff options
author | glebius <glebius@FreeBSD.org> | 2012-09-20 06:52:05 +0000 |
---|---|---|
committer | glebius <glebius@FreeBSD.org> | 2012-09-20 06:52:05 +0000 |
commit | 90628516533ba3a215431824df6d379724744711 (patch) | |
tree | 2c1bc7e95c0606a90a10596824be27a3882c2d28 /sys/netpfil | |
parent | 2de8d93bb9d336b9ca03d3132f94a93ba90e7787 (diff) | |
download | FreeBSD-src-90628516533ba3a215431824df6d379724744711.zip FreeBSD-src-90628516533ba3a215431824df6d379724744711.tar.gz |
Utilize Jenkins hash with random seed for source nodes storage.
Diffstat (limited to 'sys/netpfil')
-rw-r--r-- | sys/netpfil/pf/pf.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/netpfil/pf/pf.c b/sys/netpfil/pf/pf.c index 74b3a64..3f23c35 100644 --- a/sys/netpfil/pf/pf.c +++ b/sys/netpfil/pf/pf.c @@ -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) |