Re: ntpd(8) option to provide time even when not being synced
I think the way to go for this is: -fake a sensor inside ntpd -that sensor must be specifically asked for, say, with "sensor local-clock" or the like -make sure ntpd only ever uses that in absence of anything else -- Henning Brauer, h...@bsws.de, henn...@openbsd.org BS Web Services, http://bsws.de, Full-Service ISP Secure Hosting, Mail and DNS Services. Dedicated Servers, Root to Fully Managed Henning Brauer Consulting, http://henningbrauer.com/
Re: ntpd(8) option to provide time even when not being synced
On 2012/09/07 20:16, Mike. wrote: > On 9/7/2012 at 6:35 PM Patrick Wildt wrote: > > |I have machines which might not have an internet connection, but still > |need to > |be synchronized, > |even if the time's not correct. What's important is, that every > machine in > |the > |network has the > |same time. Also the ntp server doesn't have a sensor to synchronize > to. > === > > > > Comments in the context of RFC5905... > > > Instead of sending out stratum 10, it may be better to send out stratum > 16 per the RFC, indicating the clock is unsynchronized. I agree, but there is a client issue with doing this for Patrick's use case. rdate -n clients don't accept time from a stratum 15, and OpenNTPd clients don't accept time from a stratum 16. Apart from being different numbers (which should probably be the same between the two clients), I think this is sane as a default, I don't believe they should accept time from an unsynchronised time server by default. However there are cases where it might be useful to make this configurable. > You are effectively "sync'ing" to the local clock. What will you be > sending out for the reference ID to the clients that sync up to the > server? I would suggest either 127.0.0.1, formatted appropriately, or > you might use the four characters XLCL to indicate you are using the > LoCaL clock. Agreed.
Re: ntpd(8) option to provide time even when not being synced
On 9/7/2012 at 6:35 PM Patrick Wildt wrote: |I have machines which might not have an internet connection, but still |need to |be synchronized, |even if the time's not correct. What's important is, that every machine in |the |network has the |same time. Also the ntp server doesn't have a sensor to synchronize to. === Comments in the context of RFC5905... Instead of sending out stratum 10, it may be better to send out stratum 16 per the RFC, indicating the clock is unsynchronized. You are effectively "sync'ing" to the local clock. What will you be sending out for the reference ID to the clients that sync up to the server? I would suggest either 127.0.0.1, formatted appropriately, or you might use the four characters XLCL to indicate you are using the LoCaL clock.
Re: ntpd(8) option to provide time even when not being synced
I have machines which might not have an internet connection, but still need to be synchronized, even if the time's not correct. What's important is, that every machine in the network has the same time. Also the ntp server doesn't have a sensor to synchronize to. Patrick Am 07.09.2012 um 17:33 schrieb "Eric P. Mangold" : > Could I ask what your use-case is? > > -E > On Fri, Aug 24, 2012 at 01:41:21PM +0200, Patrick Wildt wrote: >> the diff below adds an option to the ntpd(8), which has him provide >> time, even though he's not synced. >> >> ok? >> >> Index: ntpd.8 >> === >> RCS file: /cvs/src/usr.sbin/ntpd/ntpd.8,v >> retrieving revision 1.31 >> diff -u -r1.31 ntpd.8 >> --- ntpd.8 17 Sep 2011 10:22:00 - 1.31 >> +++ ntpd.8 24 Aug 2012 11:17:17 - >> @@ -23,7 +23,7 @@ >> .Sh SYNOPSIS >> .Nm ntpd >> .Bk -words >> -.Op Fl dnSsv >> +.Op Fl dinSsv >> .Op Fl f Ar file >> .Ek >> .Sh DESCRIPTION >> @@ -47,6 +47,9 @@ >> .Nm >> will run in the foreground and log to >> .Em stderr . >> +.It Fl i >> +Provide time, even though the time is >> +not synced. >> .It Fl f Ar file >> Use >> .Ar file >> Index: ntpd.c >> === >> RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v >> retrieving revision 1.69 >> diff -u -r1.69 ntpd.c >> --- ntpd.c 19 Mar 2011 23:40:11 - 1.69 >> +++ ntpd.c 24 Aug 2012 11:17:17 - >> @@ -73,7 +73,7 @@ >> { >> extern char *__progname; >> >> -fprintf(stderr, "usage: %s [-dnSsv] [-f file]\n", __progname); >> +fprintf(stderr, "usage: %s [-dinSsv] [-f file]\n", __progname); >> exit(1); >> } >> >> @@ -97,13 +97,16 @@ >> >> log_init(1);/* log to stderr until daemonized */ >> >> -while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { >> +while ((ch = getopt(argc, argv, "df:insSv")) != -1) { >> switch (ch) { >> case 'd': >> lconf.debug = 1; >> break; >> case 'f': >> conffile = optarg; >> +break; >> +case 'i': >> +lconf.ignore_sync = 1; >> break; >> case 'n': >> lconf.noaction = 1; >> Index: ntpd.h >> === >> RCS file: /cvs/src/usr.sbin/ntpd/ntpd.h,v >> retrieving revision 1.105 >> diff -u -r1.105 ntpd.h >> --- ntpd.h 21 Sep 2011 16:38:05 - 1.105 >> +++ ntpd.h 24 Aug 2012 11:17:17 - >> @@ -180,6 +180,7 @@ >> u_int8_tdebug; >> u_int8_tnoaction; >> u_int8_tfilters; >> +u_int8_tignore_sync; >> }; >> >> enum imsg_type { >> Index: server.c >> === >> RCS file: /cvs/src/usr.sbin/ntpd/server.c,v >> retrieving revision 1.36 >> diff -u -r1.36 server.c >> --- server.c 21 Sep 2011 15:41:30 - 1.36 >> +++ server.c 24 Aug 2012 11:17:17 - >> @@ -188,7 +188,7 @@ >> version = (query.status & VERSIONMASK) >> 3; >> >> bzero(&reply, sizeof(reply)); >> -if (lconf->status.synced) >> +if (lconf->status.synced || lconf->ignore_sync) >> reply.status = lconf->status.leap; >> else >> reply.status = LI_ALARM; >> @@ -200,7 +200,9 @@ >> else /* ignore packets of different type (e.g. bcast) */ >> return (0); >> >> -reply.stratum = lconf->status.stratum; >> +/* set stratum to 10 when we're not synced but still provide time */ >> +reply.stratum = (lconf->status.synced || !lconf->ignore_sync) ? >> +lconf->status.stratum : 10; >> reply.ppoll = query.ppoll; >> reply.precision = lconf->status.precision; >> reply.rectime = d_to_lfp(rectime);
Re: ntpd(8) option to provide time even when not being synced
Could I ask what your use-case is? -E On Fri, Aug 24, 2012 at 01:41:21PM +0200, Patrick Wildt wrote: > the diff below adds an option to the ntpd(8), which has him provide > time, even though he's not synced. > > ok? > > Index: ntpd.8 > === > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.8,v > retrieving revision 1.31 > diff -u -r1.31 ntpd.8 > --- ntpd.817 Sep 2011 10:22:00 - 1.31 > +++ ntpd.824 Aug 2012 11:17:17 - > @@ -23,7 +23,7 @@ > .Sh SYNOPSIS > .Nm ntpd > .Bk -words > -.Op Fl dnSsv > +.Op Fl dinSsv > .Op Fl f Ar file > .Ek > .Sh DESCRIPTION > @@ -47,6 +47,9 @@ > .Nm > will run in the foreground and log to > .Em stderr . > +.It Fl i > +Provide time, even though the time is > +not synced. > .It Fl f Ar file > Use > .Ar file > Index: ntpd.c > === > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v > retrieving revision 1.69 > diff -u -r1.69 ntpd.c > --- ntpd.c19 Mar 2011 23:40:11 - 1.69 > +++ ntpd.c24 Aug 2012 11:17:17 - > @@ -73,7 +73,7 @@ > { > extern char *__progname; > > - fprintf(stderr, "usage: %s [-dnSsv] [-f file]\n", __progname); > + fprintf(stderr, "usage: %s [-dinSsv] [-f file]\n", __progname); > exit(1); > } > > @@ -97,13 +97,16 @@ > > log_init(1);/* log to stderr until daemonized */ > > - while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { > + while ((ch = getopt(argc, argv, "df:insSv")) != -1) { > switch (ch) { > case 'd': > lconf.debug = 1; > break; > case 'f': > conffile = optarg; > + break; > + case 'i': > + lconf.ignore_sync = 1; > break; > case 'n': > lconf.noaction = 1; > Index: ntpd.h > === > RCS file: /cvs/src/usr.sbin/ntpd/ntpd.h,v > retrieving revision 1.105 > diff -u -r1.105 ntpd.h > --- ntpd.h21 Sep 2011 16:38:05 - 1.105 > +++ ntpd.h24 Aug 2012 11:17:17 - > @@ -180,6 +180,7 @@ > u_int8_tdebug; > u_int8_tnoaction; > u_int8_tfilters; > + u_int8_tignore_sync; > }; > > enum imsg_type { > Index: server.c > === > RCS file: /cvs/src/usr.sbin/ntpd/server.c,v > retrieving revision 1.36 > diff -u -r1.36 server.c > --- server.c 21 Sep 2011 15:41:30 - 1.36 > +++ server.c 24 Aug 2012 11:17:17 - > @@ -188,7 +188,7 @@ > version = (query.status & VERSIONMASK) >> 3; > > bzero(&reply, sizeof(reply)); > - if (lconf->status.synced) > + if (lconf->status.synced || lconf->ignore_sync) > reply.status = lconf->status.leap; > else > reply.status = LI_ALARM; > @@ -200,7 +200,9 @@ > else /* ignore packets of different type (e.g. bcast) */ > return (0); > > - reply.stratum = lconf->status.stratum; > + /* set stratum to 10 when we're not synced but still provide time */ > + reply.stratum = (lconf->status.synced || !lconf->ignore_sync) ? > + lconf->status.stratum : 10; > reply.ppoll = query.ppoll; > reply.precision = lconf->status.precision; > reply.rectime = d_to_lfp(rectime);
ntpd(8) option to provide time even when not being synced
the diff below adds an option to the ntpd(8), which has him provide time, even though he's not synced. ok? Index: ntpd.8 === RCS file: /cvs/src/usr.sbin/ntpd/ntpd.8,v retrieving revision 1.31 diff -u -r1.31 ntpd.8 --- ntpd.8 17 Sep 2011 10:22:00 - 1.31 +++ ntpd.8 24 Aug 2012 11:17:17 - @@ -23,7 +23,7 @@ .Sh SYNOPSIS .Nm ntpd .Bk -words -.Op Fl dnSsv +.Op Fl dinSsv .Op Fl f Ar file .Ek .Sh DESCRIPTION @@ -47,6 +47,9 @@ .Nm will run in the foreground and log to .Em stderr . +.It Fl i +Provide time, even though the time is +not synced. .It Fl f Ar file Use .Ar file Index: ntpd.c === RCS file: /cvs/src/usr.sbin/ntpd/ntpd.c,v retrieving revision 1.69 diff -u -r1.69 ntpd.c --- ntpd.c 19 Mar 2011 23:40:11 - 1.69 +++ ntpd.c 24 Aug 2012 11:17:17 - @@ -73,7 +73,7 @@ { extern char *__progname; - fprintf(stderr, "usage: %s [-dnSsv] [-f file]\n", __progname); + fprintf(stderr, "usage: %s [-dinSsv] [-f file]\n", __progname); exit(1); } @@ -97,13 +97,16 @@ log_init(1);/* log to stderr until daemonized */ - while ((ch = getopt(argc, argv, "df:nsSv")) != -1) { + while ((ch = getopt(argc, argv, "df:insSv")) != -1) { switch (ch) { case 'd': lconf.debug = 1; break; case 'f': conffile = optarg; + break; + case 'i': + lconf.ignore_sync = 1; break; case 'n': lconf.noaction = 1; Index: ntpd.h === RCS file: /cvs/src/usr.sbin/ntpd/ntpd.h,v retrieving revision 1.105 diff -u -r1.105 ntpd.h --- ntpd.h 21 Sep 2011 16:38:05 - 1.105 +++ ntpd.h 24 Aug 2012 11:17:17 - @@ -180,6 +180,7 @@ u_int8_tdebug; u_int8_tnoaction; u_int8_tfilters; + u_int8_tignore_sync; }; enum imsg_type { Index: server.c === RCS file: /cvs/src/usr.sbin/ntpd/server.c,v retrieving revision 1.36 diff -u -r1.36 server.c --- server.c21 Sep 2011 15:41:30 - 1.36 +++ server.c24 Aug 2012 11:17:17 - @@ -188,7 +188,7 @@ version = (query.status & VERSIONMASK) >> 3; bzero(&reply, sizeof(reply)); - if (lconf->status.synced) + if (lconf->status.synced || lconf->ignore_sync) reply.status = lconf->status.leap; else reply.status = LI_ALARM; @@ -200,7 +200,9 @@ else /* ignore packets of different type (e.g. bcast) */ return (0); - reply.stratum = lconf->status.stratum; + /* set stratum to 10 when we're not synced but still provide time */ + reply.stratum = (lconf->status.synced || !lconf->ignore_sync) ? + lconf->status.stratum : 10; reply.ppoll = query.ppoll; reply.precision = lconf->status.precision; reply.rectime = d_to_lfp(rectime);