[Git][NTPsec/ntpsec][master] 2 commits: Bug fix: GPSD driver was logging (null)(0) rather than GPSD(0)
Hal Murray
gitlab at mg.gitlab.com
Tue Aug 23 03:45:00 UTC 2016
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
d0372d5e by Hal Murray at 2016-08-22T20:44:40-07:00
Bug fix: GPSD driver was logging (null)(0) rather than GPSD(0)
The code was caching the result from refclock_name before
setting up pp->clockname which is used by refclock_name
- - - - -
a0d81c39 by Hal Murray at 2016-08-22T20:44:40-07:00
First cut at fixing minsane - log msg only.
- - - - -
3 changed files:
- include/ntpd.h
- ntpd/ntpd.c
- ntpd/refclock_gpsd.c
Changes:
=====================================
include/ntpd.h
=====================================
--- a/include/ntpd.h
+++ b/include/ntpd.h
@@ -416,6 +416,8 @@ extern double sys_rootdisp; /* dispersion to primary source */
extern uint32_t sys_refid; /* reference id */
extern l_fp sys_reftime; /* last update time */
extern struct peer *sys_peer; /* current peer */
+extern int sys_maxclock; /* maximum candidates */
+extern int sys_minclock; /* minimum candidates */
/*
* Nonspecified system state variables.
=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -56,6 +56,8 @@ DNSServiceRef mdns;
#include <sodium.h>
+static void check_minsane();
+
static bool need_priority = false;
static bool config_priority_override = false;
static int config_priority;
@@ -914,6 +916,7 @@ ntpdmain(
*/
have_interface_option = (!listen_to_virtual_ips || explicit_interface);
intercept_getconfig(explicit_config);
+ check_minsane();
loop_config(LOOP_DRIFTINIT, 0);
report_event(EVNT_SYSRESTART, NULL, NULL);
@@ -1208,6 +1211,43 @@ wait_child_sync_if(
/*
+ * check_minsane - check peers to see if minsane should be bigger
+ *
+ * This is just a first cut. It should probably fixup things automagically.
+ * We also need to do similar for maxclock when running a pool command.
+ *
+ * With 2 working servers:
+ * if they don't agree, you can't tell which one is correct
+ * With 3 working servers, 2 can outvote a falseticker
+ * With 4 servers, you still have 3 if one is down.
+ */
+static void check_minsane()
+{
+ struct peer *peer;
+ int servers = 0;
+
+ if (sys_minsane > 1) return; /* already adjusted, assume reasonable */
+
+ for (peer = peer_list; peer != NULL; peer = peer->p_link) {
+ if (peer->flags & FLAG_NOSELECT) continue;
+ servers++;
+ if (peer->cast_flags & MDF_POOL) {
+ /* pool server */
+ servers = sys_maxclock;
+ break;
+ }
+ /* ?? multicast and such */
+ }
+
+ if (servers >= 5)
+ msyslog(LOG_ERR, "Found %d servers, suggest minsane at least 3", servers);
+ else if (servers == 4)
+ msyslog(LOG_ERR, "Found 4 servers, suggest minsane of 2");
+
+};
+
+
+/*
* assertion_failed - Redirect assertion failures to msyslog().
*/
static void
=====================================
ntpd/refclock_gpsd.c
=====================================
--- a/ntpd/refclock_gpsd.c
+++ b/ntpd/refclock_gpsd.c
@@ -512,6 +512,7 @@ gpsd_start(
++up->refcount;
/* initialize the unit structure */
+ pp->clockname = NAME; /* Hack, needed by refclock_name */
up->logname = estrdup(refclock_name(peer));
up->unit = unit & 0x7F;
up->fdt = -1;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/8dae7cc3e442b9849f4c1d0cb03d285763843b92...a0d81c395af8034b44573758d38a64268fb78841
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20160823/358f8d96/attachment.html>
More information about the vc
mailing list