[Dnsmasq-discuss] Hang when system time is changed backwards

Simon Kelley simon at thekelleys.org.uk
Sun Jul 5 22:39:04 BST 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Using monotonic time seems to be a bit of a portability nightmare, as
an alternative, I've added code to count the number of zero returns
from select(). The standard wait is three seconds, so once select()
has returned zero 12 times, the loop ends even if the result of
gettimeofday() doesn't end it. Unless the net is unfeasibly busy
(ending every select call with a received packet) then  that should
put a sensible limit of the waiting time.

Code in the git repo now, if you could test it.


Cheers,

Simon.

On 29/06/15 14:00, Jacob Siverskog wrote:
> Hi! It seems like dnsmasq may occasionally hang (=become
> unresponsive, unkillable with "killall dnsmasq" (-9 works), doesn't
> seem to answer on DHCP requests etc) if the system time is changed
> backwards.
> 
> I ran strace on dnsmasq once when this happened: root at OD-11:~#
> strace -p 1645 -f -tt -s 1024 Process 1645 attached 12:12:08.502148
> select(18, [6 7 8 9 10 11 15 16 17], [], NULL, {0, 46327}) = 0
> (Timeout) 12:12:08.552953 gettimeofday({1435572728, 553933}, NULL)
> = 0 12:12:08.555642 select(18, [6 7 8 9 10 11 15 16 17], [], NULL,
> {0, 250000}) = 0 (Timeout) 12:12:08.808748
> gettimeofday({1435572728, 809379}, NULL) = 0 12:12:08.810668
> select(18, [6 7 8 9 10 11 15 16 17], [], NULL, {0, 250000}) = 0
> (Timeout) 12:12:09.063807 gettimeofday({1435572729, 65256}, NULL) =
> 0 12:12:09.066343 select(18, [6 7 8 9 10 11 15 16 17], [], NULL,
> {0, 250000}) = 0 (Timeout) 12:12:09.319034
> gettimeofday({1435572729, 320590}, NULL) = 0 12:12:09.321021
> select(18, [6 7 8 9 10 11 15 16 17], [], NULL, {0, 250000}) = 0
> (Timeout)
> 
> I grep:ed for select:s in the source code and my guess is that it's
> the icmp_ping() select loop in dnsmasq.c that gets confused.
> Perhaps monotonic time should be used in this for loop: for (now =
> start = dnsmasq_time(); difftime(now, start) < (float)PING_WAIT;)
> 
> I manually set the time forward a few hours and dnsmasq released 
> immediately: root at SYSTEM:~# date -s "2015-06-29 14:14:56" Mon Jun
> 29 14:14:56 CEST 2015 root at SYSTEM:~# Mon Jun 29 14:14:56 2015
> daemon.info dnsmasq-dhcp[1645]: DHCPDISCOVER(wlan0-work)
> 8a:33:14:0f:3b:d8 Mon Jun 29 14:14:56 2015 daemon.info
> dnsmasq-dhcp[1645]: DHCPOFFER(wlan0-work) 192.168.7.146
> 8a:33:14:0f:3b:d8
> 
> I'm using dnsmasq 2.72.
> 
> Thanks, Jacob
> 
> 
> 
> _______________________________________________ Dnsmasq-discuss
> mailing list Dnsmasq-discuss at lists.thekelleys.org.uk 
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss
> 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBCAAGBQJVmaP4AAoJEBXN2mrhkTWiFVMP/2XP3OTf+f2PEKnb45Ttt8vH
FKULZKfoB6vzM9fhK1Y3FzeTrlfHdrtOpd2jazYF5QUOZbG7uywopHIPTQNJ77FV
TKqjU5a75naZF+UMz3DrkOyWc4hs6TXVs0E5WGDy8ZHN6NrgSij8JvBYm2pTIUwu
1vLD95xcCZgnROgKd6eo7SDARlYZ/k6gw51M/KE6kql0cE7oM1gtFDJ1JCOR0lf/
SIxO+fFfYkCrYfQQfvo0aKiBsnfa0EMeuTOFlDOyeiPYnW2+wdq3iv5L8ClsnX90
FXJTk1czJ7QKhpTPxKltkEtU/Uz9iQ7A8roA7Ex1ngjIHQ96XxR0f4RLbEyisJpt
s9aAjzqmdFP5Rpv8nH9cQsO870qq09OxfdGLNwGhMknCdVVl1+TNy4b6KrvdM5qZ
9CEQUeLi4yuXX9u/s46tBHTThMsYslGU+lImBx2IqBEz3wfxCchAkfzyLkugrWg2
YqB5/AEOLNI+jwvQvaH2O2LBEEszbJ2GELWKQY15xh+Ijt4HLyGxzlshkl2D4hSx
hctZ1K7Q/G9PD+zd5+wpCoyivct9NWCQn95AFbSWLfqCCN6ZhppSavWMiwk8vstw
dfa3EOVEyyR0BroeKEDfWZXa7p3OcqOULi3bEAdLG/uECPeiuMH8js19P73u+rAa
ODmCRJrDNbZk8KVHHtYr
=83S5
-----END PGP SIGNATURE-----



More information about the Dnsmasq-discuss mailing list