<div dir="ltr">Hi,<br><div class="gmail_quote"><div dir="ltr"><div><div><div><div><div><div><div><div><br></div>I
was trying to understand how dnsmasq computes the IP it gives out to a
specific computer, which brought me to this e-mail chain: <a href="http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2010q2/003893.html" target="_blank">http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2010q2/003893.html</a><br><br></div>This mentions the SDBM hash described here: <a href="http://www.cse.yorku.ca/%7Eoz/hash.html" target="_blank">http://www.cse.yorku.ca/~oz/hash.html</a><br><br></div>However, there is a typo in the implementation, which is increasing the number of collisions in this hash.<br><br></div>This
might be irrelevant as the number of possible hashes is already high,
but still I thought to warn you, as the fix is simple.<br><br></div>A potential patch to fix it would be:<br><br>diff --git a/src/dhcp.c b/src/dhcp.c<br>index c11675d..00145bc 100644<br>--- a/src/dhcp.c<br>+++ b/src/dhcp.c<br>@@ -651,7 +651,7 @@ int address_allocate(struct dhcp_context *context,<br> /* hash hwaddr: use the SDBM hashing algorithm. Seems to give good<br> dispersal even with similarly-valued "strings". */ <br> for (j = 0, i = 0; i < hw_len; i++)<br>- j += hwaddr[i] + (j << 6) + (j << 16) - j;<br>+ j = hwaddr[i] + (j << 6) + (j << 16) - j;<br> <br> for (pass = 0; pass <= 1; pass++)<br> for (c = context; c; c = c->current)<span class=""><font color="#888888"><br>-- <br><br></font></span></div><span class=""><font color="#888888">Sorry if this is just nitpicking.<br><br></font></span></div><span class=""><font color="#888888">Best Regards,<br></font></span></div><span class=""><font color="#888888">Luis Carvalho<br></font></span></div>
</div></div>