Blame SOURCES/ntp-4.2.6p5-backfwdstep.patch

6d3098
diff -up ntp-4.2.6p5/html/miscopt.html.backfwdstep ntp-4.2.6p5/html/miscopt.html
6d3098
--- ntp-4.2.6p5/html/miscopt.html.backfwdstep	2015-05-13 17:07:13.553206904 +0200
6d3098
+++ ntp-4.2.6p5/html/miscopt.html	2015-05-13 17:55:59.226133427 +0200
6d3098
@@ -70,7 +70,7 @@
6d3098
 			
Specify the directory in which to write configuration snapshots requested with <tt>ntpq</tt>'s saveconfig command. If <tt>saveconfigdir</tt> does not appear in the configuration file, saveconfig requests are rejected by ntpd.
6d3098
 			
<tt>setvar variable [default]</tt>
6d3098
 			
This command adds an additional system variable. These variables can be used to distribute additional information such as the access policy. If the variable of the form <tt>name = value</tt> is followed by the <tt>default</tt> keyword, the variable will be listed as part of the default system variables (<tt>ntpq rv</tt> command). These additional variables serve informational purposes only. They are not related to the protocol other that they can be listed. The known protocol variables will always override any variables defined via the <tt>setvar</tt> mechanism. There are three special variables that contain the names of all variable of the same group. The <tt>sys_var_list</tt> holds the names of all system variables. The <tt>peer_var_list</tt> holds the names of all peer variables and the <tt>clock_var_list</tt> holds the names of the reference clock variables.
6d3098
-			
<tt>tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepout stepout ]</tt>
6d3098
+			
<tt>tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepback step | stepfwd step | stepout stepout ]</tt>
6d3098
 			
This command alters certain system variables used by the clock discipline algorithm. The default values of these variables have been carefully optimized for a wide range of network speeds and reliability expectations. Very rarely is it necessary to change the default values; but, some folks can't resist twisting the knobs. The options are as follows:
6d3098
 				
6d3098
 					
<tt>allan allan</tt>
6d3098
@@ -89,6 +89,10 @@
6d3098
 						occur. Note: The kernel time discipline is disabled if
6d3098
 						the step threshold is set to zero or greater than 0.5
6d3098
 						s and the threshold is applied also to leap second corrections.
6d3098
+					
<tt>stepback step</tt>
6d3098
+					
Specifies the step threshold, but only in the backward direction.
6d3098
+					
<tt>stepfwd step</tt>
6d3098
+					
Specifies the step threshold, but only in the forward direction. To avoid problems with frequency stabilization after large slews it's not recommended to set one direction to a value greater than 0.5 s without setting also the other direction to at least 0.5 s.
6d3098
 					
<tt>stepout stepout</tt>
6d3098
 					
Specifies the stepout threshold in seconds. The default without this
6d3098
 						command is 900 s.  If set to zero, popcorn spikes will
6d3098
diff -up ntp-4.2.6p5/include/ntp.h.backfwdstep ntp-4.2.6p5/include/ntp.h
6d3098
--- ntp-4.2.6p5/include/ntp.h.backfwdstep	2011-12-01 03:55:17.000000000 +0100
6d3098
+++ ntp-4.2.6p5/include/ntp.h	2015-05-13 17:23:19.953372541 +0200
6d3098
@@ -725,6 +725,8 @@ struct pkt {
6d3098
 #define LOOP_KERN_CLEAR		11	/* reset kernel pll parameters */
6d3098
 #define LOOP_CODEC		12	/* set audio codec frequency */
6d3098
 #define	LOOP_LEAP		13	/* insert leap after second 23:59 */
6d3098
+#define LOOP_MAX_BACK		14	/* set bacward-step offset */
6d3098
+#define LOOP_MAX_FWD		15	/* set forward-step offset */
6d3098
 
6d3098
 /*
6d3098
  * Configuration items for the stats printer
6d3098
diff -up ntp-4.2.6p5/include/ntpd.h.backfwdstep ntp-4.2.6p5/include/ntpd.h
6d3098
--- ntp-4.2.6p5/include/ntpd.h.backfwdstep	2015-05-13 17:07:13.498212244 +0200
6d3098
+++ ntp-4.2.6p5/include/ntpd.h	2015-05-13 17:28:42.516052737 +0200
6d3098
@@ -345,7 +345,8 @@ extern int	maxactivefd;
6d3098
 /* ntp_loopfilter.c */
6d3098
 extern double	drift_comp;		/* clock frequency (s/s) */
6d3098
 extern double	clock_stability;	/* clock stability (s/s) */
6d3098
-extern double	clock_max;		/* max offset before step (s) */
6d3098
+extern double	clock_max_back;		/* max backward offset before step (s) */
6d3098
+extern double	clock_max_fwd;		/* max forward offset before step (s) */
6d3098
 extern double	clock_panic;		/* max offset before panic (s) */
6d3098
 extern double	clock_phi;		/* dispersion rate (s/s) */
6d3098
 extern double	clock_minstep;		/* step timeout (s) */
6d3098
diff -up ntp-4.2.6p5/ntpd/cmd_args.c.backfwdstep ntp-4.2.6p5/ntpd/cmd_args.c
6d3098
--- ntp-4.2.6p5/ntpd/cmd_args.c.backfwdstep	2009-12-25 10:03:41.000000000 +0100
6d3098
+++ ntp-4.2.6p5/ntpd/cmd_args.c	2015-05-13 17:25:05.726102347 +0200
6d3098
@@ -161,8 +161,7 @@ getCmdOpts(
6d3098
 	}
6d3098
 
6d3098
 	if (HAVE_OPT( SLEW )) {
6d3098
-		clock_max = 600;
6d3098
-		kern_enable = 0;
6d3098
+		loop_config(LOOP_MAX, 600);
6d3098
 	}
6d3098
 	if (HAVE_OPT( UPDATEINTERVAL )) {
6d3098
 		long val = OPT_VALUE_UPDATEINTERVAL;
6d3098
diff -up ntp-4.2.6p5/ntpd/keyword-gen.c.backfwdstep ntp-4.2.6p5/ntpd/keyword-gen.c
6d3098
--- ntp-4.2.6p5/ntpd/keyword-gen.c.backfwdstep	2010-04-18 10:05:39.000000000 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/keyword-gen.c	2015-05-13 17:39:08.889233906 +0200
6d3098
@@ -173,6 +173,8 @@ struct key_tok ntp_keywords[] = {
6d3098
 { "stats",		T_Stats,		FOLLBY_TOKEN },
6d3098
 /* tinker_option */
6d3098
 { "step",		T_Step,			FOLLBY_TOKEN },
6d3098
+{ "stepback",		T_Stepback,		FOLLBY_TOKEN },
6d3098
+{ "stepfwd",		T_Stepfwd,		FOLLBY_TOKEN },
6d3098
 { "panic",		T_Panic,		FOLLBY_TOKEN },
6d3098
 { "dispersion",		T_Dispersion,		FOLLBY_TOKEN },
6d3098
 { "stepout",		T_Stepout,		FOLLBY_TOKEN },
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_config.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_config.c
6d3098
--- ntp-4.2.6p5/ntpd/ntp_config.c.backfwdstep	2015-05-13 17:07:13.534208748 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_config.c	2015-05-13 17:36:12.929319050 +0200
6d3098
@@ -2407,6 +2407,14 @@ config_tinker(
6d3098
 			item = LOOP_MAX;
6d3098
 			break;
6d3098
 
6d3098
+		case T_Stepback:
6d3098
+			item = LOOP_MAX_BACK;
6d3098
+			break;
6d3098
+
6d3098
+		case T_Stepfwd:
6d3098
+			item = LOOP_MAX_FWD;
6d3098
+			break;
6d3098
+
6d3098
 		case T_Stepout:
6d3098
 			item = LOOP_MINSTEP;
6d3098
 			break;
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_loopfilter.c
6d3098
--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.backfwdstep	2015-05-13 17:07:13.499212146 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c	2015-05-13 17:20:42.362674093 +0200
6d3098
@@ -107,7 +107,8 @@
6d3098
 /*
6d3098
  * Program variables that can be tinkered.
6d3098
  */
6d3098
-double	clock_max = CLOCK_MAX;	/* step threshold */
6d3098
+double	clock_max_back = CLOCK_MAX;	/* step threshold */
6d3098
+double	clock_max_fwd =  CLOCK_MAX;	/* step threshold */
6d3098
 double	clock_minstep = CLOCK_MINSTEP; /* stepout threshold */
6d3098
 double	clock_panic = CLOCK_PANIC; /* panic threshold */
6d3098
 double	clock_phi = CLOCK_PHI;	/* dispersion rate (s/s) */
6d3098
@@ -257,7 +258,8 @@ local_clock(
6d3098
 	 * directly to the terminal.
6d3098
 	 */
6d3098
 	if (mode_ntpdate) {
6d3098
-		if (fabs(fp_offset) > clock_max && clock_max > 0) {
6d3098
+		if (  ( fp_offset > clock_max_fwd  && clock_max_fwd  > 0)
6d3098
+		   || (-fp_offset > clock_max_back && clock_max_back > 0)) {
6d3098
 			step_systime(fp_offset);
6d3098
 			msyslog(LOG_NOTICE, "ntpd: time set %+.6f s",
6d3098
 	   		    fp_offset);
6d3098
@@ -319,7 +321,8 @@ local_clock(
6d3098
 	mu = current_time - clock_epoch;
6d3098
 	clock_frequency = drift_comp;
6d3098
 	rval = 1;
6d3098
-	if (fabs(fp_offset) > clock_max && clock_max > 0) {
6d3098
+	if (  ( fp_offset > clock_max_fwd  && clock_max_fwd  > 0)
6d3098
+	   || (-fp_offset > clock_max_back && clock_max_back > 0)) {
6d3098
 		switch (state) {
6d3098
 
6d3098
 		/*
6d3098
@@ -1007,8 +1010,20 @@ loop_config(
6d3098
 		break;
6d3098
 
6d3098
 	case LOOP_MAX:		/* step threshold (step) */
6d3098
-		clock_max = freq;
6d3098
-		if (clock_max == 0 || clock_max > 0.5)
6d3098
+		clock_max_fwd = clock_max_back = freq;
6d3098
+		if (freq == 0 || freq > 0.5)
6d3098
+			kern_enable = 0;
6d3098
+		break;
6d3098
+
6d3098
+	case LOOP_MAX_BACK:	/* step threshold (step) */
6d3098
+		clock_max_back = freq;
6d3098
+		if (freq == 0 || freq > 0.5)
6d3098
+			kern_enable = 0;
6d3098
+		break;
6d3098
+
6d3098
+	case LOOP_MAX_FWD:	/* step threshold (step) */
6d3098
+		clock_max_fwd = freq;
6d3098
+		if (freq == 0 || freq > 0.5)
6d3098
 			kern_enable = 0;
6d3098
 		break;
6d3098
 
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.backfwdstep ntp-4.2.6p5/ntpd/ntp_parser.y
6d3098
--- ntp-4.2.6p5/ntpd/ntp_parser.y.backfwdstep	2010-10-24 08:29:35.000000000 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_parser.y	2015-05-13 17:40:45.207881673 +0200
6d3098
@@ -190,6 +190,8 @@
6d3098
 %token	<Integer>	T_Stats
6d3098
 %token	<Integer>	T_Statsdir
6d3098
 %token	<Integer>	T_Step
6d3098
+%token	<Integer>	T_Stepback
6d3098
+%token	<Integer>	T_Stepfwd
6d3098
 %token	<Integer>	T_Stepout
6d3098
 %token	<Integer>	T_Stratum
6d3098
 %token	<String>	T_String
6d3098
@@ -899,6 +901,8 @@ tinker_option_keyword
6d3098
 	|	T_Huffpuff
6d3098
 	|	T_Panic
6d3098
 	|	T_Step
6d3098
+	|	T_Stepback
6d3098
+	|	T_Stepfwd
6d3098
 	|	T_Stepout
6d3098
 	;
6d3098
 
6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_timer.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_timer.c
6d3098
--- ntp-4.2.6p5/ntpd/ntp_timer.c.backfwdstep	2015-05-13 17:07:13.554206806 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_timer.c	2015-05-13 17:27:45.659573319 +0200
6d3098
@@ -450,7 +450,7 @@ timer(void)
6d3098
 			sys_tai = leap_tai;
6d3098
 #ifdef KERNEL_PLL
6d3098
 			if (!pll_control || !kern_enable) {
6d3098
-				if (clock_max < 1.0 && clock_max > 0.0) {
6d3098
+				if (clock_max_back < 1.0 && clock_max_back > 0.0) {
6d3098
 					step_systime(-1.0);
6d3098
 					msyslog(LOG_NOTICE, "Inserting positive leap second");
6d3098
 				} else {