Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Sep 2012 06:52:06 +0000 (UTC)
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r240736 - in head/sys: net netpfil/pf
Message-ID:  <201209200652.q8K6q6Eq061849@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209200652.q8K6q6Eq061849>