]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
reference: report same values in tracking command as in NTP
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 7 Apr 2016 15:09:01 +0000 (17:09 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 8 Apr 2016 14:21:19 +0000 (16:21 +0200)
Use REF_GetReferenceParams() in the tracking command to simplify the
code and report the same values as what NTP clients of the server see.

When the local reference mode is active, this changes the leap status to
synchronised and reference time to one second behind current time. When
not synchronised, the root delay and root dispersion are now 1 second.

reference.c
reports.h
test/simulation/115-cmdmontime

index 2c956f5b9b6d2661bab4bf19ca35cc982407e977..dfc851d33d8bf6f4e98ca4045c752852fe3195c5 100644 (file)
@@ -1367,52 +1367,34 @@ int REF_IsLeapSecondClose(void)
 void
 REF_GetTrackingReport(RPT_TrackingReport *rep)
 {
-  double elapsed;
-  double extra_dispersion;
   struct timeval now_raw, now_cooked;
   double correction;
+  int synchronised;
 
   LCL_ReadRawTime(&now_raw);
   LCL_GetOffsetCorrection(&now_raw, &correction, NULL);
   UTI_AddDoubleToTimeval(&now_raw, correction, &now_cooked);
 
-  rep->ref_id = NTP_REFID_UNSYNC;
+  REF_GetReferenceParams(&now_cooked, &synchronised,
+                         &rep->leap_status, &rep->stratum,
+                         &rep->ref_id, &rep->ref_time,
+                         &rep->root_delay, &rep->root_dispersion);
+
+  if (rep->stratum == NTP_MAX_STRATUM)
+    rep->stratum = 0;
+
   rep->ip_addr.family = IPADDR_UNSPEC;
-  rep->stratum = 0;
-  rep->leap_status = our_leap_status;
-  rep->ref_time.tv_sec = 0;
-  rep->ref_time.tv_usec = 0;
   rep->current_correction = correction;
   rep->freq_ppm = LCL_ReadAbsoluteFrequency();
   rep->resid_freq_ppm = 0.0;
   rep->skew_ppm = 0.0;
-  rep->root_delay = 0.0;
-  rep->root_dispersion = 0.0;
   rep->last_update_interval = last_ref_update_interval;
   rep->last_offset = last_offset;
   rep->rms_offset = sqrt(avg2_offset);
 
   if (are_we_synchronised) {
-    
-    UTI_DiffTimevalsToDouble(&elapsed, &now_cooked, &our_ref_time);
-    extra_dispersion = (our_skew + fabs(our_residual_freq) + LCL_GetMaxClockError()) * elapsed;
-    
-    rep->ref_id = our_ref_id;
     rep->ip_addr = our_ref_ip;
-    rep->stratum = our_stratum;
-    rep->ref_time = our_ref_time;
     rep->resid_freq_ppm = 1.0e6 * our_residual_freq;
     rep->skew_ppm = 1.0e6 * our_skew;
-    rep->root_delay = our_root_delay;
-    rep->root_dispersion = our_root_dispersion + extra_dispersion;
-
-  } else if (enable_local_stratum) {
-
-    rep->ref_id = NTP_REFID_LOCAL;
-    rep->ip_addr.family = IPADDR_UNSPEC;
-    rep->stratum = local_stratum;
-    rep->ref_time = now_cooked;
-    rep->root_dispersion = LCL_GetSysPrecisionAsQuantum();
   }
-
 }
index 193d933c0ef3db055c5618f46677416a167f99a1..7d5d431b40e63c6ac2dfd971c9c869361f102db6 100644 (file)
--- a/reports.h
+++ b/reports.h
@@ -29,6 +29,7 @@
 
 #include "sysincl.h"
 #include "addressing.h"
+#include "ntp.h"
 
 #define REPORT_INVALID_OFFSET 0x80000000
 
@@ -50,8 +51,8 @@ typedef struct {
 typedef struct {
   uint32_t ref_id;
   IPAddr ip_addr;
-  unsigned long stratum;
-  unsigned long leap_status;
+  int stratum;
+  NTP_Leap leap_status;
   struct timeval ref_time;
   double current_correction;
   double last_offset;
index 017daad802291601c1e3b56b995dc75119747b1f..2806a1f6bba1763a4a41eb7fae25a6f5dd3377f4 100755 (executable)
@@ -10,7 +10,7 @@ grep -q 'HAVE_LONG_TIME_T 1' ../../config.h || test_skip
 limit=2
 client_server_options="noselect"
 client_conf="local stratum 1"
-chronyc_start="0.5"
+chronyc_start="1.5"
 chronyc_conf="tracking"
 
 for year in `seq 1850 100 2300`; do