[ntp] fix calculation of root dispersion (#1037981)

Miroslav Lichvar mlichvar at fedoraproject.org
Mon Dec 9 16:14:30 UTC 2013


commit 08678200be52f3d132c72db262393fa532944435
Author: Miroslav Lichvar <mlichvar at redhat.com>
Date:   Mon Dec 9 15:38:35 2013 +0100

    fix calculation of root dispersion (#1037981)

 ntp-4.2.6p5-rootdisp.patch |   84 ++++++++++++++++++++++++++++++++++++++++++++
 ntp.spec                   |    3 ++
 2 files changed, 87 insertions(+), 0 deletions(-)
---
diff --git a/ntp-4.2.6p5-rootdisp.patch b/ntp-4.2.6p5-rootdisp.patch
new file mode 100644
index 0000000..9d90359
--- /dev/null
+++ b/ntp-4.2.6p5-rootdisp.patch
@@ -0,0 +1,84 @@
+Backported from ntp-dev-4.2.7p385
+
+diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp ntp-4.2.6p5/ntpd/ntp_proto.c
+--- ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp	2013-12-09 15:02:58.394459288 +0100
++++ ntp-4.2.6p5/ntpd/ntp_proto.c	2013-12-09 15:10:05.770954848 +0100
+@@ -1667,10 +1667,34 @@ clock_update(
+ 		sys_refid = peer->refid;
+ 	else
+ 		sys_refid = addr2refid(&peer->srcadr);
+-	dtemp = sys_jitter + fabs(sys_offset) + peer->disp +
+-	    (peer->delay + peer->rootdelay) / 2 + clock_phi *
+-	    (current_time - peer->update);
+-	sys_rootdisp = dtemp + peer->rootdisp;
++	/*
++	 * Root Dispersion (E) is defined (in RFC 5905) as:
++	 *
++	 * E = p.epsilon_r + p.epsilon + p.psi + PHI*(s.t - p.t) + |THETA|
++	 *
++	 * where:
++	 *  p.epsilon_r is the PollProc's root dispersion
++	 *  p.epsilon   is the PollProc's dispersion
++	 *  p.psi       is the PollProc's jitter
++	 *  THETA       is the combined offset
++	 *
++	 * NB: Think Hard about where these numbers come from and
++	 * what they mean.  When did peer->update happen?  Has anything
++	 * interesting happened since then?  What values are the most
++	 * defensible?  Why?
++	 *
++	 * DLM thinks this equation is probably the best of all worse choices.
++	 */
++	dtemp	= peer->rootdisp
++		+ peer->disp
++		+ sys_jitter
++		+ clock_phi * (current_time - peer->update)
++		+ fabs(sys_offset);
++
++	if (dtemp > sys_mindisp)                                                                                               
++		sys_rootdisp = dtemp;                                                                                          
++	else                                                                                                                   
++		sys_rootdisp = sys_mindisp;                                                                                    
+ 	sys_rootdelay = peer->delay + peer->rootdelay;
+ 	sys_reftime = peer->dst;
+ 
+@@ -2810,15 +2834,36 @@ root_distance(
+ 	double	dtemp;
+ 
+ 	/*
++	 * Root Distance (LAMBDA) is defined as:
++	 * (delta + DELTA)/2 + epsilon + EPSILON + phi
++	 *
++	 * where:
++	 *  delta   is the round-trip delay
++	 *  DELTA   is the root delay
++	 *  epsilon is the remote server precision + local precision
++	 *	    + (15 usec each second)
++	 *  EPSILON is the root dispersion
++	 *  phi     is the peer jitter statistic
++	 *
++	 * NB: Think hard about why we are using these values, and what
++	 * the alternatives are, and the various pros/cons.
++	 *
++	 * DLM thinks these are probably the best choices from any of the
++	 * other worse choices.
++	 */
++	dtemp = (peer->delay + peer->rootdelay) / 2
++		+ LOGTOD(peer->precision)
++		  + LOGTOD(sys_precision)
++		  + clock_phi * (current_time - peer->update)
++		+ peer->rootdisp
++		+ peer->jitter;
++	/*
+ 	 * Careful squeak here. The value returned must be greater than
+ 	 * the minimum root dispersion in order to avoid clockhop with
+ 	 * highly precise reference clocks. Note that the root distance
+ 	 * cannot exceed the sys_maxdist, as this is the cutoff by the
+ 	 * selection algorithm.
+ 	 */
+-	dtemp = (peer->delay + peer->rootdelay) / 2 + peer->disp +
+-	    peer->rootdisp + clock_phi * (current_time - peer->update) +
+-	    peer->jitter;
+ 	if (dtemp < sys_mindisp)
+ 		dtemp = sys_mindisp;
+ 	return (dtemp);
diff --git a/ntp.spec b/ntp.spec
index cc07ca4..0cd6252 100644
--- a/ntp.spec
+++ b/ntp.spec
@@ -61,6 +61,8 @@ Patch5: ntp-4.2.6p1-linkfastmath.patch
 Patch6: ntp-4.2.6p5-fipsmd5.patch
 # ntpbz #759
 Patch7: ntp-4.2.6p1-retcode.patch
+# ntpbz #2085
+Patch8: ntp-4.2.6p5-rootdisp.patch
 # ntpbz #2309
 Patch9: ntp-4.2.6p5-hexpw.patch
 # ntpbz #898
@@ -180,6 +182,7 @@ This package contains NTP documentation in HTML format.
 %endif
 %patch6 -p1 -b .fipsmd5
 %patch7 -p1 -b .retcode
+%patch8 -p1 -b .rootdisp
 %patch9 -p1 -b .hexpw
 %patch10 -p1 -b .htmldoc
 %patch11 -p1 -b .updatebclient


More information about the scm-commits mailing list