Why does busybox ntpd use /etc/ntp.conf as configuration file?

Hi,

When I invoke busybox ntpd, this is what I got:

                       ntpd: /etc/ntp.conf: No such file or directory

BusyBox v1.23.2 (2018-11-15 09:19:02 MST) multi-call binary.

Usage: ntpd [-dnqNwl -I IFACE] [-S PROG] [-p PEER]...

NTP client/server

    -d      Verbose
    -n      Do not daemonize
    -q      Quit after clock is set
    -N      Run at high priority
    -w      Do not set time (only query peers), implies -n
    -l      Run as server on port 123
    -I IFACE Bind server to IFACE, implies -l
    -S PROG Run PROG after stepping time, stratum change, and every 11 mins
    -p PEER Obtain time from PEER (may be repeated)
            If -p is not given, read /etc/ntp.conf

My understanding is that /etc/config/network/ntpclient is the UCI and busybox NTP configuration file.

I am porting codes from Open Embedded(OE)  Linux to Openwrt UCI environment, I know that
/etc/ntp.conf is being used in OE Linux.

 Thanks for the clarification!

Thanks,
Scott

How did you invoke the busybox version? Did you start it with /etc/init.d/sysntpd start as is how one starts most daemons under OpenWrt?

That appears to be an error message for the full version of ntpd, not the busybox version.

Hi Jeff,

I invoke like this /usr/sbin/ntpd. Also, if I use "ls -l" in /usr/sbin directory. the following display shows that it is linked to busybox. ( Please also see my first post, the ntpd manual display page has "BusyBox v1.23.2 (2018-11-15 09:19:02 MST) multi-call binary." displayed.)

rwxrwxrwx    1 root     root            17 Nov 15 16:20 nbd-client -> ../../bin/busybox
lrwxrwxrwx    1 root     root            15 Nov 15 16:20 nmbd -> samba_multicall
-rwxr-xr-x    1 root     root         18236 Nov 15 00:47 ntpclient
lrwxrwxrwx    1 root     root            17 Nov 15 16:20 ntpd -> ../../bin/busybox
-rwxr-xr-x    1 root     root            74 Nov 15 16:19 ntpd-hotplug
-rwxr-xr-x    1 root     root         35064 Nov 15 16:12 odhcp6c
-rwxr-xr-x    1 root     root         53452 Nov 15

Thanks,
Scott

That looks like the busybox version

jeff@office:~$ sudo find / -name ntpd -ls
      903      2 -rwxr-xr-x   1  root     root         1932 Nov 25 11:22 /etc/init.d/ntpd
      903      2 -rwxr-xr-x   1  root     root         1932 Nov 25 11:22 /overlay/upper/etc/init.d/ntpd
      909      0 c---------   1  root     root       0,   0 Dec 12 18:34 /overlay/upper/usr/sbin/ntpd
      905    491 -rwxr-xr-x   1  root     root       502408 Nov 25 11:22 /overlay/upper/sbin/ntpd
      255      0 lrwxrwxrwx   1  root     root           17 Sep  2 11:58 /rom/usr/sbin/ntpd -> ../../bin/busybox
      905    491 -rwxr-xr-x   1  root     root       502408 Nov 25 11:22 /sbin/ntpd

For the "real" ntpd:

jeff@office:~$ which ntpd
/sbin/ntpd
jeff@office:~$ ls -l /sbin/ntpd
-rwxr-xr-x    1 root     root        502408 Nov 25 11:22 /sbin/ntpd
jeff@office:~$ ntpd --version
ntpd 4.2.8p12@1.3728-o Mon Nov 26 12:02:01 UTC 2018 (1)

and its current state, using "pool" servers

jeff@office:~$ ntpq
ntpq> pe
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
+lithium.constan 216.218.254.202  2 u  658 1024  377   75.592    0.824   0.372
*192.138.210.214 129.7.1.66       2 u  153 1024  377   47.845   -0.330   2.173
-69.195.159.158  128.138.140.44   2 u  786 1024  175   57.238   -3.956   1.207
+tick.no-such-ag 162.213.2.253    2 u  409 1024  163   12.157    0.315   0.671
ntpq> rv
associd=0 status=0615 leap_none, sync_ntp, 1 event, clock_sync,
version="ntpd 4.2.8p12@1.3728-o Mon Nov 26 12:02:01 UTC 2018 (1)",
processor="mips", system="Linux/4.14.67", leap=00, stratum=3,
precision=-18, rootdelay=57.611, rootdisp=18.996, refid=192.138.210.214,
reftime=dfd8f879.8d8951ab  Thu, Jan  3 2019 13:09:13.552,
clock=dfd8f924.27eea8ad  Thu, Jan  3 2019 13:12:04.155, peer=61113,
tc=10, mintc=3, offset=0.118202, frequency=8.445, sys_jitter=0.761437,
clk_jitter=1.425, clk_wander=0.071

showing synchronization to 0.120 ms, but revealing how relatively poor the Archer C7's timekeeping ability is, with a jitter of ~1.5 ms. Not that within 2 ms is really all that bad, but another of my machines running on a Celeron J1900 has its jitter and wander below 0.050 ms.

Hi Jeff,

When you say "real" ntpd, do you mean "real OPENWRT ntpd" or other Linux system's ntpd?

My major concern are:

1.) Is the one that I used and mentioned in the first post is the OPENWRT real ntpd?
2.) If it is not ,why my group people ported the code from OPENWRT has "BusyBox v1.23.2 (2018-11-15 09:19:02 MST) multi-call binary." displayed" ( By the way, is OPENWRT going to fix this soon if it
is a bug so that I can use this fixed one.)
3.) How can I install the "real OPENWRT ntpd"?
4.) Is there a way ( such as option ) that I can specify the real OPENWRT ntp configuration file /etc/config/network/ntpclient in command line?

I need to finish my assigned work ( job ) so that the answers for above questions are very important to
me.

Thanks,
Scott

When I say "real" NTP, I'm referring to the reference NTPv4 implementation. It is available as a package and can be compiled and built into an image, or installed with opkg post-facto.

OpenWrt, being targeted at devices with limited resources, supplies default NTP functionality through a busybox applet. The full NTP implementation is quite large, and provides functionality that far exceeds the needs of the majority of OpenWrt users. The busybox applet sets the clock sufficiently well for most users, and can serve NTP protocol to clients on their network.

To use real NTP, you'll not only need to install it, but also disable the busybox applet service and enable the ntpd service. It can also be built into a ROM.

I'm not sure what you consider a "bug" with the behavior you're seeing. OpenWrt, as shipped, runs the busybox applet. If you install the NTP package, disable the busybox-based service from starting, and enable the NTP package's service, it works.

I’ve the impression that you’re missing each other’s points here.

The busybox ntpd or the full ntpd aren’t using /etc/config/ files directly, but these files are translated by the corresponding /etc/init.d/ scripts into either ephemeral native config within /var/etc or a series of command line switches.

The /etc/config/ntpclient file specifically belongs to neither busybox ntpd nor to the standalone ntpd but to the ntpclient package and is processed by ntpclients hotplug script (https://github.com/openwrt/packages/blob/openwrt-18.06/net/ntpclient/files/ntpclient.hotplug)

OpenWrts builtin busybox ntpd is configured within /etc/config/system which is translated to a series of ntpd command line arguments for ntpd by /etc/init.d/sysntpd.

3 Likes

Jow,

Thanks to you and Jeff! It is clear now.

In our system, the ntpclient.hotplug is called 20-ntpclient and located under /etc/hotplug.d/iface directory with permission "-rw-r--r--", which probably "x" permission should be added or the "x" will be added by invoking script/process.

I have the following questions:

1.) Because it is interface up/down event driven, which event dispacher wil call hotplug.ntpclient.
Do you have the event dispatch code because I need to invoke this script in my code, but the current code does not distinguish between interface up and down ( i.e. both up/down will be invoked my inhereted code the same way .)

2.) In the script code:

config_load ntpclient
config_foreach load_settings ntpclient

I believe that the ntpclient means /etc/config/ntpclient configuration file.

Can you show me other related scripts about this part?

Thanks,
Scott

I have already had answer by myself. Also, if I use ntpclient.hotplug, there is #!/bin/sh on the top,
there is no need to chmod +x.