Date: Tue, 28 Apr 2015 09:34:12 -0600 From: Ian Lepore <ian@freebsd.org> To: Christian Weisgerber <naddy@mips.inka.de> Cc: freebsd-hackers@freebsd.org Subject: Re: System clock always unsynced Message-ID: <1430235252.1157.37.camel@freebsd.org> In-Reply-To: <20150428115741.GA68174@lorvorc.mips.inka.de> References: <slrnmjsigv.8j.naddy@lorvorc.mips.inka.de> <slrnmjsp0a.17je.naddy@lorvorc.mips.inka.de> <1430177037.1157.23.camel@freebsd.org> <20150428115741.GA68174@lorvorc.mips.inka.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2015-04-28 at 13:57 +0200, Christian Weisgerber wrote: > Ian Lepore: > > > > Okay, let me rephrase this since the first two replies completely > > > missed the point. This is an API programming question. How is the > > > poorly documented ntp_adjtime() API to be used so the system clock > > > will lose the STA_UNSYNC status and switch from TIME_ERROR to TIME_OK > > > as clock state? > > > > It requires a call to ntp_adjtime() with the MOD_STATUS bit set in > > ntv.modes and the STA_UNSYNC bit clear in ntv.status. > > Well, yes. You omitted the crucial piece of information, but I > think I have figured it out from reading kern_ntptime.c: The > STA_UNSYNC value is _read_ by the kernel and (mostly) _set_ by > userland. It is ntpd that is supposed to clear STA_UNSYNC to signal > the kernel that the time is synchronized. > > The ntp_adjtime(2) man page doesn't say anything how STA_UNSYNC is > used and I had naturally assumed that it was the kernel that cleared > STA_UNSYNC to let ntpd know (that the offsets had been applied or > whatever). > I'm not sure why you "naturally" assumed it was the kernel's responsibility to clear that bit when all the kernel is doing is following ntpd's instructions on how to steer the clock. It's ntpd (or some other external entity) that knows the relationship between current system time and some other authorative source of time. The missing documentation you're looking for is probably RFC 1589. The ntp_adjtime manpage probably should mention it. -- Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1430235252.1157.37.camel>