5a725fc
From 355043d3d3778d4516ab410c7da461d53f0de0a9 Mon Sep 17 00:00:00 2001
5a725fc
From: Michal Schmidt <mschmidt@redhat.com>
5a725fc
Date: Wed, 10 Sep 2014 19:10:05 +0200
5a725fc
Subject: [PATCH] timesyncd: fix calculation of transmit time
5a725fc
5a725fc
Upstream commit:
5a725fc
commit 73c76e6330d31e1d04454fd7408dd56b4eedca9f
5a725fc
Author: Miroslav Lichvar <mlichvar@redhat.com>
5a725fc
Date:   Wed Aug 27 16:47:18 2014 +0200
5a725fc
5a725fc
    timesyncd: fix calculation of transmit time
5a725fc
5a725fc
    The kernel timestamp (recv_time) is made earlier than current time
5a725fc
    (now_ts), use the timestamp captured before sending packet directly.
5a725fc
---
5a725fc
 src/timesync/timesyncd.c | 4 +---
5a725fc
 1 file changed, 1 insertion(+), 3 deletions(-)
5a725fc
5a725fc
diff --git a/src/timesync/timesyncd.c b/src/timesync/timesyncd.c
5a725fc
index dc00b2f1f3..d123f0a3fc 100644
5a725fc
--- a/src/timesync/timesyncd.c
5a725fc
+++ b/src/timesync/timesyncd.c
5a725fc
@@ -565,7 +565,6 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
5a725fc
                 .msg_namelen = sizeof(server_addr),
5a725fc
         };
5a725fc
         struct cmsghdr *cmsg;
5a725fc
-        struct timespec now_ts;
5a725fc
         struct timeval *recv_time;
5a725fc
         ssize_t len;
5a725fc
         double origin, receive, trans, dest;
5a725fc
@@ -678,8 +677,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
5a725fc
          *  The round-trip delay, d, and system clock offset, t, are defined as:
5a725fc
          *  d = (T4 - T1) - (T3 - T2)     t = ((T2 - T1) + (T3 - T4)) / 2"
5a725fc
          */
5a725fc
-        assert_se(clock_gettime(clock_boottime_or_monotonic(), &now_ts) >= 0);
5a725fc
-        origin = tv_to_d(recv_time) - (ts_to_d(&now_ts) - ts_to_d(&m->trans_time_mon)) + OFFSET_1900_1970;
5a725fc
+        origin = ts_to_d(&m->trans_time) + OFFSET_1900_1970;
5a725fc
         receive = ntp_ts_to_d(&ntpmsg.recv_time);
5a725fc
         trans = ntp_ts_to_d(&ntpmsg.trans_time);
5a725fc
         dest = tv_to_d(recv_time) + OFFSET_1900_1970;