[Git][NTPsec/ntpsec][master] 2 commits: Documentation polishing.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Jan 29 12:27:04 UTC 2019
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
e534c6a9 by Eric S. Raymond at 2019-01-29T05:35:36Z
Documentation polishing.
- - - - -
23527dee by Eric S. Raymond at 2019-01-29T12:24:35Z
Introduce refid_t typedef.
- - - - -
7 changed files:
- devel/testing.adoc
- include/ntp.h
- include/ntp_refclock.h
- include/ntpd.h
- ntpd/ntp_control.c
- ntpd/ntp_proto.c
- ntpd/ntp_timer.c
Changes:
=====================================
devel/testing.adoc
=====================================
@@ -8,15 +8,18 @@ directory.
== Path problems with the test tools ==
-The very first thing to do, even before you start up ntpd, is to change
-directory to build/main/ntpclients/ and run ./ntpq there. If you get a message
-that says
+The build tree has been set up so that if you first waf builid then cd to
+build/main/ntpclients/ and run (say) ntpq, you should be able to test
+new bersions of the Python code without installing to rootspace.
+
+The very first thing to do, even before you start up ntpd, is to try that.
+If you get a message that says
---------------------------------------------------------------------
ntpq: can't find Python NTP library -- check PYTHONPATH.
---------------------------------------------------------------------
-You *may* have a problem. A lot of what was C code in legacy versions
+you *may* have a problem. A lot of what was C code in legacy versions
(pretty much everything except ntpd itself, in fact) has been moved to
Python to improve maintainability and decrease attack
surface. Most of these tools share a Python library of critical
=====================================
include/ntp.h
=====================================
@@ -109,7 +109,24 @@ extern uint64_t ntp_random64 (void);
#define LOGTOD(a) ldexp(1., (int)(a)) /* log2 to double */
#define ULOGTOD(a) ldexp(1., (int)(a)) /* ulog2 to double */
+/*
+ * A refid is a "reference ID", intended as a uniqueness cookie for
+ * network hosts, used to prevent loops in the flow graph of
+ * client/server relationships. Unfortunately, the length was frozen
+ * into the NTP packet format before IPv6; in that case the value is a
+ * hash of the IPv6 address and collisions *have* been observed in the
+ * wild
+ *
+ * Just to contemplate things further, the refid for a local clock source
+ * (which doesn't have an IP address) is interpreted as a 4-digit string that
+ * identifies the clock device class.
+ *
+ * In ntpq, the refid field in displays is overloaded yet again. It can have
+ * the value "POOL" or "INIT" describing a connection status for a host that
+ * is not yet supplying time.
+ */
#define REFIDLEN sizeof(uint32_t) /* size of IPv4 network addr */
+typedef unsigned char refid_t[REFIDLEN];
/*
* The netendpt structure is used to hold the addresses and socket
@@ -127,7 +144,7 @@ typedef struct netendpt {
unsigned short family; /* AF_INET/AF_INET6 */
unsigned short phase; /* phase in update cycle */
uint32_t flags; /* interface flags */
- char addr_refid[REFIDLEN]; /* IPv4 addr or IPv6 hash */
+ refid_t addr_refid; /* IPv4 addr or IPv6 hash */
unsigned long starttime; /* current_time at creation */
volatile long received; /* number of incoming packets */
long sent; /* number of outgoing packets */
@@ -256,7 +273,7 @@ struct peer {
int8_t precision; /* remote clock precision */
double rootdelay; /* roundtrip delay to primary source */
double rootdisp; /* dispersion to primary source */
- char refid[REFIDLEN];/* remote reference ID */
+ refid_t refid; /* remote reference ID */
l_fp reftime; /* update epoch */
#define clear_to_zero status
@@ -395,7 +412,7 @@ struct parsed_pkt {
int8_t precision;
uint32_t rootdelay;
uint32_t rootdisp;
- char refid[REFIDLEN];
+ refid_t refid;
uint64_t reftime;
uint64_t org;
uint64_t rec;
=====================================
include/ntp_refclock.h
=====================================
@@ -137,7 +137,7 @@ struct refclockproc {
double fudgetime1; /* fudge time1 */
double fudgetime2; /* fudge time2 */
uint8_t stratum; /* server stratum */
- char refid[REFIDLEN]; /* reference identifier */
+ refid_t refid; /* reference identifier */
uint8_t sloppyclockflag; /* driver options */
/*
=====================================
include/ntpd.h
=====================================
@@ -337,7 +337,7 @@ struct system_variables {
double sys_rootdelay; /* roundtrip delay to primary source */
double sys_rootdisp; /* dispersion to primary source */
double sys_rootdist; /* distance to primary source */
- char sys_refid[REFIDLEN]; /* reference id */
+ refid_t sys_refid; /* reference id */
l_fp sys_reftime; /* last update time */
struct peer *sys_peer; /* current peer */
};
=====================================
ntpd/ntp_control.c
=====================================
@@ -66,9 +66,8 @@ static void ctl_putuint (const char *, uint64_t);
static void ctl_puthex (const char *, uint64_t);
static void ctl_putint (const char *, long);
static void ctl_putts (const char *, l_fp *);
-static void ctl_putadr (const char *, char[REFIDLEN],
- sockaddr_u *);
-static void ctl_putrefid (const char *, char *);
+static void ctl_putadr (const char *, refid_t, sockaddr_u *);
+static void ctl_putrefid (const char *, refid_t);
static void ctl_putarray (const char *, double *, int);
static void ctl_putsys (int);
static void ctl_putpeer (int, struct peer *);
@@ -1368,7 +1367,7 @@ ctl_putts(
static void
ctl_putadr(
const char *tag,
- char refid[REFIDLEN],
+ refid_t refid,
sockaddr_u *addr
)
{
@@ -1401,7 +1400,7 @@ ctl_putadr(
static void
ctl_putrefid(
const char * tag,
- char refid[REFIDLEN]
+ refid_t refid
)
{
char output[16];
=====================================
ntpd/ntp_proto.c
=====================================
@@ -35,7 +35,7 @@ struct pkt {
int8_t precision; /* peer clock precision */
u_fp rootdelay; /* roundtrip delay to primary source */
u_fp rootdisp; /* dispersion to primary source*/
- char refid[REFIDLEN]; /* reference id */
+ refid_t refid; /* reference id */
l_fp_w reftime; /* last update time */
l_fp_w org; /* originate time stamp */
l_fp_w rec; /* receive time stamp */
=====================================
ntpd/ntp_timer.c
=====================================
@@ -235,11 +235,11 @@ timer(void)
}
sys_vars.sys_stratum = (uint8_t)sys_orphan;
if (sys_vars.sys_stratum > 1) {
- /* set LOOPBACKADR */
- sys_vars.sys_refid[0] = 127;
- sys_vars.sys_refid[1] = 0;
- sys_vars.sys_refid[2] = 0;
- sys_vars.sys_refid[3] = 1;
+ /* set LOOPBACKADR */
+ sys_vars.sys_refid[0] = 127;
+ sys_vars.sys_refid[1] = 0;
+ sys_vars.sys_refid[2] = 0;
+ sys_vars.sys_refid[3] = 1;
} else
memcpy(&sys_vars.sys_refid, "LOOP", REFIDLEN);
sys_offset = 0;
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/3d194979e02d6ddee4c6ac9bc5c3aee684b7a7da...23527dee44523171f02f9f35cd1539b779bedd53
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/3d194979e02d6ddee4c6ac9bc5c3aee684b7a7da...23527dee44523171f02f9f35cd1539b779bedd53
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20190129/9e88e1c6/attachment-0001.html>
More information about the vc
mailing list