[Dnsmasq-discuss] Little detail in DHCP address allocation

Simon Kelley simon at thekelleys.org.uk
Mon Apr 25 17:07:31 BST 2016


Thanks for that. I pushed that fix, and the equivalent one in the DHCPv6
code, which got the same error by cut 'n paste....




Cheers,

Simon.

On 16/03/16 11:33, Luís Carvalho wrote:
> Hi,
> 
> 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:
> http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2010q2/003893.html
> 
> This mentions the SDBM hash described here:
> http://www.cse.yorku.ca/~oz/hash.html
> 
> However, there is a typo in the implementation, which is increasing the
> number of collisions in this hash.
> 
> 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.
> 
> A potential patch to fix it would be:
> 
> diff --git a/src/dhcp.c b/src/dhcp.c
> index c11675d..00145bc 100644
> --- a/src/dhcp.c
> +++ b/src/dhcp.c
> @@ -651,7 +651,7 @@ int address_allocate(struct dhcp_context *context,
>    /* hash hwaddr: use the SDBM hashing algorithm.  Seems to give good
>       dispersal even with similarly-valued "strings". */
>    for (j = 0, i = 0; i < hw_len; i++)
> -    j += hwaddr[i] + (j << 6) + (j << 16) - j;
> +    j = hwaddr[i] + (j << 6) + (j << 16) - j;
> 
>    for (pass = 0; pass <= 1; pass++)
>      for (c = context; c; c = c->current)
> 
> 
> 
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> 




More information about the Dnsmasq-discuss mailing list