Blame SOURCES/ntp-4.2.6p5-rootdisp.patch

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