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

Jacob Siverskog jacob at teenage.engineering
Mon Jun 29 14:00:35 BST 2015


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20150629/b08af390/attachment.html>


More information about the Dnsmasq-discuss mailing list