source:
freewrt/package/openntpd/patches/01-adjtimex_linux.patch@
475ad56
| Last change on this file since 475ad56 was 475ad56, checked in by , 20 years ago | |
|---|---|
|
|
| File size: 5.7 KB | |
-
openntpd-3.7p1
diff -urN openntpd-3.7p1.orig/client.c openntpd-3.7p1/client.c
old new 306 306 priv_adjtime(); 307 307 308 308 for (i = 0; i < OFFSET_ARRAY_SIZE; i++) 309 if (p->reply[i].rcvd <= p->reply[best].rcvd)309 /* if (p->reply[i].rcvd <= p->reply[best].rcvd) */ 310 310 p->reply[i].good = 0; 311 311 312 312 return (0); -
openntpd-3.7p1
diff -urN openntpd-3.7p1.orig/configure.ac openntpd-3.7p1/configure.ac
old new 466 466 [ builtin_arc4random=$withval ] 467 467 ) 468 468 469 AC_ARG_WITH(adjtimex, 470 [ --with-adjtimex Use adjtimex to adjust kernel skew], 471 [ AC_DEFINE(USE_ADJTIMEX, [], [Use adjust skew with adjtimex (experimental)]) ] 472 ) 473 469 474 # Search for OpenSSL if required. 470 475 if test "$ac_cv_func_arc4random" != "yes" && test "x$builtin_arc4random" != "xyes"; then 471 476 saved_CPPFLAGS="$CPPFLAGS" -
openntpd-3.7p1
diff -urN openntpd-3.7p1.orig/defines.h openntpd-3.7p1/defines.h
old new 20 20 # define setproctitle(x) 21 21 #endif 22 22 23 #ifdef USE_ADJTIMEX 24 # define adjtime(a,b) (_compat_adjtime((a),(b))) 25 #endif 26 23 27 #if !defined(SA_LEN) 24 28 # if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) 25 29 # define SA_LEN(x) ((x)->sa_len) -
openbsd-compat/Makefile.in
diff -urN openntpd-3.7p1.orig/openbsd-compat/Makefile.in openntpd-3.7p1/openbsd-compat/Makefile.in
old new 9 9 OPENBSD= asprintf.o daemon.o inet_pton.o strlcpy.o 10 10 COMPAT= atomicio.o bsd-arc4random.o bsd-misc.o bsd-poll.o \ 11 11 bsd-snprintf.o fake-rfc2553.o uidswap.o 12 PORT= port- qnx.o12 PORT= port-linux.o port-qnx.o 13 13 14 14 VPATH=@srcdir@ 15 15 CC=@CC@ -
openbsd-compat/openbsd-compat.h
diff -urN openntpd-3.7p1.orig/openbsd-compat/openbsd-compat.h openntpd-3.7p1/openbsd-compat/openbsd-compat.h
old new 44 44 __attribute__((__format__ (printf, 2, 3))); 45 45 #endif 46 46 47 #ifdef USE_ADJTIMEX 48 # include <sys/time.h> 49 int _compat_adjtime(const struct timeval *, struct timeval *); 50 #endif 51 47 52 #ifndef HAVE_INET_PTON 48 53 int inet_pton(int, const char *, void *); 49 54 #endif -
openbsd-compat/port-linux.c
diff -urN openntpd-3.7p1.orig/openbsd-compat/port-linux.c openntpd-3.7p1/openbsd-compat/port-linux.c
old new 1 /* $Id$ */ 2 3 /* 4 * Copyright (c) 2004 Darren Tucker <dtucker at zip com au> 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 #include "includes.h" 20 21 #ifdef USE_ADJTIMEX 22 #include <sys/timex.h> 23 #include <errno.h> 24 #ifdef adjtime 25 # undef adjtime 26 #endif 27 28 #include "ntpd.h" 29 30 /* scale factor used by adjtimex freq param. 1 ppm = 65536 */ 31 #define ADJTIMEX_FREQ_SCALE 65536 32 33 /* maximum change to skew per adjustment, in PPM */ 34 #define MAX_SKEW_DELTA 5.0 35 36 int 37 _compat_adjtime(const struct timeval *delta, struct timeval *olddelta) 38 { 39 static struct timeval tlast = {0,0}; 40 static double tskew = 0; 41 static int synced = -1; 42 struct timeval tnow, tdelta; 43 double skew = 0, newskew, deltaskew, adjust, interval = 0; 44 struct timex tmx; 45 int result, saved_errno; 46 47 gettimeofday(&tnow, NULL); 48 adjust = (double)delta->tv_sec; 49 adjust += (double)delta->tv_usec / 1000000; 50 51 /* Even if the caller doesn't care about the olddelta, we do */ 52 if (olddelta == NULL) 53 olddelta = &tdelta; 54 55 result = adjtime(delta, olddelta); 56 saved_errno = errno; 57 58 if (olddelta->tv_sec == 0 && olddelta->tv_usec == 0 && 59 synced != INT_MAX) 60 synced++; 61 else 62 synced = 0; 63 64 /* 65 * do skew calculations if we have synced 66 */ 67 if (synced == 0 ) { 68 tmx.modes = 0; 69 if (adjtimex(&tmx) == -1) 70 log_warn("adjtimex get failed"); 71 else 72 tskew = (double)tmx.freq / ADJTIMEX_FREQ_SCALE; 73 } else if (synced >= 1) { 74 interval = (double)(tnow.tv_sec - tlast.tv_sec); 75 interval += (double)(tnow.tv_usec - tlast.tv_usec) / 1000000; 76 77 skew = (adjust * 1000000) / interval; 78 newskew = ((tskew * synced) + skew) / synced; 79 deltaskew = newskew - tskew; 80 81 if (deltaskew > MAX_SKEW_DELTA) { 82 log_info("skew change %0.3lf exceeds limit", deltaskew); 83 tskew += MAX_SKEW_DELTA; 84 } else if (deltaskew < -MAX_SKEW_DELTA) { 85 log_info("skew change %0.3lf exceeds limit", deltaskew); 86 tskew -= MAX_SKEW_DELTA; 87 } else { 88 tskew = newskew; 89 } 90 91 /* Adjust the kernel skew. */ 92 tmx.freq = (long)(tskew * ADJTIMEX_FREQ_SCALE); 93 tmx.modes = ADJ_FREQUENCY; 94 if (adjtimex(&tmx) == -1) 95 log_warn("adjtimex set freq failed"); 96 } 97 98 log_debug("interval %0.3lf skew %0.3lf total skew %0.3lf", interval, 99 skew, tskew); 100 101 tlast = tnow; 102 errno = saved_errno; 103 return result; 104 } 105 #endif
Note:
See TracBrowser
for help on using the repository browser.
