]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: delay enabling permanent kernel RX timestamping on Linux
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 2 Mar 2018 10:49:53 +0000 (11:49 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Fri, 2 Mar 2018 12:03:26 +0000 (13:03 +0100)
Wait until a kernel RX timestamp is actually missing before opening the
dummy socket in order to avoid a small performance impact in case the
servers are so slow/distant that the kernel can constantly win the race.

ntp_io_linux.c

index eb437e37064f15c29546e58e1a4d0020f72a54a2..c44a13bed9beba0e5a77f15d201f8365650ed29c 100644 (file)
@@ -397,9 +397,7 @@ NIO_Linux_Initialise(void)
 
   monitored_socket = INVALID_SOCK_FD;
   suspended_socket = INVALID_SOCK_FD;
-
-  /* Open a socket to keep the kernel RX timestamping permanently enabled */
-  dummy_rxts_socket = open_dummy_socket();
+  dummy_rxts_socket = INVALID_SOCK_FD;
 }
 
 /* ================================================== */
@@ -763,6 +761,14 @@ NIO_Linux_ProcessMessage(NTP_Remote_Address *remote_addr, NTP_Local_Address *loc
     }
   }
 
+  /* If the kernel is slow with enabling RX timestamping, open a dummy
+     socket to keep the kernel RX timestamping permanently enabled */
+  if (!is_tx && local_ts->source == NTP_TS_DAEMON && ts_flags) {
+    DEBUG_LOG("Missing kernel RX timestamp");
+    if (dummy_rxts_socket == INVALID_SOCK_FD)
+      dummy_rxts_socket = open_dummy_socket();
+  }
+
   /* Return the message if it's not received from the error queue */
   if (!is_tx)
     return 0;