Modify

Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#10310 closed defect (fixed)

Problems with busybox built-in ntpd

Reported by: ferob Owned by: developers
Priority: normal Milestone: Barrier Breaker 14.07
Component: base system Version: Trunk
Keywords: busybox built-in ntpd time Cc:

Description

Since r28612 and r28613, there are some problems, because AICCU needs the correct time to use the IPv6 tunnel.

The built-in ntpd only changes the time after the router is up and everything is running.

But every time the router is restarted or turned on, this happens:

Oct 29 14:41:23 Netgear local7.err syslog: The clock is off by 147 seconds, use NTP to sync it!
Oct 29 14:41:23 Netgear local7.err syslog: Couldn't retrieve first tunnel for the above reason, aborting

...

Oct 29 14:42:59 Netgear daemon.info pppd[654]: System time change detected.

Then I need to manually restart AICCU, to use the tunnel.

Attachments (0)

Change History (18)

comment:1 follow-up: Changed 6 years ago by hnyman <hannu.nyman@…>

Aiccu's startup position is 51: https://dev.openwrt.org/browser/packages/ipv6/aiccu/files/aiccu.init#L3

Perhaps it could be made to start later.

You might try change that '51' on line 3 to '99', which would be after sysntpd's value '98'. I guess that the sysntpd is the built-in ntpd daemon. If aiccu starts after that, it should probably be ok.

sysntpd could also be made to start earlier by changing its value from 98 to something smaller, like 48 (after firewall) or 61 (after dnsmasq).

You might test on a live system to see, which works. The files are:
/etc/init.d/aiccu
/etc/init.d/sysntpd

comment:2 in reply to: ↑ 1 Changed 6 years ago by ferob

I tried to change sysntpd to 48 and aiccu to 99 at the same time, but aiccu still starts before the time changes.
And this is because aiccu needs to be restarted with the hotplug script if the wan goes up.

comment:3 Changed 6 years ago by arokh <trondah@…>

ntpd should be started by a hotplug script when interface wan comes up, before aiccu. Doesn't really make sense to use an init script when you don't know if wan is up yet.

comment:4 Changed 6 years ago by jow

It makes no sense to rely on an arbritary "wan" interface. Ntpd will retry to sync until it has connectivity, and I don't see why we should bend the whole system to accomodate for AICCU's broken implementation of weird ideas.

comment:5 Changed 6 years ago by arokh <trondah@…>

Well, either that or the aiccu hotplug handler needs to be modified to not start aiccu if ntpd isn't running. That way aiccu will be started by the init script after time is synced.

comment:6 Changed 6 years ago by hnyman

The ntpd starts now so late with 98, practically as the last task, that at least in my WNDR3700 the whole system log from startup has wrong time up to the last line. Generating something else to the log after the boot is the only way to see from system log entries that the time has been corrected by ntpd.

It would be better to have ntpd to start a bit earlier so that the last entries in the system log would reflect the current time at the end of the boot process.

Btw, I checked Aiccu source code and it seems to only allow 120 sec time difference at startup for some reason. I didn't find out any reason for that limitation in the source code, but I didn't go very deep into the protocol stuff there.

(I considered creating a delayed start functionality for aiccu initscript, monitoring the existence of ntpd or ntpclient process upto and waiting max. X seconds if needed, and then trying to start aiccu in any case. I got the functionality to work when manually run, but it didn't work when ran automatically at startup. Needs more work.)

comment:7 Changed 6 years ago by jow

Aiccu should be just patched to shut up and wait / retry / idle until it can do whatever it needs to do, the amount of scripting, workarounds and delay loops needed to make it autostart is ridiculous.

comment:8 Changed 6 years ago by jow

Regarding the ntpd init prio, network setup and init happen asynchronously, on fast platforms network is finished first, on slow platforms init wins. Fiddling with START=xx rarely leads to any satisfactory results when networking is involved.

comment:9 follow-up: Changed 6 years ago by arokh <trondah@…>

I disabled the sysntpd init script and added /etc/hotplug.d/iface/20-ntpd:

[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && [ -z "`pidof ntpd`" ] && /etc/init.d/sysntpd start

Did the same for aiccu (it already has a hotplug handler to start on wan up), maybe not the best way but works fine.

comment:10 Changed 6 years ago by jow

Works fine if the default gateway interface happens to be called wan.

comment:11 Changed 6 years ago by jow

Also there is no need to delay the start of ntpd until "wan" is up, if you choose to do this run "nptd -q" which is the equivalent to "ntpdate" so useful for one-shot time syncing.

comment:12 Changed 6 years ago by arokh <trondah@…>

Isn't the default gateway interface always called wan? If a one-shot time sync is sufficient, why is it run as a daemon by default? Would be useful to have an uci option to control use of -l switch so local machines can sync to it also.

comment:13 in reply to: ↑ 9 Changed 6 years ago by ferob

arokh I tried the suggested modifications, but it still not good if I turn off the router for a while.

Nov  5 16:11:06 Netgear local7.err syslog: The clock is off by 304 seconds, use NTP to sync it!
Nov  5 16:11:06 Netgear local7.err syslog: Couldn't retrieve first tunnel for the above reason, aborting

...

Nov  5 16:16:19 Netgear daemon.info pppd[654]: System time change detected.

comment:14 Changed 6 years ago by arokh <trondah@…>

I tried turning off the router and reproduced it here ferob. The issue seems to be that busybox ntpd uses too long time to sync when in daemon mode. I changed my ntpd hotplug script to do a one-time sync and then quit.

/etc/hotplug.d/iface/20-ntpd:

[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && /usr/sbin/ntpd -n -q -p 0.openwrt.pool.ntp.org

Seems to work great. Time is synced right away when interface comes up and aiccu starts normally.

comment:15 Changed 6 years ago by jow

I added some fixes which might resolve the issue.

  • Lazily resolve DNS in ntpd, previously it refused to start if DNS was not available at init time, see r28794
  • Retry to log into TIC server on nonfatal errors, previously aiccu tried to login only once then gave up, see r28796 and r28797

I would appreciate some feedback on those. For me they work fine if boot the box and attach the wan cable only later.

comment:16 Changed 6 years ago by duvi

For me aiccu is OK now, it created the tunnel successfully after time was synced.

Jan  1 01:00:33 OpenWrt local7.err syslog: The clock is off by 1320653364 seconds, use NTP to sync it!
Jan  1 01:00:33 OpenWrt local7.err syslog: Retrying TIC login in 10 seconds...
...
Jan  1 01:00:44 OpenWrt local7.err syslog: The clock is off by 1320653363 seconds, use NTP to sync it!
Jan  1 01:00:44 OpenWrt local7.err syslog: Retrying TIC login in 20 seconds...
...
Nov  7 09:10:09 OpenWrt daemon.info pppd[744]: System time change detected.
...
Nov  7 09:10:28 OpenWrt local7.info syslog: Succesfully retrieved tunnel information for Txxxxx
Nov  7 09:10:28 OpenWrt local7.info syslog: AICCU running as PID 1692

comment:17 Changed 6 years ago by jow

  • Resolution set to fixed
  • Status changed from new to closed

I assume it is fixed by now.

comment:18 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.