]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: check remote interval in client mode
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 4 Nov 2015 14:47:40 +0000 (15:47 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 16 Nov 2015 09:26:14 +0000 (10:26 +0100)
For testA in the client mode require also that the time the server
needed to process the client request is not longer than 4 seconds.
With maximum peer delay this limits the interval in which the client can
accept a server reply.

ntp_core.c

index bf24b36845615abf77fa8a8025b2051a0ee7355d..b869e429bbb91e4acd7ca73670ecc4a0b6137229 100644 (file)
@@ -215,6 +215,9 @@ static ARR_Instance broadcasts;
 /* Invalid stratum number */
 #define NTP_INVALID_STRATUM 0
 
+/* Maximum allowed time for server to process client packet */
+#define MAX_SERVER_INTERVAL 4.0
+
 /* Minimum and maximum allowed poll interval */
 #define MIN_POLL 0
 #define MAX_POLL 24
@@ -1265,9 +1268,10 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
     
     /* Additional tests required to pass before accumulating the sample */
 
-    /* Test A requires that the round trip delay is less than an
-       administrator-defined value */ 
-    testA = delay <= inst->max_delay;
+    /* Test A requires that the peer delay is not larger than the configured
+       maximum and in client mode also that the server processing time is sane */
+    testA = delay <= inst->max_delay &&
+            (inst->mode != MODE_CLIENT || remote_interval <= MAX_SERVER_INTERVAL);
 
     /* Test B requires that the ratio of the round trip delay to the
        minimum one currently in the stats data register is less than an