PSARC 2015/278 NTP allow_step_at_boot s11u3-sru
authorBrian Utterback <brian.utterback@oracle.com>
Sun, 18 Oct 2015 17:18:21 -0700
branchs11u3-sru
changeset 5016 e7921135918b
parent 5015 2cbe8ea880ce
child 5024 10f6f5e98268
PSARC 2015/278 NTP allow_step_at_boot 21155469 NTP should update time at boot and shutdown
components/ntp/Solaris/ntp.sh
components/ntp/Solaris/ntp.xml
components/ntp/manpages/ntpd.1m
--- a/components/ntp/Solaris/ntp.sh	Sun Oct 18 17:18:20 2015 -0700
+++ b/components/ntp/Solaris/ntp.sh	Sun Oct 18 17:18:21 2015 -0700
@@ -21,7 +21,7 @@
 #
 
 #
-# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
 #
 
 # Standard prolog
@@ -52,7 +52,7 @@
 shift $#
 set -- -p /var/run/ntp.pid
 # We allow a step larger than the panic value of 17 minutes only 
-# once when ntpd starts up. If always_all_large_step is true, 
+# once when ntpd starts up. If always_allow_large_step is true, 
 # then we allow this each time ntpd starts. Otherwise, we allow
 # it only the very first time ntpd starts after a boot. We 
 # check that by making ntpd write its pid to a file in /var/run.
@@ -86,18 +86,31 @@
 
 # We used to support the slewalways keyword, but that was a Sun thing
 # and not in V4. Look for "slewalways yes" and set the new slew option.
-val=`svcprop -c -p config/slew_always $SMF_FMRI`
-if [ ! "$val" = "true" ]; then
-	val=`/usr/bin/nawk '/^[ \t]*#/{next}
+slew_always=`svcprop -c -p config/slew_always $SMF_FMRI`
+if [ ! "$slew_always" = "true" ]; then
+	slew_always=`/usr/bin/nawk '/^[ \t]*#/{next}
 	    /^[ \t]*slewalways[ \t]+yes/ {
         	printf("true", $2)
         	next } ' /etc/inet/ntp.conf`
 fi
-[ "$val" = "true" ] && set -- "$@" --slew
+[ "$slew_always" = "true" ] && set -- "$@" --slew
 
 # Set up debugging.
 deb=`svcprop -c -p config/debuglevel $SMF_FMRI`
 
+# If slew_always is set to true, then the large offset after a reboot
+# might take a very long time to correct the clock. Optionally allow
+# a step once after a reboot if slew_always is set when allow_step_at_boot
+# is also set. Unfortunately ntpd in ntpdate mode is a little too 
+# chatty, so direct the log to /dev/null. And since the offset might be
+# more than 17 minutes, allow larger steps with the "-g".
+#
+val=`svcprop -c -p config/allow_step_at_boot $SMF_FMRI`
+if [ "$val" = "true" ] && [ "$slew_always" = "true" ] && \
+    [ ! -f /var/run/ntp.pid ]; then
+	/usr/lib/inet/ntpd -q -l /dev/null -g
+fi
+
 # Start the daemon. If debugging is requested, put it in the background, 
 # since it won't do it on it's own.
 if [ "$deb" -gt 0 ]; then
--- a/components/ntp/Solaris/ntp.xml	Sun Oct 18 17:18:20 2015 -0700
+++ b/components/ntp/Solaris/ntp.xml	Sun Oct 18 17:18:21 2015 -0700
@@ -20,7 +20,7 @@
 
  CDDL HEADER END
 
- Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
 
  NOTE:  This service manifest is not editable; its contents will
  be overwritten by package or patch operations, including
@@ -35,7 +35,7 @@
 	type='service'
 	version='1'>
 	<single_instance />
-	<dependency 
+	<dependency
 		name='network'
 		grouping='require_any'
 		restart_on='error'
@@ -112,53 +112,58 @@
 	<instance name="default" enabled="false">
 		<property_group name='config' type='application' >
 			<!-- default property settings for ntpd(1M). -->
-		
+
 			<propval
 			    name='wait_for_sync'
 			    type='boolean'
 			    value='false' />
-		
+
 			<propval
 			    name='no_auth_required'
 			    type='boolean'
 			    value='false' />
-		
+
 			<propval
 			    name='verbose_logging'
 			    type='boolean'
 			    value='false' />
-	
+
 			<propval
 			    name='slew_always'
 			    type='boolean'
 			    value='false' />
-	
+
+			<propval
+			    name='allow_step_at_boot'
+			    type='boolean'
+			    value='true' />
+
 			<propval
 			    name='always_allow_large_step'
 			    type='boolean'
 			    value='true' />
-	
+
 			<propval
 			    name='logfile'
 			    type='astring'
 			    value='/var/ntp/ntp.log' />
-		
+
 			<propval
 			    name='debuglevel'
 			    type='integer'
 			    value='0' />
-	
+
 			<propval
 			    name='mdnsregister'
 			    type='boolean'
 			    value='false' />
-	
+
 			<!-- to change properties -->
 			<propval
 			    name='value_authorization'
 			    type='astring'
 			    value='solaris.smf.value.ntp' />
-		
+
 		</property_group>
 	</instance>
 	<stability value='Unstable' />
--- a/components/ntp/manpages/ntpd.1m	Sun Oct 18 17:18:20 2015 -0700
+++ b/components/ntp/manpages/ntpd.1m	Sun Oct 18 17:18:21 2015 -0700
@@ -18,7 +18,7 @@
 .\"
 .\" CDDL HEADER END
 .\"
-.\" Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
+.\" Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
 .\"
 .TH "ntpd" "1M" "" "" "System Administration Commands"
 .SH NAME
@@ -283,6 +283,13 @@
 does not prevent all stepping, but increases the threshold above which stepping is used. It also disables the use
 of the kernel \fBNTP\fP facility, which is incompatible with long slew times. The default is false.
 .TP
+.BR config/allow_step_at_boot
+A boolean which when true, allows ntpd to step the clock once at boot, even if slew_always is true. Normally
+when slew_always is true ntpd will not step the clock except for very large offsets. Since the intial offset
+when the system is booted could be large and no applications will be running yet, this option allows one step
+as soon as the offset is determined. If slew_always is false or if the \fBNTP\fP service is being restarted, then
+this option has no effect. The default is true.
+.TP
 .BR config/wait_for_sync
 A boolean which when true, causes the \fBNTP\fP service to delay coming completely on-line until after the first 
 time the system clock is synchronized. This can potetially delay the system start up by a significant amount. The