Advertisement
Guest User

Untitled

a guest
May 31st, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.63 KB | None | 0 0
  1. Only in openntpd-3.9p1.old: configure
  2. diff -ur --unidirectional-new-file openntpd-3.9p1.old/configure.ac openntpd-3.9p1/configure.ac
  3. --- openntpd-3.9p1.old/configure.ac 2006-05-14 07:29:23.000000000 +0200
  4. +++ openntpd-3.9p1/configure.ac 2008-02-07 13:13:18.066366142 +0100
  5. @@ -583,6 +583,11 @@
  6. [ builtin_arc4random=$withval ]
  7. )
  8.  
  9. +AC_ARG_WITH(adjtimex,
  10. + [ --with-adjtimex Use adjtimex to adjust kernel skew],
  11. + [ AC_DEFINE(USE_ADJTIMEX, [], [Use adjust skew with adjtimex (experimental)]) ]
  12. + )
  13. +
  14. AC_ARG_WITH(mantype,
  15. [ --with-mantype=man|cat|doc Set man page type],
  16. [
  17. diff -ur --unidirectional-new-file openntpd-3.9p1.old/defines.h openntpd-3.9p1/defines.h
  18. --- openntpd-3.9p1.old/defines.h 2006-05-14 07:29:21.000000000 +0200
  19. +++ openntpd-3.9p1/defines.h 2008-02-07 13:14:34.488711868 +0100
  20. @@ -20,6 +20,10 @@
  21. # define setproctitle(x)
  22. #endif
  23.  
  24. +#ifdef USE_ADJTIMEX
  25. +# define adjtime(a,b) (_compat_adjtime((a),(b)))
  26. +#endif
  27. +
  28. #if !defined(SA_LEN)
  29. # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN)
  30. # define SA_LEN(x) ((x)->sa_len)
  31. Only in openntpd-3.9p1.old: ntpd.0
  32. Only in openntpd-3.9p1.old: ntpd.conf.0
  33. diff -ur --unidirectional-new-file openntpd-3.9p1.old/openbsd-compat/Makefile.in openntpd-3.9p1/openbsd-compat/Makefile.in
  34. --- openntpd-3.9p1.old/openbsd-compat/Makefile.in 2006-05-14 07:29:19.000000000 +0200
  35. +++ openntpd-3.9p1/openbsd-compat/Makefile.in 2008-02-07 13:31:39.499728930 +0100
  36. @@ -9,7 +9,7 @@
  37. COMPAT= atomicio.o bsd-arc4random.o bsd-misc.o bsd-poll.o \
  38. bsd-snprintf.o bsd-getifaddrs.o bsd-setresuid.o \
  39. bsd-setresgid.o fake-rfc2553.o
  40. -PORT= port-qnx.o
  41. +PORT= port-linux.o port-qnx.o
  42.  
  43. VPATH=@srcdir@
  44. CC=@CC@
  45. diff -ur --unidirectional-new-file openntpd-3.9p1.old/openbsd-compat/openbsd-compat.h openntpd-3.9p1/openbsd-compat/openbsd-compat.h
  46. --- openntpd-3.9p1.old/openbsd-compat/openbsd-compat.h 2006-05-14 07:29:19.000000000 +0200
  47. +++ openntpd-3.9p1/openbsd-compat/openbsd-compat.h 2008-02-07 13:17:00.272366764 +0100
  48. @@ -46,6 +46,11 @@
  49. __attribute__((__format__ (printf, 2, 3)));
  50. #endif
  51.  
  52. +#ifdef USE_ADJTIMEX
  53. +# include <sys/time.h>
  54. +int _compat_adjtime(const struct timeval *, struct timeval *);
  55. +#endif
  56. +
  57. #ifndef HAVE_INET_PTON
  58. int inet_pton(int, const char *, void *);
  59. #endif
  60. diff -ur --unidirectional-new-file openntpd-3.9p1.old/openbsd-compat/port-linux.c openntpd-3.9p1/openbsd-compat/port-linux.c
  61. --- openntpd-3.9p1.old/openbsd-compat/port-linux.c 1970-01-01 01:00:00.000000000 +0100
  62. +++ openntpd-3.9p1/openbsd-compat/port-linux.c 2008-02-07 13:24:43.800366563 +0100
  63. @@ -0,0 +1,105 @@
  64. +
  65. +
  66. +/*
  67. + * Copyright (c) 2004 Darren Tucker <dtucker at zip com au>
  68. + *
  69. + * Permission to use, copy, modify, and distribute this software for any
  70. + * purpose with or without fee is hereby granted, provided that the above
  71. + * copyright notice and this permission notice appear in all copies.
  72. + *
  73. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  74. + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  75. + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  76. + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  77. + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  78. + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  79. + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  80. + */
  81. +
  82. +#include "includes.h"
  83. +
  84. +#ifdef USE_ADJTIMEX
  85. +#include <sys/timex.h>
  86. +#include <errno.h>
  87. +#ifdef adjtime
  88. +# undef adjtime
  89. +#endif
  90. +
  91. +#include "ntpd.h"
  92. +
  93. +/* scale factor used by adjtimex freq param. 1 ppm = 65536 */
  94. +#define ADJTIMEX_FREQ_SCALE 65536
  95. +
  96. +/* maximum change to skew per adjustment, in PPM */
  97. +#define MAX_SKEW_DELTA 5.0
  98. +
  99. +int
  100. +_compat_adjtime(const struct timeval *delta, struct timeval *olddelta)
  101. +{
  102. + static struct timeval tlast = {0,0};
  103. + static double tskew = 0;
  104. + static int synced = -1;
  105. + struct timeval tnow, tdelta;
  106. + double skew = 0, newskew, deltaskew, adjust, interval = 0;
  107. + struct timex tmx;
  108. + int result, saved_errno;
  109. +
  110. + gettimeofday(&tnow, NULL);
  111. + adjust = (double)delta->tv_sec;
  112. + adjust += (double)delta->tv_usec / 1000000;
  113. +
  114. + /* Even if the caller doesn't care about the olddelta, we do */
  115. + if (olddelta == NULL)
  116. + olddelta = &tdelta;
  117. +
  118. + result = adjtime(delta, olddelta);
  119. + saved_errno = errno;
  120. +
  121. + if (olddelta->tv_sec == 0 && olddelta->tv_usec == 0 &&
  122. + synced != INT_MAX)
  123. + synced++;
  124. + else
  125. + synced = 0;
  126. +
  127. + /*
  128. + * do skew calculations if we have synced
  129. + */
  130. + if (synced == 0 ) {
  131. + tmx.modes = 0;
  132. + if (adjtimex(&tmx) == -1)
  133. + log_warn("adjtimex get failed");
  134. + else
  135. + tskew = (double)tmx.freq / ADJTIMEX_FREQ_SCALE;
  136. + } else if (synced >= 1) {
  137. + interval = (double)(tnow.tv_sec - tlast.tv_sec);
  138. + interval += (double)(tnow.tv_usec - tlast.tv_usec) / 1000000;
  139. +
  140. + skew = (adjust * 1000000) / interval;
  141. + newskew = ((tskew * synced) + skew) / synced;
  142. + deltaskew = newskew - tskew;
  143. +
  144. + if (deltaskew > MAX_SKEW_DELTA) {
  145. + log_info("skew change %0.3lf exceeds limit", deltaskew);
  146. + tskew += MAX_SKEW_DELTA;
  147. + } else if (deltaskew < -MAX_SKEW_DELTA) {
  148. + log_info("skew change %0.3lf exceeds limit", deltaskew);
  149. + tskew -= MAX_SKEW_DELTA;
  150. + } else {
  151. + tskew = newskew;
  152. + }
  153. +
  154. + /* Adjust the kernel skew. */
  155. + tmx.freq = (long)(tskew * ADJTIMEX_FREQ_SCALE);
  156. + tmx.modes = ADJ_FREQUENCY;
  157. + if (adjtimex(&tmx) == -1)
  158. + log_warn("adjtimex set freq failed");
  159. + }
  160. +
  161. + log_debug("interval %0.3lf skew %0.3lf total skew %0.3lf", interval,
  162. + skew, tskew);
  163. +
  164. + tlast = tnow;
  165. + errno = saved_errno;
  166. + return result;
  167. +}
  168. +#endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement