summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorae <ae@FreeBSD.org>2016-12-13 09:17:30 +0000
committerLuiz Souza <luiz@netgate.com>2017-07-15 11:10:07 -0500
commit271dd72d566667c516546b8bb298ab52c9a13292 (patch)
treeba5978210549449045f8bbe94a55cc80b1920767
parent9f4b4c2e952edd89273b7920739a7021ee0ffd57 (diff)
downloadFreeBSD-src-271dd72d566667c516546b8bb298ab52c9a13292.zip
FreeBSD-src-271dd72d566667c516546b8bb298ab52c9a13292.tar.gz
MFC r309660:
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. (cherry picked from commit 0a0bda82615be0207814d7a2c02873ec5ecedce8)
-rw-r--r--sys/netpfil/ipfw/ip_fw_dynamic.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/netpfil/ipfw/ip_fw_dynamic.c b/sys/netpfil/ipfw/ip_fw_dynamic.c
index 53df5e2..7dd72e4 100644
--- a/sys/netpfil/ipfw/ip_fw_dynamic.c
+++ b/sys/netpfil/ipfw/ip_fw_dynamic.c
@@ -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 buckets)
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));
}
/**
OpenPOWER on IntegriCloud