]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: update NTP-over-PTP support
authorMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Jun 2024 07:31:31 +0000 (09:31 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 20 Jun 2024 12:35:28 +0000 (14:35 +0200)
Following the latest version of the draft, accept NTP messages in both
PTPv2 and PTPv2.1 messages, accept sync messages in addition to delay
request messages, and check the minorSdoId field in PTPv2.1 messages.

Transmitted messages are still PTPv2 delay requests.

Don't switch to the organization-specific TLV yet. Wait for the NTP TLV
subtype and Network Correction extension field to be assigned by IANA to
avoid an additional break in compatibility.

ntp_io.c
ptp.h

index ec2fd7b4f9644fc79e8dac122295b3efb397b24b..fc80aca21cb57de68286b3cae5abec3df39cef90 100644 (file)
--- a/ntp_io.c
+++ b/ntp_io.c
@@ -513,7 +513,9 @@ NIO_UnwrapMessage(SCK_Message *message, int sock_fd, double *net_correction)
 
   msg = message->data;
 
-  if (msg->header.type != PTP_TYPE_DELAY_REQ || msg->header.version != PTP_VERSION ||
+  if ((msg->header.type != PTP_TYPE_DELAY_REQ && msg->header.type != PTP_TYPE_SYNC) ||
+      (msg->header.version != PTP_VERSION_2 &&
+       (msg->header.version != PTP_VERSION_2_1 || msg->header.min_sdoid != 0)) ||
       ntohs(msg->header.length) != message->length ||
       msg->header.domain != PTP_DOMAIN_NTP ||
       ntohs(msg->header.flags) != PTP_FLAG_UNICAST ||
@@ -561,7 +563,7 @@ wrap_message(SCK_Message *message, int sock_fd)
 
   memset(ptp_message, 0, PTP_NTP_PREFIX_LENGTH);
   ptp_message->header.type = PTP_TYPE_DELAY_REQ;
-  ptp_message->header.version = PTP_VERSION;
+  ptp_message->header.version = PTP_VERSION_2;
   ptp_message->header.length = htons(PTP_NTP_PREFIX_LENGTH + message->length);
   ptp_message->header.domain = PTP_DOMAIN_NTP;
   ptp_message->header.flags = htons(PTP_FLAG_UNICAST);
diff --git a/ptp.h b/ptp.h
index 8034a2c6404918d56d225682a4d9281624adeab6..4330f4b359c37fb509a517fbe1ae7448338f52f2 100644 (file)
--- a/ptp.h
+++ b/ptp.h
@@ -31,7 +31,9 @@
 
 #include "ntp.h"
 
-#define PTP_VERSION 2
+#define PTP_VERSION_2 2
+#define PTP_VERSION_2_1 (2 | 1 << 4)
+#define PTP_TYPE_SYNC 0
 #define PTP_TYPE_DELAY_REQ 1
 #define PTP_DOMAIN_NTP 123
 #define PTP_FLAG_UNICAST (1 << (2 + 8))