[Swan-dev] hash table size and hash

Andrew Cagney andrew.cagney at gmail.com
Wed Oct 18 16:59:46 UTC 2017


I'm going to increase the size of the hash table to 499 (that is apparently
prime) from the existing 32 (which isn't).
The code should at some point be changed to resize dynamically; later, much
later.

I'm also looking at the hashes where we hash the following:

- serialno - serialno % table-size is good enough (this is new)

- pid - pid % table-size is good enough (this is even more new)

- icookie+zero-cookie (we probably shouldn't include the zero-cookie in the
hash but it should do no harm :-)
- icookie+rcookie

these use:

        for (j = 0; j < COOKIE_SIZE; j++)
                i = i * 407 + icookie[j] + rcookie[j];

where 407 isn't prime (does anyone know where 407 came from? if not I'll
change that to a prime 521 which I'm choosing randomly) and I'll change the
math to:

      i * 521 + icookie << 8 + rcookie

So that we don't allow the cookies to cancel out (I could reply with
rcookie = 255 - icookie making the hash very non-random),

Andrew

PS: I suspect ideal is icookie|rcookie % table-size but what ever
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libreswan.org/pipermail/swan-dev/attachments/20171018/43dbc84f/attachment-0001.html>


More information about the Swan-dev mailing list