]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: compare receive timestamp when checking for duplicate
authorMiroslav Lichvar <mlichvar@redhat.com>
Fri, 23 Feb 2018 13:17:07 +0000 (14:17 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 26 Feb 2018 12:42:04 +0000 (13:42 +0100)
Compare both receive and transmit timestamps in the NTP test number 1.

This prevents a client from dropping a valid response in the interleaved
mode if it follows a response in the basic mode and the server did not
have a kernel/hardware transmit timestamp, and the random bits of the
two timestamps happen to be the same (chance of 1 in 2^(32-precision)).

ntp_core.c

index 6d5b8576e082fba49c62343ffcf85f39ce9be94f..0b4ce90f355a051f0c9c025aa8e84b0e30fc17b1 100644 (file)
@@ -1495,7 +1495,8 @@ receive_packet(NCR_Instance inst, NTP_Local_Address *local_addr,
      The test values are 1 when passed and 0 when failed. */
   
   /* Test 1 checks for duplicate packet */
-  test1 = !!UTI_CompareNtp64(&message->transmit_ts, &inst->remote_ntp_tx);
+  test1 = UTI_CompareNtp64(&message->receive_ts, &inst->remote_ntp_rx) ||
+          UTI_CompareNtp64(&message->transmit_ts, &inst->remote_ntp_tx);
 
   /* Test 2 checks for bogus packet in the basic and interleaved modes.  This
      ensures the source is responding to the latest packet we sent to it. */