Blame SOURCES/ntp-4.2.6p5-rootdisp.patch

6e16f6
Backported from ntp-dev-4.2.7p385
6e16f6
6e16f6
diff -up ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp ntp-4.2.6p5/ntpd/ntp_proto.c
6e16f6
--- ntp-4.2.6p5/ntpd/ntp_proto.c.rootdisp	2013-12-09 15:02:58.394459288 +0100
6e16f6
+++ ntp-4.2.6p5/ntpd/ntp_proto.c	2013-12-09 15:10:05.770954848 +0100
6e16f6
@@ -1667,10 +1667,34 @@ clock_update(
6e16f6
 		sys_refid = peer->refid;
6e16f6
 	else
6e16f6
 		sys_refid = addr2refid(&peer->srcadr);
6e16f6
-	dtemp = sys_jitter + fabs(sys_offset) + peer->disp +
6e16f6
-	    (peer->delay + peer->rootdelay) / 2 + clock_phi *
6e16f6
-	    (current_time - peer->update);
6e16f6
-	sys_rootdisp = dtemp + peer->rootdisp;
6e16f6
+	/*
6e16f6
+	 * Root Dispersion (E) is defined (in RFC 5905) as:
6e16f6
+	 *
6e16f6
+	 * E = p.epsilon_r + p.epsilon + p.psi + PHI*(s.t - p.t) + |THETA|
6e16f6
+	 *
6e16f6
+	 * where:
6e16f6
+	 *  p.epsilon_r is the PollProc's root dispersion
6e16f6
+	 *  p.epsilon   is the PollProc's dispersion
6e16f6
+	 *  p.psi       is the PollProc's jitter
6e16f6
+	 *  THETA       is the combined offset
6e16f6
+	 *
6e16f6
+	 * NB: Think Hard about where these numbers come from and
6e16f6
+	 * what they mean.  When did peer->update happen?  Has anything
6e16f6
+	 * interesting happened since then?  What values are the most
6e16f6
+	 * defensible?  Why?
6e16f6
+	 *
6e16f6
+	 * DLM thinks this equation is probably the best of all worse choices.
6e16f6
+	 */
6e16f6
+	dtemp	= peer->rootdisp
6e16f6
+		+ peer->disp
6e16f6
+		+ sys_jitter
6e16f6
+		+ clock_phi * (current_time - peer->update)
6e16f6
+		+ fabs(sys_offset);
6e16f6
+
6e16f6
+	if (dtemp > sys_mindisp)                                                                                               
6e16f6
+		sys_rootdisp = dtemp;                                                                                          
6e16f6
+	else                                                                                                                   
6e16f6
+		sys_rootdisp = sys_mindisp;                                                                                    
6e16f6
 	sys_rootdelay = peer->delay + peer->rootdelay;
6e16f6
 	sys_reftime = peer->dst;
6e16f6
 
6e16f6
@@ -2810,15 +2834,36 @@ root_distance(
6e16f6
 	double	dtemp;
6e16f6
 
6e16f6
 	/*
6e16f6
+	 * Root Distance (LAMBDA) is defined as:
6e16f6
+	 * (delta + DELTA)/2 + epsilon + EPSILON + phi
6e16f6
+	 *
6e16f6
+	 * where:
6e16f6
+	 *  delta   is the round-trip delay
6e16f6
+	 *  DELTA   is the root delay
6e16f6
+	 *  epsilon is the remote server precision + local precision
6e16f6
+	 *	    + (15 usec each second)
6e16f6
+	 *  EPSILON is the root dispersion
6e16f6
+	 *  phi     is the peer jitter statistic
6e16f6
+	 *
6e16f6
+	 * NB: Think hard about why we are using these values, and what
6e16f6
+	 * the alternatives are, and the various pros/cons.
6e16f6
+	 *
6e16f6
+	 * DLM thinks these are probably the best choices from any of the
6e16f6
+	 * other worse choices.
6e16f6
+	 */
6e16f6
+	dtemp = (peer->delay + peer->rootdelay) / 2
6e16f6
+		+ LOGTOD(peer->precision)
6e16f6
+		  + LOGTOD(sys_precision)
6e16f6
+		  + clock_phi * (current_time - peer->update)
6e16f6
+		+ peer->rootdisp
6e16f6
+		+ peer->jitter;
6e16f6
+	/*
6e16f6
 	 * Careful squeak here. The value returned must be greater than
6e16f6
 	 * the minimum root dispersion in order to avoid clockhop with
6e16f6
 	 * highly precise reference clocks. Note that the root distance
6e16f6
 	 * cannot exceed the sys_maxdist, as this is the cutoff by the
6e16f6
 	 * selection algorithm.
6e16f6
 	 */
6e16f6
-	dtemp = (peer->delay + peer->rootdelay) / 2 + peer->disp +
6e16f6
-	    peer->rootdisp + clock_phi * (current_time - peer->update) +
6e16f6
-	    peer->jitter;
6e16f6
 	if (dtemp < sys_mindisp)
6e16f6
 		dtemp = sys_mindisp;
6e16f6
 	return (dtemp);