From 80ecb121906c7790840f7eed26d8b062a0829f67 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 28 Mar 2019 14:07:46 -0700 Subject: [PATCH 1/2] change the IPv6 hash function to be more efficient --- flow/network.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flow/network.h b/flow/network.h index a7660d31c6..b652c1878e 100644 --- a/flow/network.h +++ b/flow/network.h @@ -201,7 +201,7 @@ namespace std { int result = 0; if (na.ip.isV6()) { - result = crc32c_append( 0xfdbeefdb, (uint8_t*)na.ip.toV6().data(), 16 ); + result = ((uint16_t*) na.ip.toV6().data())[7]; } else { result = na.ip.toV4(); } From aa368c08a24a76e8d9a899108b97783f25c567b8 Mon Sep 17 00:00:00 2001 From: Evan Tschannen Date: Thu, 28 Mar 2019 17:47:13 -0700 Subject: [PATCH 2/2] changed NetworkAddress hash function to use more bytes from the IP address --- flow/network.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flow/network.h b/flow/network.h index b652c1878e..9e7b3a385f 100644 --- a/flow/network.h +++ b/flow/network.h @@ -199,9 +199,10 @@ namespace std { size_t operator()(const NetworkAddress& na) const { - int result = 0; + size_t result = 0; if (na.ip.isV6()) { - result = ((uint16_t*) na.ip.toV6().data())[7]; + uint16_t* ptr = (uint16_t*)na.ip.toV6().data(); + result = ((size_t)ptr[5] << 32) | ((size_t)ptr[6] << 16) | ptr[7]; } else { result = na.ip.toV4(); }