Portable build framework for OpenNTPD
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

69 lines
2.1 KiB

From 6724771a5f732d7317862379ca1b285cfc7b0635 Mon Sep 17 00:00:00 2001
From: Brent Cook <bcook@openbsd.org>
Date: Sun, 6 Dec 2015 22:35:38 -0600
Subject: [PATCH 11/18] Deal with missing SO_TIMESTAMP
from Paul B. Henson" <henson@acm.org>
Fall back to the previous client.c implementation when it is not found.
---
src/usr.sbin/ntpd/client.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c
index 98a1eb5825..9dc131a11e 100644
--- a/src/usr.sbin/ntpd/client.c
+++ b/src/usr.sbin/ntpd/client.c
@@ -193,10 +193,12 @@ client_query(struct ntp_peer *p)
if (p->addr->ss.ss_family == AF_INET && setsockopt(p->query->fd,
IPPROTO_IP, IP_TOS, &val, sizeof(val)) == -1)
log_warn("setsockopt IPTOS_LOWDELAY");
+#ifdef SO_TIMESTAMP
val = 1;
if (setsockopt(p->query->fd, SOL_SOCKET, SO_TIMESTAMP,
&val, sizeof(val)) == -1)
fatal("setsockopt SO_TIMESTAMP");
+#endif
}
/*
@@ -283,7 +285,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
struct cmsghdr hdr;
char buf[CMSG_SPACE(sizeof(tv))];
} cmsgbuf;
+#ifdef SO_TIMESTAMP
struct cmsghdr *cmsg;
+#endif
ssize_t size;
double T1, T2, T3, T4;
time_t interval;
@@ -296,7 +300,6 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
somsg.msg_control = cmsgbuf.buf;
somsg.msg_controllen = sizeof(cmsgbuf.buf);
- T4 = getoffset();
if ((size = recvmsg(p->query->fd, &somsg, 0)) == -1) {
if (errno == EHOSTUNREACH || errno == EHOSTDOWN ||
errno == ENETUNREACH || errno == ENETDOWN ||
@@ -321,6 +324,8 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
return (0);
}
+#ifdef SO_TIMESTAMP
+ T4 = getoffset();
for (cmsg = CMSG_FIRSTHDR(&somsg); cmsg != NULL;
cmsg = CMSG_NXTHDR(&somsg, cmsg)) {
if (cmsg->cmsg_level == SOL_SOCKET &&
@@ -330,6 +335,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
break;
}
}
+#else
+ T4 = gettime_corrected();
+#endif
ntp_getmsg((struct sockaddr *)&p->addr->ss, buf, size, &msg);
--
2.27.0