Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Dec 2016 23:52:56 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r309660 - head/sys/netpfil/ipfw
Message-ID:  <201612062352.uB6NquYS045803@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Tue Dec  6 23:52:56 2016
New Revision: 309660
URL: https://svnweb.freebsd.org/changeset/base/309660

Log:
  Convert result of hash_packet6() into host byte order.
  
  For IPv4 similar function uses addresses and ports in host byte order,
  but for IPv6 it used network byte order. This led to very bad hash
  distribution for IPv6 flows. Now the result looks similar to IPv4.
  
  Reported by:	olivier
  MFC after:	1 week
  Sponsored by:	Yandex LLC

Modified:
  head/sys/netpfil/ipfw/ip_fw_dynamic.c

Modified: head/sys/netpfil/ipfw/ip_fw_dynamic.c
==============================================================================
--- head/sys/netpfil/ipfw/ip_fw_dynamic.c	Tue Dec  6 23:43:04 2016	(r309659)
+++ head/sys/netpfil/ipfw/ip_fw_dynamic.c	Tue Dec  6 23:52:56 2016	(r309660)
@@ -256,9 +256,8 @@ hash_packet6(struct ipfw_flow_id *id)
 	i = (id->dst_ip6.__u6_addr.__u6_addr32[2]) ^
 	    (id->dst_ip6.__u6_addr.__u6_addr32[3]) ^
 	    (id->src_ip6.__u6_addr.__u6_addr32[2]) ^
-	    (id->src_ip6.__u6_addr.__u6_addr32[3]) ^
-	    (id->dst_port) ^ (id->src_port);
-	return i;
+	    (id->src_ip6.__u6_addr.__u6_addr32[3]);
+	return ntohl(i);
 }
 #endif
 
@@ -277,9 +276,9 @@ hash_packet(struct ipfw_flow_id *id, int
 		i = hash_packet6(id);
 	else
 #endif /* INET6 */
-	i = (id->dst_ip) ^ (id->src_ip) ^ (id->dst_port) ^ (id->src_port);
-	i &= (buckets - 1);
-	return i;
+	i = (id->dst_ip) ^ (id->src_ip);
+	i ^= (id->dst_port) ^ (id->src_port);
+	return (i & (buckets - 1));
 }
 
 #if 0



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