From owner-freebsd-hackers@FreeBSD.ORG Mon Apr 27 15:11:20 2015 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6207B2EE for ; Mon, 27 Apr 2015 15:11:20 +0000 (UTC) Received: from mail-in-08.arcor-online.net (mail-in-08.arcor-online.net [151.189.21.48]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "mx.arcor.de", Issuer "Thawte SSL CA" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 1991B110D for ; Mon, 27 Apr 2015 15:11:19 +0000 (UTC) Received: from mail-in-02-z2.arcor-online.net (mail-in-02-z2.arcor-online.net [151.189.8.14]) by mx.arcor.de (Postfix) with ESMTP id 3lb7zN20hQzY4Zr for ; Mon, 27 Apr 2015 16:39:28 +0200 (CEST) Received: from mail-in-06.arcor-online.net (mail-in-06.arcor-online.net [151.189.21.46]) by mail-in-02-z2.arcor-online.net (Postfix) with ESMTP id 37677718E7B for ; Mon, 27 Apr 2015 16:39:28 +0200 (CEST) X-Greylist: Passed host: 188.104.143.26 X-DKIM: Sendmail DKIM Filter v2.8.2 mail-in-06.arcor-online.net 3lb7zN0Vflz8Fc9 Received: from lorvorc.mips.inka.de (dslb-188-104-143-026.188.104.pools.vodafone-ip.de [188.104.143.26]) by mail-in-06.arcor-online.net (Postfix) with ESMTPS id 3lb7zN0Vflz8Fc9 for ; Mon, 27 Apr 2015 16:39:27 +0200 (CEST) Received: from lorvorc.mips.inka.de (localhost [127.0.0.1]) by lorvorc.mips.inka.de (8.14.9/8.14.9) with ESMTP id t3REdRXt001390 for ; Mon, 27 Apr 2015 16:39:27 +0200 (CEST) (envelope-from news@lorvorc.mips.inka.de) Received: (from news@localhost) by lorvorc.mips.inka.de (8.14.9/8.14.9/Submit) id t3REdRca001389 for freebsd-hackers@freebsd.org; Mon, 27 Apr 2015 16:39:27 +0200 (CEST) (envelope-from news) To: freebsd-hackers@freebsd.org From: Christian Weisgerber Newsgroups: list.freebsd.hackers Subject: System clock always unsynced Date: Mon, 27 Apr 2015 14:39:27 +0000 (UTC) Lines: 32 Message-ID: X-Trace: lorvorc.mips.inka.de 1430145567 276 ::1 (27 Apr 2015 14:39:27 GMT) X-Complaints-To: usenet@mips.inka.de User-Agent: slrn/1.0.2 (FreeBSD) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2015 15:11:20 -0000 I run OpenNTPD, from ports/net/openntpd, and I've noticed that after each reboot, the initial system time is further off. (This is quite noticeable with OpenNTPD, since by default it does *not* jump the clock on startup like the base ntpd does.) It's as if the RTC was never synchronized to the system clock. Some digging in sys/kern/kern_ntptime.c shows indeed that the RTC is only synced if STA_UNSYNC is not set, and dumping the value of the timex struct... offset: 0 freq: 2730304 maxerror: 84860000 esterror: 500000 status: UNSYNC constant: 0 precision: 0 tolerance: 32500000 state: ERROR ... reveals that the clock remains permanently unsynced. Clearly, OpenNTPD, which uses adjtime(2) to correct offsets and ntp_adjtime(2) with MOD_FREQUENCY to correct the frequency, doesn't handle this quite right. What *does* an ntpd daemon need to do to sync the clock? The ntp_adjtime(2) man page documents struct timex in detail, but is very vague on what all of this means. -- Christian "naddy" Weisgerber naddy@mips.inka.de