ntp.conf new refclock configuration syntax
Eric S. Raymond
esr at thyrsus.com
Sat Nov 26 21:54:30 UTC 2016
Achim Gratz <Stromeko at nexgo.de>:
>
> I've switched to the new refclock configuration syntax, but it seems
> there is either a bug somewhere in the implementation or some mismatch
> to the documentation.
>
> I was trying to set up my NavSpark GPS to use $GPZDA and 115200 baud
> like this:
>
> refclock nmea unit 1 refid NavS mode 8 baud 115200 flag1 1
>
> but that actually configured the serial for 0 baud and the GPS stopped
> sending data. Manually setting it back to the correct baud rate with
> stty recovered operation. Since the old syntax still seemed to work
> correctly I've tried to pull the baud configuration into the mode
> parameter again and that actually worked:
>
> refclock nmea unit 1 refid NavS mode 88 flag1 1
I tried reproducing your bug under gdb by adding the NavSpark config
line as my only clock. Here's what I got:
root at snark:/home/esr/software/ntp-rescue/ntpsec# gdb build/main/ntpd/ntpd
[boilerplate skipped]
Reading symbols from build/main/ntpd/ntpd...done.
(gdb) break nmea_start
Breakpoint 1 at 0x45ca50: file ../../ntpd/refclock_nmea.c, line 396.
(gdb) r -g -n
Starting program: /home/esr/software/ntp-rescue/ntpsec/build/main/ntpd/ntpd -g -n
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
11-26T16:22:10 ntpd[10502]: ntpd 0.9.6-9d95f6e Nov 26 2016 16:19:43: Starting
11-26T16:22:10 ntpd[10502]: Command line: /home/esr/software/ntp-rescue/ntpsec/build/main/ntpd/ntpd -g -n
11-26T16:22:10 ntpd[10502]: proto: precision = 0.838 usec (-20)
11-26T16:22:10 ntpd[10502]: successfully locked into RAM
11-26T16:22:10 ntpd[10502]: authreadkeys: reading /usr/local/etc/ntp.keys
11-26T16:22:10 ntpd[10502]: authreadkeys: added 10 keys
11-26T16:22:10 ntpd[10502]: restrict 0.0.0.0: notrap keyword is ignored.
11-26T16:22:10 ntpd[10502]: restrict ::: notrap keyword is ignored.
11-26T16:22:10 ntpd[10502]: Listen and drop on 0 v6wildcard [::]:123
11-26T16:22:10 ntpd[10502]: Listen and drop on 1 v4wildcard 0.0.0.0:123
11-26T16:22:10 ntpd[10502]: Listen normally on 2 lo 127.0.0.1:123
11-26T16:22:10 ntpd[10502]: Listen normally on 3 enp14s0 192.168.1.22:123
11-26T16:22:10 ntpd[10502]: Listen normally on 4 lo [::1]:123
11-26T16:22:10 ntpd[10502]: Listen normally on 5 enp14s0 [2001:470:e34c:2:56a0:50ff:febb:62d0]:123
11-26T16:22:10 ntpd[10502]: Listen normally on 6 enp14s0 [fe80::56a0:50ff:febb:62d0%2]:123
11-26T16:22:10 ntpd[10502]: Listening on routing socket on fd #23 for interface updates
Breakpoint 1, nmea_start (unit=1, peer=0x6b2d00 <init_peer_alloc>)
at ../../ntpd/refclock_nmea.c:396
396 {
(gdb) n
397 struct refclockproc * const pp = peer->procptr;
(gdb) n
398 nmea_unit * const up = emalloc_zero(sizeof(*up));
(gdb) n
406 rate = (peer->ttl & NMEA_BAUDRATE_MASK) >> NMEA_BAUDRATE_SHIFT;
(gdb) n
409 if (peer->baud)
(gdb) p rate
$1 = 0
(gdb) p peer->baud
$2 = 115200
(gdb) p peer->ttl
$3 = 8
(gdb) n
410 rate = peer->baud;
(gdb) n
412 switch (rate) {
(gdb) n
443 baudrate = B115200;
(gdb) n
444 baudtext = "115200";
(gdb) n
It looks like the baud rate and mode bits (which go into the otherwise unused
ttl field, yes, I know that's ugly) are being passed in correctly and not
stepping on each other. Then I see the baud rate being set correctly.
I would expect pulling the baud rate into the mode field to work, because
here's the logic:
/* Old style: get baudrate choice from mode byte bits 4/5/6 */
rate = (peer->ttl & NMEA_BAUDRATE_MASK) >> NMEA_BAUDRATE_SHIFT;
/* New style: get baudrate from baud option */
if (peer->baud)
rate = peer->baud;
Then the following switch is set up to accept either small-integer values
or larger ones in the range 300..115200 and do the right thing. What's
mysterious is how you are coming out of that logic with speed set to zero.
Please try configuring with
./waf configure --enable-crypto --refclock=all --enable-debug-gdb
and tracing through this yourself.
> The documentation example at the end of the page also looks wrong:
>
> refclock nmea mode baud 19200 # All sentences from /dev/gps0 at 19200 baud
>
> It looks like the mode parameter is missing here (it might actually
> interpret a missing mode as zero, but that should be commented). It
> would also be good to show the unit syntax in one of the examples for
> each refclock I'd think.
You're right. I typoed that. I'll fix it.
> It would be a good thing if there was a way to read in any old
> configuration file and spit it out again in the new syntax. Any default
> values should be present as a comment so it's easy to find out what else
> might need changing.
That is probably doable. Not in ntpd itsef, I don't want to add the
weight there, but I will poke at a conversion script.
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
More information about the devel
mailing list