[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 ]


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.


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/