| [chrony-dev] [RFC PATCH v1 07/17] socket: Ignore the kernel system timestamp read from the socket |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
- To: chrony-dev@xxxxxxxxxxxxxxxxxxxx
- Subject: [chrony-dev] [RFC PATCH v1 07/17] socket: Ignore the kernel system timestamp read from the socket
- From: Christopher S M Hall <christopher.s.hall@xxxxxxxxx>
- Date: Sat, 6 Dec 2025 06:10:53 +0000
- Cc: christopher.s.hall@xxxxxxxxx, david.zage@xxxxxxxxx, yoong.siang.song@xxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765002154; x=1796538154; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gobJhBGPyEmvVfa7FrGzHzlyaiL60YsJIwEiCowbwOY=; b=lrqBqXRlyI7TLoxSZIeBEEaE5fDEBp8KqKTK72ySRprOH8912vVG9AOt NOJG8DraK4ggvy5yp4PwgJgSR3wr5kZE6UzD03Lggh0g9X2YxKaAnJLVw dmGBn5NRDz+WAZQMbmAqEwJ8Dat3RJAODBUoVuDIzDJ+5BtsoofvrNYPA lAH3/fCTasJbybGcxvSs1UiU1Nwe9VYrP+tmqauJFnPP45JGPRpTdHn17 AvolZ0NyjCbVw22r9sLpkJbnnUczXfiSm3df8CQg0RFiGqWjp2sb4OZ2q iwFnV1/Zbm7rJT/kuwrm/vkwwoVNJ/DLckKqXa8cMPFdgP0amHuNg0IZC w==;
The kernel system timestamp read from the socket is captured by the kernel rather the network device.
Linux does not currently support kernel timestamps on the socket using auxiliary clocks. The implementation
would be non-trivial. For now, set the kernel timestamp to zero. The code in ntp_io.c and ntp_io_linux.c
both check for a zero valued kernel timestamp and ignore it.
A default implementation of CNF_GetAuxClockId() is provided for the build of the client which does not include
conf.o. The function is/should never be called, but results in a fatal error if it is.
---
socket.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/socket.c b/socket.c
index ed80d0b..c73001b 100644
--- a/socket.c
+++ b/socket.c
@@ -47,6 +47,7 @@
#include "privops.h"
#include "ptp.h"
#include "util.h"
+#include "conf.h"
#define INVALID_SOCK_FD (-4)
#define CMSG_BUF_SIZE 256
@@ -114,6 +115,15 @@ static unsigned int received_messages;
static int (*priv_bind_function)(int sock_fd, struct sockaddr *address,
socklen_t address_len);
+#ifdef FEAT_AUXCLOCK
+__attribute__((weak)) const int *CNF_GetAuxClockId()
+{
+ LOG_FATAL("Link error: conf.o must be linked to use the provided "
+ "%s implementation", __FUNCTION__);
+ return NULL;
+}
+#endif
+
/* ================================================== */
static void
@@ -1010,7 +1020,15 @@ process_header(struct msghdr *msg, int msg_length, int sock_fd, int flags,
struct scm_timestamping ts3;
memcpy(&ts3, CMSG_DATA(cmsg), sizeof (ts3));
- message->timestamp.kernel = ts3.ts[0];
+#ifdef FEAT_AUXCLOCK
+ /* If we're using an auxiliary clock, kernel socket timestamping is not currently supported */
+ if (CNF_GetAuxClockId()) {
+ message->timestamp.kernel = (struct timespec){0,0};
+ } else
+#endif
+ {
+ message->timestamp.kernel = ts3.ts[0];
+ }
message->timestamp.hw = ts3.ts[2];
}
else if ((match_cmsg(cmsg, SOL_IP, IP_RECVERR, 0) ||
--
2.34.1
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.