From a8886603c2472e3f137ceed7b553682225a5e71d Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Mon, 22 Aug 2016 13:14:45 +0200 Subject: [PATCH] ntp: fix processing of kernel timestamps on non-Linux systems When the SO_TIMESTAMP socket option was enabled, the expected type of control messages containing timestamps was SO_TIMESTAMP instead of SCM_TIMESTAMP. This worked on Linux, where the two values are equal, but not on the other supported systems. The timestamps were ignored and this probably worsened the accuracy and stability of the synchronisation. --- ntp_io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ntp_io.c b/ntp_io.c index ab220b5..af5158f 100644 --- a/ntp_io.c +++ b/ntp_io.c @@ -593,8 +593,8 @@ process_receive(struct msghdr *hdr, int length, int sock_fd) } #endif -#ifdef SO_TIMESTAMP - if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) { +#ifdef SCM_TIMESTAMP + if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMP) { struct timeval tv; struct timespec ts; @@ -604,8 +604,8 @@ process_receive(struct msghdr *hdr, int length, int sock_fd) } #endif -#ifdef SO_TIMESTAMPNS - if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMPNS) { +#ifdef SCM_TIMESTAMPNS + if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_TIMESTAMPNS) { struct timespec ts; memcpy(&ts, CMSG_DATA(cmsg), sizeof (ts));