dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
Zbigniew Jędrzejewski-Szmek 62fe94
From 487a36821ea214a73e1d0dcbd6d84123b50d1135 Mon Sep 17 00:00:00 2001
Michal Schmidt d962ba
From: Miroslav Lichvar <mlichvar@redhat.com>
Michal Schmidt d962ba
Date: Wed, 27 Aug 2014 16:47:19 +0200
Zbigniew Jędrzejewski-Szmek 62fe94
Subject: [PATCH] timesyncd: get kernel timestamp in nanoseconds
Michal Schmidt d962ba
Michal Schmidt d962ba
---
Michal Schmidt d962ba
 src/timesync/timesyncd-manager.c | 14 +++++---------
Michal Schmidt d962ba
 1 file changed, 5 insertions(+), 9 deletions(-)
Michal Schmidt d962ba
Michal Schmidt d962ba
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
Zbigniew Jędrzejewski-Szmek 62fe94
index 333960669c..2b0580cf01 100644
Michal Schmidt d962ba
--- a/src/timesync/timesyncd-manager.c
Michal Schmidt d962ba
+++ b/src/timesync/timesyncd-manager.c
Michal Schmidt d962ba
@@ -136,10 +136,6 @@ static double ts_to_d(const struct timespec *ts) {
Michal Schmidt d962ba
         return ts->tv_sec + (1.0e-9 * ts->tv_nsec);
Michal Schmidt d962ba
 }
Michal Schmidt d962ba
 
Michal Schmidt d962ba
-static double tv_to_d(const struct timeval *tv) {
Michal Schmidt d962ba
-        return tv->tv_sec + (1.0e-6 * tv->tv_usec);
Michal Schmidt d962ba
-}
Michal Schmidt d962ba
-
Michal Schmidt d962ba
 static double square(double d) {
Michal Schmidt d962ba
         return d * d;
Michal Schmidt d962ba
 }
Michal Schmidt d962ba
@@ -500,7 +496,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
Michal Schmidt d962ba
                 .msg_namelen = sizeof(server_addr),
Michal Schmidt d962ba
         };
Michal Schmidt d962ba
         struct cmsghdr *cmsg;
Michal Schmidt d962ba
-        struct timeval *recv_time;
Michal Schmidt d962ba
+        struct timespec *recv_time;
Michal Schmidt d962ba
         ssize_t len;
Michal Schmidt d962ba
         double origin, receive, trans, dest;
Michal Schmidt d962ba
         double delay, offset;
Michal Schmidt d962ba
@@ -543,8 +539,8 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
Michal Schmidt d962ba
                         continue;
Michal Schmidt d962ba
 
Michal Schmidt d962ba
                 switch (cmsg->cmsg_type) {
Michal Schmidt d962ba
-                case SCM_TIMESTAMP:
Michal Schmidt d962ba
-                        recv_time = (struct timeval *) CMSG_DATA(cmsg);
Michal Schmidt d962ba
+                case SCM_TIMESTAMPNS:
Michal Schmidt d962ba
+                        recv_time = (struct timespec *) CMSG_DATA(cmsg);
Michal Schmidt d962ba
                         break;
Michal Schmidt d962ba
                 }
Michal Schmidt d962ba
         }
Michal Schmidt d962ba
@@ -615,7 +611,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
Michal Schmidt d962ba
         origin = ts_to_d(&m->trans_time) + OFFSET_1900_1970;
Michal Schmidt d962ba
         receive = ntp_ts_to_d(&ntpmsg.recv_time);
Michal Schmidt d962ba
         trans = ntp_ts_to_d(&ntpmsg.trans_time);
Michal Schmidt d962ba
-        dest = tv_to_d(recv_time) + OFFSET_1900_1970;
Michal Schmidt d962ba
+        dest = ts_to_d(recv_time) + OFFSET_1900_1970;
Michal Schmidt d962ba
 
Michal Schmidt d962ba
         offset = ((receive - origin) + (trans - dest)) / 2;
Michal Schmidt d962ba
         delay = (dest - origin) - (trans - receive);
Michal Schmidt d962ba
@@ -697,7 +693,7 @@ static int manager_listen_setup(Manager *m) {
Michal Schmidt d962ba
         if (r < 0)
Michal Schmidt d962ba
                 return -errno;
Michal Schmidt d962ba
 
Michal Schmidt d962ba
-        r = setsockopt(m->server_socket, SOL_SOCKET, SO_TIMESTAMP, &on, sizeof(on));
Michal Schmidt d962ba
+        r = setsockopt(m->server_socket, SOL_SOCKET, SO_TIMESTAMPNS, &on, sizeof(on));
Michal Schmidt d962ba
         if (r < 0)
Michal Schmidt d962ba
                 return -errno;
Michal Schmidt d962ba