Wrong clock type reported for NTP sources

With an NTP source as the system peer, the system status reported by ntpq has a clock type of 0 (unspecified) instead of 6 (NTP).

$ ntpq -c rv
associd=0 status=0015 leap_none, sync_unspec, 1 event, clock_sync,
leap=00, stratum=4, precision=-24, rootdelay=22.6, rootdisp=940.045, refid=162.159.200.123,
...

There should be sync_ntp instead of sync_unspec.

It seems there is nothing in the code setting the sstclktype for NTP sources. The following change works for me:

--- a/ntpd/ntp_peer.c
+++ b/ntpd/ntp_peer.c
@@ -629,6 +629,10 @@ newpeer(
        /* reset NTS */
        peer->nts_state.count = -1;
 
+#ifdef REFCLOCK
+       peer->sstclktype = CTL_SST_TS_NTP;
+#endif
+
        peer->cast_flags = cast_flags;
        set_peerdstadr(peer,
                       select_peerinterface(peer, srcadr, dstadr));

but I suspect it might need to be reset in refclock_newpeer() back to 0 for drivers that don't set their own value.

Assignee Loading
Time tracking Loading