Blame SOURCES/ntp-4.2.6p5-backfwdstep.patch

2b78f7
diff -up ntp-4.2.6p5/html/miscopt.html.backfwdstep ntp-4.2.6p5/html/miscopt.html
2b78f7
--- ntp-4.2.6p5/html/miscopt.html.backfwdstep	2015-05-13 17:07:13.553206904 +0200
2b78f7
+++ ntp-4.2.6p5/html/miscopt.html	2015-05-13 17:55:59.226133427 +0200
2b78f7
@@ -70,7 +70,7 @@
2b78f7
 			
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.
2b78f7
 			
<tt>setvar variable [default]</tt>
2b78f7
 			
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.
2b78f7
-			
<tt>tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepout stepout ]</tt>
2b78f7
+			
<tt>tinker [ allan allan | dispersion dispersion | freq freq | huffpuff huffpuff | panic panic | step step | stepback step | stepfwd step | stepout stepout ]</tt>
2b78f7
 			
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:
2b78f7
 				
2b78f7
 					
<tt>allan allan</tt>
2b78f7
@@ -89,6 +89,10 @@
2b78f7
 						occur. Note: The kernel time discipline is disabled if
2b78f7
 						the step threshold is set to zero or greater than 0.5
2b78f7
 						s and the threshold is applied also to leap second corrections.
2b78f7
+					
<tt>stepback step</tt>
2b78f7
+					
Specifies the step threshold, but only in the backward direction.
2b78f7
+					
<tt>stepfwd step</tt>
2b78f7
+					
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.
2b78f7
 					
<tt>stepout stepout</tt>
2b78f7
 					
Specifies the stepout threshold in seconds. The default without this
2b78f7
 						command is 900 s.  If set to zero, popcorn spikes will
2b78f7
diff -up ntp-4.2.6p5/include/ntp.h.backfwdstep ntp-4.2.6p5/include/ntp.h
2b78f7
--- ntp-4.2.6p5/include/ntp.h.backfwdstep	2011-12-01 03:55:17.000000000 +0100
2b78f7
+++ ntp-4.2.6p5/include/ntp.h	2015-05-13 17:23:19.953372541 +0200
2b78f7
@@ -725,6 +725,8 @@ struct pkt {
2b78f7
 #define LOOP_KERN_CLEAR		11	/* reset kernel pll parameters */
2b78f7
 #define LOOP_CODEC		12	/* set audio codec frequency */
2b78f7
 #define	LOOP_LEAP		13	/* insert leap after second 23:59 */
2b78f7
+#define LOOP_MAX_BACK		14	/* set bacward-step offset */
2b78f7
+#define LOOP_MAX_FWD		15	/* set forward-step offset */
2b78f7
 
2b78f7
 /*
2b78f7
  * Configuration items for the stats printer
2b78f7
diff -up ntp-4.2.6p5/include/ntpd.h.backfwdstep ntp-4.2.6p5/include/ntpd.h
2b78f7
--- ntp-4.2.6p5/include/ntpd.h.backfwdstep	2015-05-13 17:07:13.498212244 +0200
2b78f7
+++ ntp-4.2.6p5/include/ntpd.h	2015-05-13 17:28:42.516052737 +0200
2b78f7
@@ -345,7 +345,8 @@ extern int	maxactivefd;
2b78f7
 /* ntp_loopfilter.c */
2b78f7
 extern double	drift_comp;		/* clock frequency (s/s) */
2b78f7
 extern double	clock_stability;	/* clock stability (s/s) */
2b78f7
-extern double	clock_max;		/* max offset before step (s) */
2b78f7
+extern double	clock_max_back;		/* max backward offset before step (s) */
2b78f7
+extern double	clock_max_fwd;		/* max forward offset before step (s) */
2b78f7
 extern double	clock_panic;		/* max offset before panic (s) */
2b78f7
 extern double	clock_phi;		/* dispersion rate (s/s) */
2b78f7
 extern double	clock_minstep;		/* step timeout (s) */
2b78f7
diff -up ntp-4.2.6p5/ntpd/cmd_args.c.backfwdstep ntp-4.2.6p5/ntpd/cmd_args.c
2b78f7
--- ntp-4.2.6p5/ntpd/cmd_args.c.backfwdstep	2009-12-25 10:03:41.000000000 +0100
2b78f7
+++ ntp-4.2.6p5/ntpd/cmd_args.c	2015-05-13 17:25:05.726102347 +0200
2b78f7
@@ -161,8 +161,7 @@ getCmdOpts(
2b78f7
 	}
2b78f7
 
2b78f7
 	if (HAVE_OPT( SLEW )) {
2b78f7
-		clock_max = 600;
2b78f7
-		kern_enable = 0;
2b78f7
+		loop_config(LOOP_MAX, 600);
2b78f7
 	}
2b78f7
 	if (HAVE_OPT( UPDATEINTERVAL )) {
2b78f7
 		long val = OPT_VALUE_UPDATEINTERVAL;
2b78f7
diff -up ntp-4.2.6p5/ntpd/keyword-gen.c.backfwdstep ntp-4.2.6p5/ntpd/keyword-gen.c
2b78f7
--- ntp-4.2.6p5/ntpd/keyword-gen.c.backfwdstep	2010-04-18 10:05:39.000000000 +0200
2b78f7
+++ ntp-4.2.6p5/ntpd/keyword-gen.c	2015-05-13 17:39:08.889233906 +0200
2b78f7
@@ -173,6 +173,8 @@ struct key_tok ntp_keywords[] = {
2b78f7
 { "stats",		T_Stats,		FOLLBY_TOKEN },
2b78f7
 /* tinker_option */
2b78f7
 { "step",		T_Step,			FOLLBY_TOKEN },
2b78f7
+{ "stepback",		T_Stepback,		FOLLBY_TOKEN },
2b78f7
+{ "stepfwd",		T_Stepfwd,		FOLLBY_TOKEN },
2b78f7
 { "panic",		T_Panic,		FOLLBY_TOKEN },
2b78f7
 { "dispersion",		T_Dispersion,		FOLLBY_TOKEN },
2b78f7
 { "stepout",		T_Stepout,		FOLLBY_TOKEN },
2b78f7
diff -up ntp-4.2.6p5/ntpd/ntp_config.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_config.c
2b78f7
--- ntp-4.2.6p5/ntpd/ntp_config.c.backfwdstep	2015-05-13 17:07:13.534208748 +0200
2b78f7
+++ ntp-4.2.6p5/ntpd/ntp_config.c	2015-05-13 17:36:12.929319050 +0200
2b78f7
@@ -2407,6 +2407,14 @@ config_tinker(
2b78f7
 			item = LOOP_MAX;
2b78f7
 			break;
2b78f7
 
2b78f7
+		case T_Stepback:
2b78f7
+			item = LOOP_MAX_BACK;
2b78f7
+			break;
2b78f7
+
2b78f7
+		case T_Stepfwd:
2b78f7
+			item = LOOP_MAX_FWD;
2b78f7
+			break;
2b78f7
+
2b78f7
 		case T_Stepout:
2b78f7
 			item = LOOP_MINSTEP;
2b78f7
 			break;
2b78f7
diff -up ntp-4.2.6p5/ntpd/ntp_loopfilter.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_loopfilter.c
2b78f7
--- ntp-4.2.6p5/ntpd/ntp_loopfilter.c.backfwdstep	2015-05-13 17:07:13.499212146 +0200
2b78f7
+++ ntp-4.2.6p5/ntpd/ntp_loopfilter.c	2015-05-13 17:20:42.362674093 +0200
2b78f7
@@ -107,7 +107,8 @@
2b78f7
 /*
2b78f7
  * Program variables that can be tinkered.
2b78f7
  */
2b78f7
-double	clock_max = CLOCK_MAX;	/* step threshold */
2b78f7
+double	clock_max_back = CLOCK_MAX;	/* step threshold */
2b78f7
+double	clock_max_fwd =  CLOCK_MAX;	/* step threshold */
2b78f7
 double	clock_minstep = CLOCK_MINSTEP; /* stepout threshold */
2b78f7
 double	clock_panic = CLOCK_PANIC; /* panic threshold */
2b78f7
 double	clock_phi = CLOCK_PHI;	/* dispersion rate (s/s) */
2b78f7
@@ -257,7 +258,8 @@ local_clock(
2b78f7
 	 * directly to the terminal.
2b78f7
 	 */
2b78f7
 	if (mode_ntpdate) {
2b78f7
-		if (fabs(fp_offset) > clock_max && clock_max > 0) {
2b78f7
+		if (  ( fp_offset > clock_max_fwd  && clock_max_fwd  > 0)
2b78f7
+		   || (-fp_offset > clock_max_back && clock_max_back > 0)) {
2b78f7
 			step_systime(fp_offset);
2b78f7
 			msyslog(LOG_NOTICE, "ntpd: time set %+.6f s",
2b78f7
 	   		    fp_offset);
2b78f7
@@ -319,7 +321,8 @@ local_clock(
2b78f7
 	mu = current_time - clock_epoch;
2b78f7
 	clock_frequency = drift_comp;
2b78f7
 	rval = 1;
2b78f7
-	if (fabs(fp_offset) > clock_max && clock_max > 0) {
2b78f7
+	if (  ( fp_offset > clock_max_fwd  && clock_max_fwd  > 0)
2b78f7
+	   || (-fp_offset > clock_max_back && clock_max_back > 0)) {
2b78f7
 		switch (state) {
2b78f7
 
2b78f7
 		/*
2b78f7
@@ -1007,8 +1010,20 @@ loop_config(
2b78f7
 		break;
2b78f7
 
2b78f7
 	case LOOP_MAX:		/* step threshold (step) */
2b78f7
-		clock_max = freq;
2b78f7
-		if (clock_max == 0 || clock_max > 0.5)
2b78f7
+		clock_max_fwd = clock_max_back = freq;
2b78f7
+		if (freq == 0 || freq > 0.5)
2b78f7
+			kern_enable = 0;
2b78f7
+		break;
2b78f7
+
2b78f7
+	case LOOP_MAX_BACK:	/* step threshold (step) */
2b78f7
+		clock_max_back = freq;
2b78f7
+		if (freq == 0 || freq > 0.5)
2b78f7
+			kern_enable = 0;
2b78f7
+		break;
2b78f7
+
2b78f7
+	case LOOP_MAX_FWD:	/* step threshold (step) */
2b78f7
+		clock_max_fwd = freq;
2b78f7
+		if (freq == 0 || freq > 0.5)
2b78f7
 			kern_enable = 0;
2b78f7
 		break;
2b78f7
 
2b78f7
diff -up ntp-4.2.6p5/ntpd/ntp_parser.y.backfwdstep ntp-4.2.6p5/ntpd/ntp_parser.y
2b78f7
--- ntp-4.2.6p5/ntpd/ntp_parser.y.backfwdstep	2010-10-24 08:29:35.000000000 +0200
2b78f7
+++ ntp-4.2.6p5/ntpd/ntp_parser.y	2015-05-13 17:40:45.207881673 +0200
2b78f7
@@ -190,6 +190,8 @@
2b78f7
 %token	<Integer>	T_Stats
2b78f7
 %token	<Integer>	T_Statsdir
2b78f7
 %token	<Integer>	T_Step
2b78f7
+%token	<Integer>	T_Stepback
2b78f7
+%token	<Integer>	T_Stepfwd
2b78f7
 %token	<Integer>	T_Stepout
2b78f7
 %token	<Integer>	T_Stratum
2b78f7
 %token	<String>	T_String
2b78f7
@@ -899,6 +901,8 @@ tinker_option_keyword
2b78f7
 	|	T_Huffpuff
2b78f7
 	|	T_Panic
2b78f7
 	|	T_Step
2b78f7
+	|	T_Stepback
2b78f7
+	|	T_Stepfwd
2b78f7
 	|	T_Stepout
2b78f7
 	;
2b78f7
 
2b78f7
diff -up ntp-4.2.6p5/ntpd/ntp_timer.c.backfwdstep ntp-4.2.6p5/ntpd/ntp_timer.c
2b78f7
--- ntp-4.2.6p5/ntpd/ntp_timer.c.backfwdstep	2015-05-13 17:07:13.554206806 +0200
2b78f7
+++ ntp-4.2.6p5/ntpd/ntp_timer.c	2015-05-13 17:27:45.659573319 +0200
2b78f7
@@ -450,7 +450,7 @@ timer(void)
2b78f7
 			sys_tai = leap_tai;
2b78f7
 #ifdef KERNEL_PLL
2b78f7
 			if (!pll_control || !kern_enable) {
2b78f7
-				if (clock_max < 1.0 && clock_max > 0.0) {
2b78f7
+				if (clock_max_back < 1.0 && clock_max_back > 0.0) {
2b78f7
 					step_systime(-1.0);
2b78f7
 					msyslog(LOG_NOTICE, "Inserting positive leap second");
2b78f7
 				} else {