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 -0000      1.31
> +++ ntpd.8    24 Aug 2012 11:17:17 -0000
> @@ -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 -0000      1.69
> +++ ntpd.c    24 Aug 2012 11:17:17 -0000
> @@ -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 -0000      1.105
> +++ ntpd.h    24 Aug 2012 11:17:17 -0000
> @@ -180,6 +180,7 @@
>       u_int8_t                                        debug;
>       u_int8_t                                        noaction;
>       u_int8_t                                        filters;
> +     u_int8_t                                        ignore_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 -0000      1.36
> +++ server.c  24 Aug 2012 11:17:17 -0000
> @@ -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);

Reply via email to