[Dnsmasq-discuss] Patch: Add --ping-timeout option

Simon Kelley simon at thekelleys.org.uk
Thu May 17 12:01:47 BST 2012


On 14/05/12 19:04, aopfer at bennett-electric.com wrote:
> Hello,
> 
> This is a patch I wrote for dnsmasq to allow changing the timeout on the
> ping
> request sent to an IP address to determine whether the address is free
> to give
> out to a DHCPv4 client. The default value according to the manpage was
> 1.5
> seconds and not changeable. This option lets you set the timeout to a
> number of
> milliseconds.
> 
> I noticed that I had to multiply the given timeout by 2 in order for it
> to wait
> the correct amount of time. This is reflected in the PING_WAIT constant
> as
> well, which was set to 3 in order to wait 1.5 seconds. While I believe
> my patch
> is performing correct behavior, I'd appreciate some explanation as to
> why this
> is necessary.

Where in the man page does it say that the default wait is 1.5 seconds?
 I can't find that. The code which does the waiting is rather
susceptible to rounding errors: by staring at it I think it will wait
somewhere between 2 and 3.25 seconds for the default value, but I've not
done a live test to verify that.

> 
> I've placed a maxmimum limit of 15 seconds on the timeout. This is
> because it
> appears that PING_CACHE_TIME must be greater than the timeout. See the
> patch
> made in dhcp.c for the area where this issue is of concern. 
> 
> I have attached the output of `git diff` to this email as a patch. If
> this is
> not the correct format, please let me know.
> 

Under what circumstances is increasing this time useful? Making it
longer has definite downsides, since whilst dnsmasq is waiting for a
ping reply, it doesn't handle other DHCP requests. If it's too long this
risks other clients timing out. Certainly allowing people the ability to
tweak this knob risks that they'll inadvertently break things. At the
very least PING_CACHE_TIME needs to be increased in proportion with
PING_WAIT


Cheers,

Simon.





More information about the Dnsmasq-discuss mailing list