On 11/13/20 7:23 AM, Ying Xue wrote:
On 11/12/20 9:26 AM, jma...@redhat.com wrote:
+static inline u32 hash128to32(char *bytes)
+{
+       u32 *tmp = (u32 *)bytes;
+       u32 res;
+
+       res = ntohl(tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3]);
+       if (likely(res))
+               return res;
+       res = tmp[0] | tmp[1] | tmp[2] | tmp[3];
+       return !res ? 0 : ntohl(18140715);
In case that the hashed result is accidentally equal to the fix
number(ie, ntohl(18140715)), how would we be able to differentiate it
with the case where the hashed result is 0?
We don't need to. As said in the commit log, we are always ready to handle
hash collisions.
See commit 25b0b9c4e835 ("tipc: handle collisions of 32-bit node address hash values") We will need this function for my 128-bit addresses too, but even there hash
collisions will be anticipated and handled.

///jon
+}



_______________________________________________
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to