From: Russ Combs (rucombs) Date: Fri, 27 Jan 2017 17:54:01 +0000 (-0500) Subject: Merge pull request #793 in SNORT/snort3 from hardly to master X-Git-Tag: 3.0.0-233~96 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d9b15c3f4d42b31fcc10f4fd6916c19389c40b04;p=thirdparty%2Fsnort3.git Merge pull request #793 in SNORT/snort3 from hardly to master Squashed commit of the following: commit 2cf0b48aa3296297e7ce3629fac594f79ba9a628 Author: Russ Combs Date: Fri Jan 27 12:08:00 2017 -0500 initialize flow hash with hardener --- diff --git a/src/flow/flow_key.cc b/src/flow/flow_key.cc index 14967f317..542b8af6c 100644 --- a/src/flow/flow_key.cc +++ b/src/flow/flow_key.cc @@ -268,33 +268,36 @@ bool FlowKey::init( // hash foo //------------------------------------------------------------------------- -uint32_t FlowKey::hash(SFHASHFCN*, unsigned char* d, int) +uint32_t FlowKey::hash(SFHASHFCN* hf, unsigned char* p, int) { - uint32_t a,b,c; + uint32_t a, b, c; + a = b = c = hf->hardener; - a = *(uint32_t*)d; /* IPv6 lo[0] */ - b = *(uint32_t*)(d+4); /* IPv6 lo[1] */ - c = *(uint32_t*)(d+8); /* IPv6 lo[2] */ + const uint32_t* d = (uint32_t*)p; - mix(a,b,c); + a += d[0]; // IPv6 lo[0] + b += d[1]; // IPv6 lo[1] + c += d[2]; // IPv6 lo[2] - a += *(uint32_t*)(d+12); /* IPv6 lo[3] */ - b += *(uint32_t*)(d+16); /* IPv6 hi[0] */ - c += *(uint32_t*)(d+20); /* IPv6 hi[1] */ + mix(a, b, c); - mix(a,b,c); + a += d[3]; // IPv6 lo[3] + b += d[4]; // IPv6 hi[0] + c += d[5]; // IPv6 hi[1] - a += *(uint32_t*)(d+24); /* IPv6 hi[2] */ - b += *(uint32_t*)(d+28); /* IPv6 hi[3] */ - c += *(uint32_t*)(d+32); /* port lo & port hi */ + mix(a, b, c); - mix(a,b,c); + a += d[6]; // IPv6 hi[2] + b += d[7]; // IPv6 hi[3] + c += d[8]; // port lo & port hi - a += *(uint32_t*)(d+36); /* vlan tag, packet type, & version */ - b += *(uint32_t*)(d+40); /* mpls label */ - c += *(uint32_t*)(d+44); /* address space id and 16bits of zero'd pad */ + mix(a, b, c); - finalize(a,b,c); + a += d[9]; // vlan tag, packet type, & version + b += d[10]; // mpls label + c += d[11]; // address space id and 16bits of zero'd pad + + finalize(a, b, c); return c; }