From owner-svn-src-all@FreeBSD.ORG Thu Sep 20 06:52:06 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AB1AB1065670; Thu, 20 Sep 2012 06:52:06 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7D7DB8FC0C; Thu, 20 Sep 2012 06:52:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8K6q6KC061852; Thu, 20 Sep 2012 06:52:06 GMT (envelope-from glebius@svn.freebsd.org) Received: (from glebius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8K6q6Eq061849; Thu, 20 Sep 2012 06:52:06 GMT (envelope-from glebius@svn.freebsd.org) Message-Id: <201209200652.q8K6q6Eq061849@svn.freebsd.org> From: Gleb Smirnoff Date: Thu, 20 Sep 2012 06:52:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r240736 - in head/sys: net netpfil/pf X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Sep 2012 06:52:06 -0000 Author: glebius Date: Thu Sep 20 06:52:05 2012 New Revision: 240736 URL: http://svn.freebsd.org/changeset/base/240736 Log: Utilize Jenkins hash with random seed for source nodes storage. Modified: head/sys/net/pfvar.h head/sys/netpfil/pf/pf.c Modified: head/sys/net/pfvar.h ============================================================================== --- head/sys/net/pfvar.h Thu Sep 20 05:49:31 2012 (r240735) +++ head/sys/net/pfvar.h Thu Sep 20 06:52:05 2012 (r240736) @@ -1730,28 +1730,6 @@ extern int pf_state_insert(struct pfi 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) { Modified: head/sys/netpfil/pf/pf.c ============================================================================== --- head/sys/netpfil/pf/pf.c Thu Sep 20 05:49:31 2012 (r240735) +++ head/sys/netpfil/pf/pf.c Thu Sep 20 06:52:05 2012 (r240736) @@ -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)