openntpd: clock adjustment fails when ntp servers are not available at boot
|Reported by:||ben-keyword-openwrt.85f0dd@…||Owned by:||developers|
When ntpd is kicked off from the /etc/init.d/S55ntpd script, it's run with the -s option to immediately set the time, which is good.
However, if no NTP servers are available when ntpd is started (e.g. just booted and the Internet link is not yet up), ntpd will not be able to set the time; when the ntp servers do become available ntpd will try to use the kernel adjtime call to slew the clock into line, this is impractical (it would take forever to catch up from the boot-time of 2000-01-01), and doesn't work: adjtime doesn't allow such large adjustments (e.g. /usr/sbin/ntpd: adjusting local clock by 215648283.905616s followed by adjtime failed: Invalid argument).
The simple (only?) solution is to kick ntp whenever the network state changes
# cat /etc/hotplug.d/iface/55-ntpd #!/bin/sh # hopefully some ntp servers are reachable now... killall ntpd /etc/init.d/S55ntpd start