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

3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
  1. From 6724771a5f732d7317862379ca1b285cfc7b0635 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/18] 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 98a1eb5825..9dc131a11e 100644
  12. --- a/src/usr.sbin/ntpd/client.c
  13. +++ b/src/usr.sbin/ntpd/client.c
  14. @@ -193,10 +193,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. @@ -283,7 +285,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
  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. @@ -296,7 +300,6 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
  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. @@ -321,6 +324,8 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
  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. @@ -330,6 +335,9 @@ client_dispatch(struct ntp_peer *p, u_int8_t settime, u_int8_t automatic)
  52. break;
  53. }
  54. }
  55. +#else
  56. + T4 = gettime_corrected();
  57. +#endif
  58. ntp_getmsg((struct sockaddr *)&p->addr->ss, buf, size, &msg);
  59. --
  60. 2.27.0