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.0 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. From e6dac416156382be9065c684cd17de03e6695175 Mon Sep 17 00:00:00 2001
  2. From: Brent Cook <bcook@openbsd.org>
  3. Date: Sun, 6 Dec 2015 22:35:38 -0600
  4. Subject: [PATCH 11/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. ---
  8. src/usr.sbin/ntpd/client.c | 10 +++++++++-
  9. 1 file changed, 9 insertions(+), 1 deletion(-)
  10. diff --git a/src/usr.sbin/ntpd/client.c b/src/usr.sbin/ntpd/client.c
  11. index 3d70317..5619454 100644
  12. --- a/src/usr.sbin/ntpd/client.c
  13. +++ b/src/usr.sbin/ntpd/client.c
  14. @@ -163,10 +163,12 @@ client_query(struct ntp_peer *p)
  15. if (p->addr->ss.ss_family == AF_INET && setsockopt(p->query->fd,
  16. IPPROTO_IP, IP_TOS, &val, sizeof(val)) == -1)
  17. log_warn("setsockopt IPTOS_LOWDELAY");
  18. +#ifdef SO_TIMESTAMP
  19. val = 1;
  20. if (setsockopt(p->query->fd, SOL_SOCKET, SO_TIMESTAMP,
  21. &val, sizeof(val)) == -1)
  22. fatal("setsockopt SO_TIMESTAMP");
  23. +#endif
  24. }
  25. /*
  26. @@ -213,7 +215,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  27. struct cmsghdr hdr;
  28. char buf[CMSG_SPACE(sizeof(tv))];
  29. } cmsgbuf;
  30. +#ifdef SO_TIMESTAMP
  31. struct cmsghdr *cmsg;
  32. +#endif
  33. ssize_t size;
  34. double T1, T2, T3, T4;
  35. time_t interval;
  36. @@ -226,7 +230,6 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  37. somsg.msg_control = cmsgbuf.buf;
  38. somsg.msg_controllen = sizeof(cmsgbuf.buf);
  39. - T4 = getoffset();
  40. if ((size = recvmsg(p->query->fd, &somsg, 0)) == -1) {
  41. if (errno == EHOSTUNREACH || errno == EHOSTDOWN ||
  42. errno == ENETUNREACH || errno == ENETDOWN ||
  43. @@ -251,6 +254,8 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  44. return (0);
  45. }
  46. +#ifdef SO_TIMESTAMP
  47. + T4 = getoffset();
  48. for (cmsg = CMSG_FIRSTHDR(&somsg); cmsg != NULL;
  49. cmsg = CMSG_NXTHDR(&somsg, cmsg)) {
  50. if (cmsg->cmsg_level == SOL_SOCKET &&
  51. @@ -260,6 +265,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime)
  52. break;
  53. }
  54. }
  55. +#else
  56. + T4 = gettime_corrected();
  57. +#endif
  58. if (T4 < JAN_1970) {
  59. client_log_error(p, "recvmsg control format", EBADF);
  60. --
  61. 2.10.1