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.

70 lines
2.1 KiB

9 years ago
9 years ago
9 years ago
  1. From 90c47e06db660d4de455769fc291b1580a9f9414 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <bcook@openbsd.org>
  3. Date: Sat, 18 Jul 2015 01:14:55 -0500
  4. Subject: [PATCH 13/13] Deal with missing SO_TIMESTAMP
  5. from Paul B. Henson" <henson@acm.org>
  6. Fall back to the previous client.c implementation when it is not found.
  7. SO_TIMESTAMP was added in CVS rev 1.85 by henning@.
  8. ---
  9. src/usr.sbin/ntpd/client.c | 10 +++++++++-
  10. 1 file changed, 9 insertions(+), 1 deletion(-)
  11. diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c
  12. index 2be1f93..e2076f8 100644
  13. --- a/src/usr.sbin/ntpd/client.c
  14. +++ b/src/usr.sbin/ntpd/client.c
  15. @@ -169,10 +169,12 @@ client_query(struct ntp_peer *p)
  16. if (p->addr->ss.ss_family == AF_INET && setsockopt(p->query->fd,
  17. IPPROTO_IP, IP_TOS, &val, sizeof(val)) == -1)
  18. log_warn("setsockopt IPTOS_LOWDELAY");
  19. +#ifdef SO_TIMESTAMP
  20. val = 1;
  21. if (setsockopt(p->query->fd, SOL_SOCKET, SO_TIMESTAMP,
  22. &val, sizeof(val)) == -1)
  23. fatal("setsockopt SO_TIMESTAMP");
  24. +#endif
  25. }
  26. /*
  27. @@ -219,7 +221,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  28. struct cmsghdr hdr;
  29. char buf[CMSG_SPACE(sizeof(tv))];
  30. } cmsgbuf;
  31. +#ifdef SO_TIMESTAMP
  32. struct cmsghdr *cmsg;
  33. +#endif
  34. ssize_t size;
  35. double T1, T2, T3, T4;
  36. time_t interval;
  37. @@ -232,7 +236,6 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  38. somsg.msg_control = cmsgbuf.buf;
  39. somsg.msg_controllen = sizeof(cmsgbuf.buf);
  40. - T4 = getoffset();
  41. if ((size = recvmsg(p->query->fd, &somsg, 0)) == -1) {
  42. if (errno == EHOSTUNREACH || errno == EHOSTDOWN ||
  43. errno == ENETUNREACH || errno == ENETDOWN ||
  44. @@ -264,6 +267,8 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  45. fatal("client_dispatch setsockopt SO_RTABLE");
  46. #endif
  47. +#ifdef SO_TIMESTAMP
  48. + T4 = getoffset();
  49. for (cmsg = CMSG_FIRSTHDR(&somsg); cmsg != NULL;
  50. cmsg = CMSG_NXTHDR(&somsg, cmsg)) {
  51. if (cmsg->cmsg_level == SOL_SOCKET &&
  52. @@ -273,6 +278,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  53. break;
  54. }
  55. }
  56. +#else
  57. + T4 = gettime_corrected();
  58. +#endif
  59. if (T4 < JAN_1970) {
  60. client_log_error(p, "recvmsg control format", EBADF);
  61. --
  62. 2.4.5