Re: [chrony-dev] Running chronyd without syncing system clock

[ Thread Index | Date Index | More chrony.tuxfamily.org/chrony-dev Archives ]


Op 24/02/2012 om 11:43:01 +0100, schreef Miroslav Lichvar:
> On Fri, Feb 24, 2012 at 11:02:55AM +0100, Leo Baltus wrote:
> > I am not saying that multiple processes should serve a single clock.
> > 
> > Let me try some good old ascii art:
> > 
> >         uplink                   local nets
> >    pool  ---   ntp-only-server1     ---     ntp-client
> >                ntp-only-server2     ---     ntp-client
> >                ntp-only-server3     ---     ntp-client
> >                                     ---     ntp-client
> >    
> > The pool is a set of ntp-servers outside my network. Inside my network I
> > have 4 servers (hardware) each running an ntp-client synchronizing to 3
> > ntp-only-servers (chronyd instances). The ntp-only servers run on the
> > same hardware as the ntp-clients but do not sync the system clock. Each
> > ntp-only server has its own ip address unrelated to the server's ip
> > address. Some hardware is running ntp-clients only. The ntp-clients do
> > sync the system clock. Some ntp clients may even be outside my networks.
> 
> Ok, there are two chronyd instances running on one real hw machine,
> one polls remote NTP servers, but doesn't set the clock. The other
> instance polls the first chronyd and sets the local clock. Is that
> correct?
> 

All ntp-clients share the same configuration:

server ntp-only-server1
server ntp-only-server2
server ntp-only-server3

> I think that will create a positive feedback loop and will not work
> well, if at all. The instance which sets the clock needs to compare
> its clock against a stable clock, not something which includes its
> own clock.

Wouldn't the one running on its own clock mark it as 'bad' in
comparison with the others?

> It could work the other way around, the client polling remote
> servers and the server polling the client, but that's probably not
> what you want.
> 

Right.

> > In the mean time I have prepared a patch to see if i can get this
> > working. Any thoughts about testing scenarios?
> 
> I'm interested to see what the patch does.
> 

---
 conf.c      |   21 +++++++++++++++++++++
 conf.h      |    1 +
 reference.c |   14 +++++++++-----
 3 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/conf.c b/conf.c
index bbd890c..7da1123 100644
--- a/conf.c
+++ b/conf.c
@@ -94,6 +94,7 @@ static void parse_cmddeny(const char *);
 static void parse_cmdport(const char *);
 static void parse_rtconutc(const char *);
 static void parse_rtcsync(const char *);
+static void parse_nolclsync(const char *);
 static void parse_noclientlog(const char *);
 static void parse_clientloglimit(const char *);
 static void parse_fallbackdrift(const char *);
@@ -165,6 +166,9 @@ static int rtc_on_utc = 0;
 /* Flag set if the RTC should be automatically synchronised by kernel */
 static int rtc_sync = 0;
 
+/* Flag set if the local system clock should be synchronised by chrony */
+static int lcl_sync = 1;
+
 /* Limit and threshold for clock stepping */
 static int make_step_limit = 0;
 static double make_step_threshold = 0.0;
@@ -260,6 +264,7 @@ static const Command commands[] = {
   {"cmdport", 7, parse_cmdport},
   {"rtconutc", 8, parse_rtconutc},
   {"rtcsync", 7, parse_rtcsync},
+  {"nolclsync", 7, parse_nolclsync},
   {"noclientlog", 11, parse_noclientlog},
   {"clientloglimit", 14, parse_clientloglimit},
   {"fallbackdrift", 13, parse_fallbackdrift},
@@ -906,6 +911,14 @@ parse_rtcsync(const char *line)
 /* ================================================== */
 
 static void
+parse_nolclsync(const char *line)
+{
+  lcl_sync = 0;
+}
+
+/* ================================================== */
+
+static void
 parse_noclientlog(const char *line)
 {
   no_client_log = 1;
@@ -1579,6 +1592,14 @@ CNF_GetRTCSync(void)
 
 /* ================================================== */
 
+int
+CNF_GetLCLSync(void)
+{
+  return lcl_sync;
+}
+
+/* ================================================== */
+
 void
 CNF_GetMakeStep(int *limit, double *threshold)
 {
diff --git a/conf.h b/conf.h
index 7f0f6b3..1fdc616 100644
--- a/conf.h
+++ b/conf.h
@@ -59,6 +59,7 @@ extern int CNF_GetManualEnabled(void);
 extern int CNF_GetCommandPort(void);
 extern int CNF_GetRTCOnUTC(void);
 extern int CNF_GetRTCSync(void);
+extern int CNF_GetLCLSync(void);
 extern void CNF_GetMakeStep(int *limit, double *threshold);
 extern void CNF_GetMaxChange(int *delay, int *ignore, double *offset);
 extern void CNF_GetLogChange(int *enabled, double *threshold);
diff --git a/reference.c b/reference.c
index 7bf8ec7..7c8f414 100644
--- a/reference.c
+++ b/reference.c
@@ -494,7 +494,7 @@ maybe_make_step()
   } else if (make_step_limit > 0) {
     make_step_limit--;
   }
-  LCL_MakeStep(make_step_threshold);
+  if (CNF_GetLCLSync()) LCL_MakeStep(make_step_threshold);
 }
 
 /* ================================================== */
@@ -705,16 +705,20 @@ REF_SetReference(int stratum,
 
     our_residual_freq = new_freq - our_frequency;
 
-    maybe_log_offset(our_offset);
-    LCL_AccumulateFrequencyAndOffset(our_frequency, our_offset, correction_rate);
+    if (CNF_GetLCLSync()) {
+        maybe_log_offset(our_offset);
+        LCL_AccumulateFrequencyAndOffset(our_frequency, our_offset, correction_rate);
+    }
     
   } else {
 
 #if 0    
     LOG(LOGS_INFO, LOGF_Reference, "Skew %f too large to track, offset=%f", skew, our_offset);
 #endif
-    maybe_log_offset(our_offset);
-    LCL_AccumulateOffset(our_offset, correction_rate);
+    if (CNF_GetLCLSync()) {
+        maybe_log_offset(our_offset);
+        LCL_AccumulateOffset(our_offset, correction_rate);
+    }
 
     our_residual_freq = frequency;
   }
-- 
1.7.4.4

-- 
Leo Baltus, internetbeheerder                         /\
NPO ICT Internet Services                            /NPO/\
Sumatralaan 45, 1217 GP Hilversum, Filmcentrum, west \  /\/
beheer@xxxxxxxxx, 035-6773555                         \/

-- 
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble?  Email listmaster@xxxxxxxxxxxxxxxxxxxx.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/