]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: change auto_offline to trigger on failed transmissions
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 24 May 2018 15:29:15 +0000 (17:29 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 25 May 2018 08:53:21 +0000 (10:53 +0200)
Instead of counting missing responses, switch to the offline state
immediately when sendmsg() fails.

This makes the option usable with servers and networks that may drop
packets, and the effect will be consistent with the onoffline command.

doc/chrony.conf.adoc
ntp_core.c

index be39a27e76cc9be23a4c7345308660b91863100e..a1875704e37d51c0e6bc9d8a2311d057f2d6fe8e 100644 (file)
@@ -164,13 +164,12 @@ option can be specified. *chronyd* will not try to poll the server until it is
 enabled to do so (by using the <<chronyc.adoc#online,*online*>> command in
 *chronyc*).
 *auto_offline*:::
-With this option, the server will be assumed to have gone offline when two
-requests have been sent to it without receiving a response. This option avoids
+With this option, the server will be assumed to have gone offline when sending
+a request fails, e.g. due to a missing route to the network. This option avoids
 the need to run the <<chronyc.adoc#offline,*offline*>> command from *chronyc*
-when disconnecting the network link, if it is safe to assume that the requests
-and responses will not be dropped in the network, e.g. in a trusted local
-network. (It will still be necessary to use the <<chronyc.adoc#online,*online*>>
-command when the link has been established, to enable measurements to start.)
+when disconnecting the network link. (It will still be necessary to use the
+<<chronyc.adoc#online,*online*>> command when the link has been established, to
+enable measurements to start.)
 *prefer*:::
 Prefer this source over sources without the *prefer* option.
 *noselect*:::
index c9d096972bb6edf2e867b482d1c7d39b0770c227..991e3d9be80f714c653658d9450ac71aed995e8a 100644 (file)
@@ -89,8 +89,8 @@ struct NCR_Instance_Record {
   int tx_suspended;             /* Boolean indicating we can't transmit yet */
 
   int auto_burst;               /* If 1, initiate a burst on each poll */
-  int auto_offline;             /* If 1, automatically go offline if server/peer
-                                   isn't responding */
+  int auto_offline;             /* If 1, automatically go offline when requests
+                                   cannot be sent */
 
   int local_poll;               /* Log2 of polling interval at our end */
   int remote_poll;              /* Log2 of server/peer's polling interval (recovered
@@ -1143,10 +1143,6 @@ transmit_timeout(void *arg)
       break;
   }
 
-  /* With auto_offline take the source offline on 2nd missed reply */
-  if (inst->auto_offline && inst->tx_count >= 2)
-    NCR_SetConnectivity(inst, SRC_OFFLINE);
-
   if (inst->opmode == MD_OFFLINE) {
     return;
   }
@@ -1230,6 +1226,10 @@ transmit_timeout(void *arg)
     SRC_UpdateReachability(inst->source, 0);
   }
 
+  /* With auto_offline take the source offline if sending failed */
+  if (!sent && inst->auto_offline)
+    NCR_SetConnectivity(inst, SRC_OFFLINE);
+
   switch (inst->opmode) {
     case MD_BURST_WAS_ONLINE:
       /* When not reachable, don't stop online burst until sending succeeds */
@@ -1239,6 +1239,8 @@ transmit_timeout(void *arg)
     case MD_BURST_WAS_OFFLINE:
       --inst->burst_total_samples_to_go;
       break;
+    case MD_OFFLINE:
+      return;
     default:
       break;
   }