mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 16:45:07 -05:00
Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
917c191650 | ||
|
|
2bfce03d29 | ||
|
|
1cb8167be0 | ||
|
|
40d33cc64d | ||
|
|
95433e9639 | ||
|
|
bbe1a09e7e | ||
|
|
dce2366b3a | ||
|
|
bab7ba22cf | ||
|
|
d6a91057ae | ||
|
|
c6e9065498 | ||
|
|
22fda21eae | ||
|
|
103a520aa6 | ||
|
|
86531a51a7 | ||
|
|
2b7e4d645f | ||
|
|
a5f63180fc | ||
|
|
934d4e04b5 | ||
|
|
1b8547059a | ||
|
|
91279a0f28 | ||
|
|
31ba3144c8 | ||
|
|
0bf34725e3 | ||
|
|
91749ebb2b | ||
|
|
4ba3dd66ad | ||
|
|
d40696f7f3 | ||
|
|
4a401a9e83 | ||
|
|
6a2a837ede | ||
|
|
eca08a281c | ||
|
|
9fd8f76fa0 | ||
|
|
50de930730 | ||
|
|
da1097095c | ||
|
|
ec7d302a6c | ||
|
|
8cc7ebffa9 | ||
|
|
de4d14843f | ||
|
|
18605795a7 | ||
|
|
da2c8d9076 | ||
|
|
3120f8adb6 | ||
|
|
2dcc16169b | ||
|
|
a8efd8c398 | ||
|
|
bb40f4aff4 | ||
|
|
66c7ac4d24 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
.deps
|
||||||
*.swp
|
*.swp
|
||||||
*.o
|
*.o
|
||||||
Makefile
|
Makefile
|
||||||
|
|||||||
36
Makefile.in
36
Makefile.in
@@ -29,9 +29,8 @@ INFODIR=@INFODIR@
|
|||||||
DOCDIR=@DOCDIR@
|
DOCDIR=@DOCDIR@
|
||||||
|
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
CCWARNFLAGS = @CCWARNFLAGS@
|
CFLAGS = @CFLAGS@
|
||||||
OPTFLAGS = @CFLAGS@
|
CPPFLAGS = @CPPFLAGS@
|
||||||
CPPFLAGS = @CPPFLAGS@ @SYSDEFS@ @EXTRA_DEFS@
|
|
||||||
|
|
||||||
DESTDIR=
|
DESTDIR=
|
||||||
|
|
||||||
@@ -49,6 +48,8 @@ EXTRA_OBJS=@EXTRA_OBJECTS@
|
|||||||
CLI_OBJS = client.o md5.o nameserv.o getdate.o cmdparse.o \
|
CLI_OBJS = client.o md5.o nameserv.o getdate.o cmdparse.o \
|
||||||
pktlength.o util.o
|
pktlength.o util.o
|
||||||
|
|
||||||
|
ALL_OBJS = $(OBJS) $(EXTRA_OBJS) $(CLI_OBJS)
|
||||||
|
|
||||||
SRCS = $(patsubst %.o,%.c,$(OBJS))
|
SRCS = $(patsubst %.o,%.c,$(OBJS))
|
||||||
EXTRA_SRCS = $(patsubst %.o,%.c,$(EXTRA_OBJS))
|
EXTRA_SRCS = $(patsubst %.o,%.c,$(EXTRA_OBJS))
|
||||||
|
|
||||||
@@ -60,36 +61,26 @@ LIBS = @LIBS@
|
|||||||
EXTRA_LIBS=@EXTRA_LIBS@
|
EXTRA_LIBS=@EXTRA_LIBS@
|
||||||
EXTRA_CLI_LIBS=@EXTRA_CLI_LIBS@
|
EXTRA_CLI_LIBS=@EXTRA_CLI_LIBS@
|
||||||
|
|
||||||
CFLAGS = $(CCWARNFLAGS) $(OPTFLAGS)
|
|
||||||
|
|
||||||
# Until we have a main procedure we can link, just build object files
|
# Until we have a main procedure we can link, just build object files
|
||||||
# to test compilation
|
# to test compilation
|
||||||
|
|
||||||
all : chronyd chronyc
|
all : chronyd chronyc
|
||||||
|
|
||||||
chronyd : $(OBJS) $(EXTRA_OBJS)
|
chronyd : $(OBJS) $(EXTRA_OBJS)
|
||||||
$(CC) $(OPTFLAGS) -o chronyd $(OBJS) $(EXTRA_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS)
|
$(CC) $(CFLAGS) -o chronyd $(OBJS) $(EXTRA_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_LIBS)
|
||||||
|
|
||||||
chronyc : $(CLI_OBJS)
|
chronyc : $(CLI_OBJS)
|
||||||
$(CC) $(OPTFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) @READLINE_LINK@ $(LIBS) $(EXTRA_CLI_LIBS)
|
$(CC) $(CFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) @READLINE_LINK@ $(LIBS) $(EXTRA_CLI_LIBS)
|
||||||
|
|
||||||
conf.o : conf.c
|
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -DDEFAULT_CONF_DIR=\"$(SYSCONFDIR)\" -c $<
|
|
||||||
|
|
||||||
client.o : client.c
|
client.o : client.c
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) @READLINE_COMPILE@ -c $<
|
$(CC) $(CFLAGS) $(CPPFLAGS) @READLINE_COMPILE@ -c $<
|
||||||
|
|
||||||
.depend :
|
distclean : clean
|
||||||
gcc -MM $(SRCS) $(EXTRA_SRCS) > .depend
|
-rm -f Makefile
|
||||||
|
|
||||||
distclean :
|
|
||||||
-rm -f *.o *.s chronyc chronyd core options.h Makefile *~
|
|
||||||
|
|
||||||
clean :
|
clean :
|
||||||
-rm -f *.o *.s chronyc chronyd core *~
|
-rm -f *.o *.s chronyc chronyd core *~
|
||||||
|
-rm -rf .deps
|
||||||
version.h : version.txt
|
|
||||||
./mkversion
|
|
||||||
|
|
||||||
getdate.c : ;
|
getdate.c : ;
|
||||||
getdate :
|
getdate :
|
||||||
@@ -133,8 +124,6 @@ install: chronyd chronyc
|
|||||||
%.s : %.c
|
%.s : %.c
|
||||||
$(CC) $(CFLAGS) $(CPPFLAGS) -S $<
|
$(CC) $(CFLAGS) $(CPPFLAGS) -S $<
|
||||||
|
|
||||||
main.o logging.o client.o : version.h
|
|
||||||
|
|
||||||
# makeinfo v4 required to generate plain text and html
|
# makeinfo v4 required to generate plain text and html
|
||||||
MAKEINFO:=makeinfo
|
MAKEINFO:=makeinfo
|
||||||
|
|
||||||
@@ -163,3 +152,10 @@ chrony.info : chrony.texi
|
|||||||
faq.php : faq.txt faqgen.pl
|
faq.php : faq.txt faqgen.pl
|
||||||
perl faqgen.pl < faq.txt > faq.php
|
perl faqgen.pl < faq.txt > faq.php
|
||||||
|
|
||||||
|
.deps:
|
||||||
|
@mkdir .deps
|
||||||
|
|
||||||
|
.deps/%.d: %.c | .deps
|
||||||
|
@$(CC) -MM $(CPPFLAGS) -MT '$(<:%.c=%.o) $@' $< -o $@
|
||||||
|
|
||||||
|
-include $(ALL_OBJS:%.o=.deps/%.d)
|
||||||
|
|||||||
11
NEWS
11
NEWS
@@ -1,3 +1,13 @@
|
|||||||
|
New in version 1.26
|
||||||
|
===================
|
||||||
|
|
||||||
|
* Add compatibility with Linux 3.0 and later
|
||||||
|
* Use proper source address in NTP replies on multihomed IPv6 hosts
|
||||||
|
* Accept NTP packets with versions 4, 3 and 2
|
||||||
|
* Cope with unexpected backward time jumps
|
||||||
|
* Don't reset kernel frequency on start without drift file
|
||||||
|
* Add waitsync command
|
||||||
|
|
||||||
New in version 1.25
|
New in version 1.25
|
||||||
===================
|
===================
|
||||||
|
|
||||||
@@ -6,6 +16,7 @@ New in version 1.25
|
|||||||
* Improve polling interval adjustment
|
* Improve polling interval adjustment
|
||||||
* Improve stability with temporary asymmetric delays
|
* Improve stability with temporary asymmetric delays
|
||||||
* Improve source selection
|
* Improve source selection
|
||||||
|
* Improve initial synchronisation
|
||||||
* Add delayed server name resolving
|
* Add delayed server name resolving
|
||||||
* Add temperature compensation
|
* Add temperature compensation
|
||||||
* Add nanosecond slewing to Linux driver
|
* Add nanosecond slewing to Linux driver
|
||||||
|
|||||||
12
acquire.c
12
acquire.c
@@ -37,6 +37,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "acquire.h"
|
#include "acquire.h"
|
||||||
@@ -61,6 +63,10 @@
|
|||||||
|
|
||||||
#define RETRANSMISSION_TIMEOUT (1.0)
|
#define RETRANSMISSION_TIMEOUT (1.0)
|
||||||
|
|
||||||
|
#define NTP_VERSION 3
|
||||||
|
#define NTP_MAX_COMPAT_VERSION 4
|
||||||
|
#define NTP_MIN_COMPAT_VERSION 2
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
IPAddr ip_addr; /* Address of the server */
|
IPAddr ip_addr; /* Address of the server */
|
||||||
int sanity; /* Flag indicating whether source
|
int sanity; /* Flag indicating whether source
|
||||||
@@ -244,7 +250,7 @@ static void
|
|||||||
probe_source(SourceRecord *src)
|
probe_source(SourceRecord *src)
|
||||||
{
|
{
|
||||||
NTP_Packet pkt;
|
NTP_Packet pkt;
|
||||||
int version = 3;
|
int version = NTP_VERSION;
|
||||||
NTP_Mode my_mode = MODE_CLIENT;
|
NTP_Mode my_mode = MODE_CLIENT;
|
||||||
struct timeval cooked;
|
struct timeval cooked;
|
||||||
union sockaddr_in46 his_addr;
|
union sockaddr_in46 his_addr;
|
||||||
@@ -264,7 +270,7 @@ probe_source(SourceRecord *src)
|
|||||||
pkt.precision = -6; /* as ntpdate */
|
pkt.precision = -6; /* as ntpdate */
|
||||||
pkt.root_delay = double_to_int32(1.0); /* 1 second */
|
pkt.root_delay = double_to_int32(1.0); /* 1 second */
|
||||||
pkt.root_dispersion = double_to_int32(1.0); /* likewise */
|
pkt.root_dispersion = double_to_int32(1.0); /* likewise */
|
||||||
pkt.reference_id = 0UL;
|
pkt.reference_id = 0;
|
||||||
pkt.reference_ts.hi = 0; /* Set to 0 */
|
pkt.reference_ts.hi = 0; /* Set to 0 */
|
||||||
pkt.reference_ts.lo = 0; /* Set to 0 */
|
pkt.reference_ts.lo = 0; /* Set to 0 */
|
||||||
pkt.originate_ts.hi = 0; /* Set to 0 */
|
pkt.originate_ts.hi = 0; /* Set to 0 */
|
||||||
@@ -370,7 +376,7 @@ process_receive(NTP_Packet *msg, SourceRecord *src, struct timeval *now)
|
|||||||
mode = lvm & 0x7;
|
mode = lvm & 0x7;
|
||||||
|
|
||||||
if ((leap == LEAP_Unsynchronised) ||
|
if ((leap == LEAP_Unsynchronised) ||
|
||||||
(version != 3) ||
|
(version < NTP_MIN_COMPAT_VERSION || version > NTP_MAX_COMPAT_VERSION) ||
|
||||||
(mode != MODE_SERVER && mode != MODE_PASSIVE)) {
|
(mode != MODE_SERVER && mode != MODE_PASSIVE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "addrfilt.h"
|
#include "addrfilt.h"
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
Deal with broadcast server functions.
|
Deal with broadcast server functions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
@@ -71,7 +73,7 @@ timeout_handler(void *arbitrary)
|
|||||||
int leap;
|
int leap;
|
||||||
int are_we_synchronised, our_stratum;
|
int are_we_synchronised, our_stratum;
|
||||||
NTP_Leap leap_status;
|
NTP_Leap leap_status;
|
||||||
unsigned long our_ref_id;
|
uint32_t our_ref_id;
|
||||||
struct timeval our_ref_time;
|
struct timeval our_ref_time;
|
||||||
double our_root_delay, our_root_dispersion;
|
double our_root_delay, our_root_dispersion;
|
||||||
struct timeval local_transmit;
|
struct timeval local_transmit;
|
||||||
@@ -89,7 +91,7 @@ timeout_handler(void *arbitrary)
|
|||||||
if (are_we_synchronised) {
|
if (are_we_synchronised) {
|
||||||
leap = (int) leap_status;
|
leap = (int) leap_status;
|
||||||
} else {
|
} else {
|
||||||
leap = 3;
|
leap = LEAP_Unsynchronised;
|
||||||
}
|
}
|
||||||
|
|
||||||
message.lvm = ((leap << 6) &0xc0) | ((version << 3) & 0x38) | (MODE_BROADCAST & 0x07);
|
message.lvm = ((leap << 6) &0xc0) | ((version << 3) & 0x38) | (MODE_BROADCAST & 0x07);
|
||||||
|
|||||||
2
chrony.1
2
chrony.1
@@ -1,4 +1,4 @@
|
|||||||
.TH CHRONY 1 "December 04, 2009" chrony "User's Manual"
|
.TH CHRONY 1 "@MAN_DATE@" "chrony @VERSION@" "User's Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
chrony \- programs for keeping computer clocks accurate
|
chrony \- programs for keeping computer clocks accurate
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH chrony.conf 5 "December 04, 2009" chrony "Configuration Files"
|
.TH chrony.conf 5 "@MAN_DATE@" "chrony @VERSION@" "Configuration Files"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
chrony.conf \- chronyd configuration file
|
chrony.conf \- chronyd configuration file
|
||||||
|
|
||||||
|
|||||||
29
chrony.lsm
29
chrony.lsm
@@ -1,29 +0,0 @@
|
|||||||
Begin3
|
|
||||||
Title: chrony
|
|
||||||
Version: 1.18
|
|
||||||
Entered-date: 01APR02
|
|
||||||
Description: A pair of programs for keeping computer clocks accurate.
|
|
||||||
chronyd is a background (daemon) program and chronyc is a
|
|
||||||
command-line interface to it. Time reference sources for
|
|
||||||
chronyd can be RFC1305 NTP servers, human (via keyboard and
|
|
||||||
chronyc), and the computer's real-time clock at boot time
|
|
||||||
(Linux only). chronyd can determine the rate at which the
|
|
||||||
computer gains or loses time and compensate for it whilst no
|
|
||||||
external reference is present. chronyd's use of NTP servers
|
|
||||||
can be switched on and off (through chronyc) to support
|
|
||||||
computers with dial-up/intermittent access to the
|
|
||||||
Internet. chronyd can also act as an RFC1305-compatible NTP
|
|
||||||
server.
|
|
||||||
Keywords: time NTP RFC1305 RTC adjtime
|
|
||||||
Author: rc@rc0.org.uk (Richard Curnow)
|
|
||||||
Maintained-by: rc@rc0.org.uk (Richard Curnow)
|
|
||||||
Primary-site: chrony.tuxfamily.org
|
|
||||||
295k chrony-1.18.tar.gz
|
|
||||||
2k chrony.lsm
|
|
||||||
Platforms: Linux 2.0/2.1/2.2/2.3/2.4 (x86, powerpc)
|
|
||||||
Solaris 2.5/6/7/8, SunOS 4.1.4. (Sparc)
|
|
||||||
BSDI/386.
|
|
||||||
NetBSD
|
|
||||||
Solaris 2.8 (x86)
|
|
||||||
Copying-policy: GPL
|
|
||||||
End
|
|
||||||
27
chrony.texi
27
chrony.texi
@@ -2898,6 +2898,7 @@ password:
|
|||||||
@item @code{sources}
|
@item @code{sources}
|
||||||
@item @code{sourcestats}
|
@item @code{sourcestats}
|
||||||
@item @code{tracking}
|
@item @code{tracking}
|
||||||
|
@item @code{waitsync}
|
||||||
@end itemize
|
@end itemize
|
||||||
|
|
||||||
All other commands require a password to have been specified previously,
|
All other commands require a password to have been specified previously,
|
||||||
@@ -2958,6 +2959,7 @@ interface.
|
|||||||
* timeout command:: Set initial response timeout
|
* timeout command:: Set initial response timeout
|
||||||
* tracking command:: Display system clock performance
|
* tracking command:: Display system clock performance
|
||||||
* trimrtc command:: Correct the RTC time to the current system time
|
* trimrtc command:: Correct the RTC time to the current system time
|
||||||
|
* waitsync command:: Wait until synchronised
|
||||||
* writertc command:: Write the RTC parameters to file.
|
* writertc command:: Write the RTC parameters to file.
|
||||||
@end menu
|
@end menu
|
||||||
@c }}}
|
@c }}}
|
||||||
@@ -4188,6 +4190,31 @@ across machine reboots even if the @code{trimrtc} command is never used
|
|||||||
corrected, in a manner compatible with @code{chronyd} using it to
|
corrected, in a manner compatible with @code{chronyd} using it to
|
||||||
maintain accurate time across machine reboots.
|
maintain accurate time across machine reboots.
|
||||||
@c }}}
|
@c }}}
|
||||||
|
@c {{{ waitsync
|
||||||
|
@node waitsync command
|
||||||
|
@subsubsection waitsync
|
||||||
|
The @code{waitsync} command waits for @code{chronyd} to synchronise.
|
||||||
|
|
||||||
|
Up to three optional arguments can be specified, the first is the maximum
|
||||||
|
number of tries in 10 second intervals before giving up and returning a
|
||||||
|
non-zero error code. When 0 is specified, or there are no arguments, the
|
||||||
|
number of tries will not be limited.
|
||||||
|
|
||||||
|
The second and third arguments are the maximum allowed remaining correction of
|
||||||
|
the system clock and the maximum allowed skew (in ppm) as reported by the
|
||||||
|
@code{tracking} command (@pxref{tracking command}) in the @code{System time}
|
||||||
|
and @code{Skew} fields. If not specified or zero, the value will not be
|
||||||
|
checked.
|
||||||
|
|
||||||
|
An example is
|
||||||
|
|
||||||
|
@example
|
||||||
|
waitsync 60 0.01
|
||||||
|
@end example
|
||||||
|
|
||||||
|
which will wait up to about 10 minutes for @code{chronyd} to synchronise to a
|
||||||
|
source and the remaining correction to be less than 10 milliseconds.
|
||||||
|
@c }}}
|
||||||
@c {{{ writertc
|
@c {{{ writertc
|
||||||
@node writertc command
|
@node writertc command
|
||||||
@subsubsection writertc
|
@subsubsection writertc
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH CHRONYC 1 "December 04, 2009" chrony "User's Manual"
|
.TH CHRONYC 1 "@MAN_DATE@" "chrony @VERSION@" "User's Manual"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
chronyc \- command-line interface for chronyd
|
chronyc \- command-line interface for chronyd
|
||||||
|
|
||||||
@@ -46,10 +46,6 @@ will be interpreted as a whole command.
|
|||||||
specify command. If no command is given, chronyc will read commands
|
specify command. If no command is given, chronyc will read commands
|
||||||
interactively.
|
interactively.
|
||||||
|
|
||||||
|
|
||||||
.SH VERSION
|
|
||||||
1.24
|
|
||||||
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
To report bugs, please visit \fIhttp://chrony.tuxfamily.org\fR
|
To report bugs, please visit \fIhttp://chrony.tuxfamily.org\fR
|
||||||
|
|
||||||
@@ -67,4 +63,3 @@ Man Pages Project". Please see \fIhttp://www.netmeister.org/misc/m2p2/index.htm
|
|||||||
for details.
|
for details.
|
||||||
|
|
||||||
The complete chrony documentation is supplied in texinfo format.
|
The complete chrony documentation is supplied in texinfo format.
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.TH CHRONYD 8 "December 04, 2009" chrony "System Administration"
|
.TH CHRONYD 8 "@MAN_DATE@" "chrony @VERSION@" "System Administration"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
chronyd \- chrony background daemon
|
chronyd \- chrony background daemon
|
||||||
|
|
||||||
@@ -108,9 +108,6 @@ Resolve hostnames only to IPv6 addresses.
|
|||||||
.SH FILES
|
.SH FILES
|
||||||
\fI/etc/chrony.conf\fR
|
\fI/etc/chrony.conf\fR
|
||||||
|
|
||||||
.SH VERSION
|
|
||||||
Version 1.24
|
|
||||||
|
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
To report bugs, please visit \fIhttp://chrony.tuxfamily.org/\fR
|
To report bugs, please visit \fIhttp://chrony.tuxfamily.org/\fR
|
||||||
|
|
||||||
|
|||||||
68
client.c
68
client.c
@@ -26,12 +26,13 @@
|
|||||||
from it whilst running.
|
from it whilst running.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "candm.h"
|
#include "candm.h"
|
||||||
#include "nameserv.h"
|
#include "nameserv.h"
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
#include "version.h"
|
|
||||||
#include "getdate.h"
|
#include "getdate.h"
|
||||||
#include "cmdparse.h"
|
#include "cmdparse.h"
|
||||||
#include "pktlength.h"
|
#include "pktlength.h"
|
||||||
@@ -1081,12 +1082,11 @@ process_cmd_delete(CMD_Request *msg, char *line)
|
|||||||
fprintf(stderr, "Could not get address for hostname\n");
|
fprintf(stderr, "Could not get address for hostname\n");
|
||||||
ok = 0;
|
ok = 0;
|
||||||
} else {
|
} else {
|
||||||
|
UTI_IPHostToNetwork(&address, &msg->data.del_source.ip_addr);
|
||||||
ok = 1;
|
ok = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UTI_IPHostToNetwork(&address, &msg->data.del_source.ip_addr);
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1234,6 +1234,7 @@ give_help(void)
|
|||||||
printf("sourcestats [-v] : Display estimation information about current sources\n");
|
printf("sourcestats [-v] : Display estimation information about current sources\n");
|
||||||
printf("tracking : Display system time information\n");
|
printf("tracking : Display system time information\n");
|
||||||
printf("trimrtc : Correct RTC relative to system clock\n");
|
printf("trimrtc : Correct RTC relative to system clock\n");
|
||||||
|
printf("waitsync [max-tries [max-correction [max-skew]]] : Wait until synchronised\n");
|
||||||
printf("writertc : Save RTC parameters to file\n");
|
printf("writertc : Save RTC parameters to file\n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("dns -n|+n : Disable/enable resolving IP addresses to hostnames\n");
|
printf("dns -n|+n : Disable/enable resolving IP addresses to hostnames\n");
|
||||||
@@ -1788,7 +1789,7 @@ process_cmd_sourcestats(char *line)
|
|||||||
char hostname_buf[50];
|
char hostname_buf[50];
|
||||||
unsigned long n_samples, n_runs, span_seconds;
|
unsigned long n_samples, n_runs, span_seconds;
|
||||||
double resid_freq_ppm, skew_ppm, sd, est_offset;
|
double resid_freq_ppm, skew_ppm, sd, est_offset;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
|
|
||||||
verbose = check_for_verbose_flag(line);
|
verbose = check_for_verbose_flag(line);
|
||||||
@@ -1867,7 +1868,7 @@ process_cmd_tracking(char *line)
|
|||||||
CMD_Request request;
|
CMD_Request request;
|
||||||
CMD_Reply reply;
|
CMD_Reply reply;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
char host[50];
|
char host[50];
|
||||||
char *ref_ip;
|
char *ref_ip;
|
||||||
struct timeval ref_time;
|
struct timeval ref_time;
|
||||||
@@ -2402,6 +2403,56 @@ process_cmd_reselect(CMD_Request *msg, char *line)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
process_cmd_waitsync(char *line)
|
||||||
|
{
|
||||||
|
CMD_Request request;
|
||||||
|
CMD_Reply reply;
|
||||||
|
uint32_t ref_id, a, b, c, d;
|
||||||
|
double correction, skew_ppm, max_correction, max_skew_ppm;
|
||||||
|
int ret = 0, max_tries, i;
|
||||||
|
|
||||||
|
max_tries = 0;
|
||||||
|
max_correction = 0.0;
|
||||||
|
max_skew_ppm = 0.0;
|
||||||
|
|
||||||
|
sscanf(line, "%d %lf %lf", &max_tries, &max_correction, &max_skew_ppm);
|
||||||
|
|
||||||
|
request.command = htons(REQ_TRACKING);
|
||||||
|
|
||||||
|
for (i = 1; ; i++) {
|
||||||
|
if (request_reply(&request, &reply, RPY_TRACKING, 0)) {
|
||||||
|
ref_id = ntohl(reply.data.tracking.ref_id);
|
||||||
|
a = (ref_id >> 24);
|
||||||
|
b = (ref_id >> 16) & 0xff;
|
||||||
|
c = (ref_id >> 8) & 0xff;
|
||||||
|
d = (ref_id) & 0xff;
|
||||||
|
|
||||||
|
correction = UTI_FloatNetworkToHost(reply.data.tracking.current_correction);
|
||||||
|
correction = fabs(correction);
|
||||||
|
skew_ppm = UTI_FloatNetworkToHost(reply.data.tracking.skew_ppm);
|
||||||
|
|
||||||
|
printf("try: %d, refid: %d.%d.%d.%d, correction: %.9f, skew: %.3f\n",
|
||||||
|
i, a, b, c, d, correction, skew_ppm);
|
||||||
|
|
||||||
|
if (ref_id != 0 && ref_id != 0x7f7f0101L /* LOCAL refid */ &&
|
||||||
|
(max_correction == 0.0 || correction <= max_correction) &&
|
||||||
|
(max_skew_ppm == 0.0 || skew_ppm <= max_skew_ppm)) {
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret && (!max_tries || i < max_tries)) {
|
||||||
|
sleep(10);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
process_cmd_dns(const char *line)
|
process_cmd_dns(const char *line)
|
||||||
{
|
{
|
||||||
@@ -2579,6 +2630,9 @@ process_line(char *line, int *quit)
|
|||||||
do_normal_submit = process_cmd_reselectdist(&tx_message, p+12);
|
do_normal_submit = process_cmd_reselectdist(&tx_message, p+12);
|
||||||
} else if (!strncmp(p, "reselect", 8)) {
|
} else if (!strncmp(p, "reselect", 8)) {
|
||||||
process_cmd_reselect(&tx_message, p+8);
|
process_cmd_reselect(&tx_message, p+8);
|
||||||
|
} else if (!strncmp(p, "waitsync", 8)) {
|
||||||
|
ret = process_cmd_waitsync(p+8);
|
||||||
|
do_normal_submit = 0;
|
||||||
} else if (!strncmp(p, "dns ", 4)) {
|
} else if (!strncmp(p, "dns ", 4)) {
|
||||||
ret = process_cmd_dns(p+4);
|
ret = process_cmd_dns(p+4);
|
||||||
do_normal_submit = 0;
|
do_normal_submit = 0;
|
||||||
@@ -2660,7 +2714,7 @@ display_gpl(void)
|
|||||||
"chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and\n"
|
"chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and\n"
|
||||||
"you are welcome to redistribute it under certain conditions. See the\n"
|
"you are welcome to redistribute it under certain conditions. See the\n"
|
||||||
"GNU General Public License version 2 for details.\n\n",
|
"GNU General Public License version 2 for details.\n\n",
|
||||||
PROGRAM_VERSION_STRING);
|
CHRONY_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -2697,7 +2751,7 @@ main(int argc, char **argv)
|
|||||||
DNS_SetAddressFamily(IPADDR_INET6);
|
DNS_SetAddressFamily(IPADDR_INET6);
|
||||||
hostname = "::1";
|
hostname = "::1";
|
||||||
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
||||||
printf("chronyc (chrony) version %s\n", PROGRAM_VERSION_STRING);
|
printf("chronyc (chrony) version %s\n", CHRONY_VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (!strncmp(*argv, "-", 1)) {
|
} else if (!strncmp(*argv, "-", 1)) {
|
||||||
fprintf(stderr, "Usage : %s [-h <hostname>] [-p <port-number>] [-n] [-4|-6] [-m] [command]\n", progname);
|
fprintf(stderr, "Usage : %s [-h <hostname>] [-p <port-number>] [-n] [-4|-6] [-m] [command]\n", progname);
|
||||||
|
|||||||
@@ -31,6 +31,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
#include "clientlog.h"
|
#include "clientlog.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
|
|||||||
2
cmdmon.c
2
cmdmon.c
@@ -25,6 +25,8 @@
|
|||||||
Command and monitoring module in the main program
|
Command and monitoring module in the main program
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "cmdmon.h"
|
#include "cmdmon.h"
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "cmdparse.h"
|
#include "cmdparse.h"
|
||||||
|
|||||||
22
conf.c
22
conf.c
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
@@ -466,10 +468,10 @@ static void
|
|||||||
parse_refclock(const char *line)
|
parse_refclock(const char *line)
|
||||||
{
|
{
|
||||||
int i, n, poll, dpoll, filter_length, pps_rate;
|
int i, n, poll, dpoll, filter_length, pps_rate;
|
||||||
unsigned long ref_id, lock_ref_id;
|
uint32_t ref_id, lock_ref_id;
|
||||||
double offset, delay, precision;
|
double offset, delay, precision;
|
||||||
const char *tmp;
|
const char *tmp;
|
||||||
char name[5], cmd[10 + 1], *param;
|
char cmd[10 + 1], *name, *param;
|
||||||
unsigned char ref[5];
|
unsigned char ref[5];
|
||||||
SRC_SelectOption sel_option;
|
SRC_SelectOption sel_option;
|
||||||
|
|
||||||
@@ -488,11 +490,20 @@ parse_refclock(const char *line)
|
|||||||
lock_ref_id = 0;
|
lock_ref_id = 0;
|
||||||
sel_option = SRC_SelectNormal;
|
sel_option = SRC_SelectNormal;
|
||||||
|
|
||||||
if (sscanf(line, "%4s%n", name, &n) != 1) {
|
while (isspace(line[0]))
|
||||||
|
line++;
|
||||||
|
tmp = line;
|
||||||
|
while (line[0] != '\0' && !isspace(line[0]))
|
||||||
|
line++;
|
||||||
|
|
||||||
|
if (line == tmp) {
|
||||||
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock driver name at line %d", line_number);
|
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock driver name at line %d", line_number);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
line += n;
|
|
||||||
|
name = MallocArray(char, 1 + line - tmp);
|
||||||
|
strncpy(name, tmp, line - tmp);
|
||||||
|
name[line - tmp] = '\0';
|
||||||
|
|
||||||
while (isspace(line[0]))
|
while (isspace(line[0]))
|
||||||
line++;
|
line++;
|
||||||
@@ -502,6 +513,7 @@ parse_refclock(const char *line)
|
|||||||
|
|
||||||
if (line == tmp) {
|
if (line == tmp) {
|
||||||
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock parameter at line %d", line_number);
|
LOG(LOGS_WARN, LOGF_Configure, "Could not read refclock parameter at line %d", line_number);
|
||||||
|
Free(name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -556,7 +568,7 @@ parse_refclock(const char *line)
|
|||||||
line += n;
|
line += n;
|
||||||
}
|
}
|
||||||
|
|
||||||
strncpy(refclock_sources[i].driver_name, name, 4);
|
refclock_sources[i].driver_name = name;
|
||||||
refclock_sources[i].driver_parameter = param;
|
refclock_sources[i].driver_parameter = param;
|
||||||
refclock_sources[i].driver_poll = dpoll;
|
refclock_sources[i].driver_poll = dpoll;
|
||||||
refclock_sources[i].poll = poll;
|
refclock_sources[i].poll = poll;
|
||||||
|
|||||||
86
configure
vendored
86
configure
vendored
@@ -8,6 +8,8 @@
|
|||||||
#
|
#
|
||||||
# =======================================================================
|
# =======================================================================
|
||||||
|
|
||||||
|
rm -f config.h
|
||||||
|
|
||||||
# This configure script determines the operating system type and version
|
# This configure script determines the operating system type and version
|
||||||
|
|
||||||
if [ "x${CC}" = "x" ]; then
|
if [ "x${CC}" = "x" ]; then
|
||||||
@@ -25,9 +27,7 @@ fi
|
|||||||
MYCPPFLAGS="${CPPFLAGS}"
|
MYCPPFLAGS="${CPPFLAGS}"
|
||||||
|
|
||||||
if [ "x${MYCC}" = "xgcc" ]; then
|
if [ "x${MYCC}" = "xgcc" ]; then
|
||||||
CCWARNFLAGS="-Wmissing-prototypes -Wall"
|
MYCFLAGS="${MYCFLAGS} -Wmissing-prototypes -Wall"
|
||||||
else
|
|
||||||
CCWARNFLAGS=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MYLDFLAGS="${LDFLAGS}"
|
MYLDFLAGS="${LDFLAGS}"
|
||||||
@@ -69,7 +69,7 @@ test_code () {
|
|||||||
#}}}
|
#}}}
|
||||||
#{{{ usage
|
#{{{ usage
|
||||||
usage () {
|
usage () {
|
||||||
cat <<EOF;
|
cat <<EOF
|
||||||
\`configure' configures tdl to adapt to many kinds of systems.
|
\`configure' configures tdl to adapt to many kinds of systems.
|
||||||
|
|
||||||
Usage: ./configure [OPTION]...
|
Usage: ./configure [OPTION]...
|
||||||
@@ -103,6 +103,7 @@ For better control, use the options below.
|
|||||||
--disable-rtc Don't include RTC even on Linux
|
--disable-rtc Don't include RTC even on Linux
|
||||||
--disable-linuxcaps Disable Linux capabilities support
|
--disable-linuxcaps Disable Linux capabilities support
|
||||||
--enable-forcednsretry Force retry on DNS failure
|
--enable-forcednsretry Force retry on DNS failure
|
||||||
|
--with-sendmail=PATH Path to sendmail binary [/usr/lib/sendmail]
|
||||||
|
|
||||||
Fine tuning of the installation directories:
|
Fine tuning of the installation directories:
|
||||||
--sysconfdir=DIR chrony.conf location [/etc]
|
--sysconfdir=DIR chrony.conf location [/etc]
|
||||||
@@ -133,6 +134,15 @@ EOF
|
|||||||
|
|
||||||
}
|
}
|
||||||
#}}}
|
#}}}
|
||||||
|
#{{{
|
||||||
|
add_def () {
|
||||||
|
if [ "x$2" = "x" ]; then
|
||||||
|
echo "#define $1 1" >> config.h
|
||||||
|
else
|
||||||
|
echo "#define $1 $2" >> config.h
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
#}}}
|
||||||
|
|
||||||
# ======================================================================
|
# ======================================================================
|
||||||
|
|
||||||
@@ -164,12 +174,13 @@ feat_pps=1
|
|||||||
try_setsched=0
|
try_setsched=0
|
||||||
try_lockmem=0
|
try_lockmem=0
|
||||||
feat_forcednsretry=0
|
feat_forcednsretry=0
|
||||||
|
mail_program="/usr/lib/sendmail"
|
||||||
|
|
||||||
for option
|
for option
|
||||||
do
|
do
|
||||||
case "$option" in
|
case "$option" in
|
||||||
--trace )
|
--trace )
|
||||||
EXTRA_DEFS="-DTRACEON"
|
add_def TRACEON
|
||||||
;;
|
;;
|
||||||
--disable-readline )
|
--disable-readline )
|
||||||
feat_readline=0
|
feat_readline=0
|
||||||
@@ -231,6 +242,9 @@ do
|
|||||||
--enable-forcednsretry)
|
--enable-forcednsretry)
|
||||||
feat_forcednsretry=1
|
feat_forcednsretry=1
|
||||||
;;
|
;;
|
||||||
|
--with-sendmail=* )
|
||||||
|
mail_program=`echo $option | sed -e 's/^.*=//;'`
|
||||||
|
;;
|
||||||
--host-system=* )
|
--host-system=* )
|
||||||
OPERATINGSYSTEM=`echo $option | sed -e 's/^.*=//;'`
|
OPERATINGSYSTEM=`echo $option | sed -e 's/^.*=//;'`
|
||||||
;;
|
;;
|
||||||
@@ -257,17 +271,17 @@ case $SYSTEM in
|
|||||||
4.* )
|
4.* )
|
||||||
EXTRA_OBJECTS="sys_sunos.o strerror.o"
|
EXTRA_OBJECTS="sys_sunos.o strerror.o"
|
||||||
EXTRA_LIBS="-lkvm"
|
EXTRA_LIBS="-lkvm"
|
||||||
SYSDEFS="-DSUNOS"
|
add_def SUNOS
|
||||||
echo "Configuring for SunOS (" $SYSTEM "version" $VERSION ")"
|
echo "Configuring for SunOS (" $SYSTEM "version" $VERSION ")"
|
||||||
;;
|
;;
|
||||||
5.* )
|
5.* )
|
||||||
EXTRA_OBJECTS="sys_solaris.o"
|
EXTRA_OBJECTS="sys_solaris.o"
|
||||||
EXTRA_LIBS="-lsocket -lnsl -lkvm -lelf"
|
EXTRA_LIBS="-lsocket -lnsl -lkvm -lelf"
|
||||||
EXTRA_CLI_LIBS="-lsocket -lnsl"
|
EXTRA_CLI_LIBS="-lsocket -lnsl"
|
||||||
SYSDEFS="-DSOLARIS"
|
add_def SOLARIS
|
||||||
echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")"
|
echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")"
|
||||||
if [ $VERSION = "5.3" ]; then
|
if [ $VERSION = "5.3" ]; then
|
||||||
SYSDEFS="$SYSDEFS -DHAS_NO_BZERO"
|
add_def HAS_NO_BZERO
|
||||||
echo "Using memset() instead of bzero()"
|
echo "Using memset() instead of bzero()"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -279,12 +293,12 @@ case $SYSTEM in
|
|||||||
try_rtc=1
|
try_rtc=1
|
||||||
try_setsched=1
|
try_setsched=1
|
||||||
try_lockmem=1
|
try_lockmem=1
|
||||||
SYSDEFS="-DLINUX"
|
add_def LINUX
|
||||||
echo "Configuring for " $SYSTEM
|
echo "Configuring for " $SYSTEM
|
||||||
if [ "${MACHINE}" = "alpha" ]; then
|
if [ "${MACHINE}" = "alpha" ]; then
|
||||||
echo "Enabling -mieee"
|
echo "Enabling -mieee"
|
||||||
# FIXME: Should really test for GCC
|
# FIXME: Should really test for GCC
|
||||||
SYSDEFS="$SYSDEFS -mieee -DALPHA"
|
MYCFLAGS="$MYCFLAGS -mieee"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -293,7 +307,7 @@ case $SYSTEM in
|
|||||||
# be supported with the SunOS 4.x driver files.
|
# be supported with the SunOS 4.x driver files.
|
||||||
EXTRA_OBJECTS="sys_sunos.o strerror.o"
|
EXTRA_OBJECTS="sys_sunos.o strerror.o"
|
||||||
EXTRA_LIBS="-lkvm"
|
EXTRA_LIBS="-lkvm"
|
||||||
SYSDEFS="-DSUNOS"
|
add_def SUNOS
|
||||||
echo "Configuring for $SYSTEM (using SunOS driver)"
|
echo "Configuring for $SYSTEM (using SunOS driver)"
|
||||||
;;
|
;;
|
||||||
NetBSD-* )
|
NetBSD-* )
|
||||||
@@ -308,13 +322,13 @@ case $SYSTEM in
|
|||||||
EXTRA_OBJECTS="sys_solaris.o"
|
EXTRA_OBJECTS="sys_solaris.o"
|
||||||
EXTRA_LIBS="-lsocket -lnsl -lkvm -lelf"
|
EXTRA_LIBS="-lsocket -lnsl -lkvm -lelf"
|
||||||
EXTRA_CLI_LIBS="-lsocket -lnsl"
|
EXTRA_CLI_LIBS="-lsocket -lnsl"
|
||||||
SYSDEFS="-DSOLARIS"
|
add_def SOLARIS
|
||||||
echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")"
|
echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")"
|
||||||
;;
|
;;
|
||||||
CYGWIN32_NT-i[3456]86 )
|
CYGWIN32_NT-i[3456]86 )
|
||||||
EXTRA_OBJECTS="sys_winnt.o"
|
EXTRA_OBJECTS="sys_winnt.o"
|
||||||
EXTRA_LIBS=""
|
EXTRA_LIBS=""
|
||||||
SYSDEFS="-DWINNT"
|
add_def WINNT
|
||||||
echo "Configuring for Windows NT (Cygwin32)"
|
echo "Configuring for Windows NT (Cygwin32)"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
@@ -336,11 +350,11 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test_code '<stdint.h>' 'stdint.h' '' '' ''; then
|
if test_code '<stdint.h>' 'stdint.h' '' '' ''; then
|
||||||
SYSDEFS="${SYSDEFS} -DHAS_STDINT_H"
|
add_def HAS_STDINT_H
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test_code '<inttypes.h>' 'inttypes.h' '' '' ''; then
|
if test_code '<inttypes.h>' 'inttypes.h' '' '' ''; then
|
||||||
SYSDEFS="${SYSDEFS} -DHAS_INTTYPES_H"
|
add_def HAS_INTTYPES_H
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $feat_ipv6 = "1" ] && \
|
if [ $feat_ipv6 = "1" ] && \
|
||||||
@@ -350,7 +364,16 @@ if [ $feat_ipv6 = "1" ] && \
|
|||||||
n.sin6_addr = in6addr_any;
|
n.sin6_addr = in6addr_any;
|
||||||
return !inet_ntop(AF_INET6, &n.sin6_addr.s6_addr, p, sizeof(p));'
|
return !inet_ntop(AF_INET6, &n.sin6_addr.s6_addr, p, sizeof(p));'
|
||||||
then
|
then
|
||||||
SYSDEFS="${SYSDEFS} -DHAVE_IPV6"
|
add_def HAVE_IPV6
|
||||||
|
if ! test_code 'in6_pktinfo' 'sys/socket.h netinet/in.h' '' '' '
|
||||||
|
return sizeof(struct in6_pktinfo);'
|
||||||
|
then
|
||||||
|
if test_code 'in6_pktinfo with _GNU_SOURCE' 'sys/socket.h netinet/in.h' \
|
||||||
|
'-D_GNU_SOURCE' '' 'return sizeof(struct in6_pktinfo);'
|
||||||
|
then
|
||||||
|
add_def _GNU_SOURCE
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $feat_pps = "1" ] && \
|
if [ $feat_pps = "1" ] && \
|
||||||
@@ -360,7 +383,7 @@ if [ $feat_pps = "1" ] && \
|
|||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
return time_pps_fetch(h, PPS_TSFMT_TSPEC, &i, &ts);'
|
return time_pps_fetch(h, PPS_TSFMT_TSPEC, &i, &ts);'
|
||||||
then
|
then
|
||||||
SYSDEFS="${SYSDEFS} -DHAVE_PPSAPI"
|
add_def HAVE_PPSAPI
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $feat_linuxcaps = "1" ] && [ $try_linuxcaps = "1" ] && \
|
if [ $feat_linuxcaps = "1" ] && [ $try_linuxcaps = "1" ] && \
|
||||||
@@ -370,7 +393,7 @@ if [ $feat_linuxcaps = "1" ] && [ $try_linuxcaps = "1" ] && \
|
|||||||
'' '-lcap' \
|
'' '-lcap' \
|
||||||
'prctl(PR_SET_KEEPCAPS, 1);cap_set_proc(cap_from_text("cap_sys_time=ep"));'
|
'prctl(PR_SET_KEEPCAPS, 1);cap_set_proc(cap_from_text("cap_sys_time=ep"));'
|
||||||
then
|
then
|
||||||
EXTRA_DEFS="${EXTRA_DEFS} -DFEAT_LINUXCAPS=1"
|
add_def FEAT_LINUXCAPS
|
||||||
EXTRA_LIBS="-lcap"
|
EXTRA_LIBS="-lcap"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -379,7 +402,7 @@ if [ $feat_rtc = "1" ] && [ $try_rtc = "1" ] && \
|
|||||||
'ioctl(1, RTC_UIE_ON&RTC_UIE_OFF&RTC_RD_TIME&RTC_SET_TIME, 0&RTC_UF);'
|
'ioctl(1, RTC_UIE_ON&RTC_UIE_OFF&RTC_RD_TIME&RTC_SET_TIME, 0&RTC_UF);'
|
||||||
then
|
then
|
||||||
EXTRA_OBJECTS="$EXTRA_OBJECTS rtc_linux.o"
|
EXTRA_OBJECTS="$EXTRA_OBJECTS rtc_linux.o"
|
||||||
EXTRA_DEFS="$EXTRA_DEFS -DFEAT_RTC=1"
|
add_def FEAT_RTC
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $try_setsched = "1" ] && \
|
if [ $try_setsched = "1" ] && \
|
||||||
@@ -390,7 +413,7 @@ if [ $try_setsched = "1" ] && \
|
|||||||
sched_get_priority_max(SCHED_FIFO);
|
sched_get_priority_max(SCHED_FIFO);
|
||||||
sched_setscheduler(0, SCHED_FIFO, &sched);'
|
sched_setscheduler(0, SCHED_FIFO, &sched);'
|
||||||
then
|
then
|
||||||
SYSDEFS="${SYSDEFS} -DHAVE_SCHED_SETSCHEDULER"
|
add_def HAVE_SCHED_SETSCHEDULER
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $try_lockmem = "1" ] && \
|
if [ $try_lockmem = "1" ] && \
|
||||||
@@ -401,12 +424,12 @@ if [ $try_lockmem = "1" ] && \
|
|||||||
setrlimit(RLIMIT_MEMLOCK, &rlim);
|
setrlimit(RLIMIT_MEMLOCK, &rlim);
|
||||||
mlockall(MCL_CURRENT|MCL_FUTURE);'
|
mlockall(MCL_CURRENT|MCL_FUTURE);'
|
||||||
then
|
then
|
||||||
SYSDEFS="${SYSDEFS} -DHAVE_MLOCKALL"
|
add_def HAVE_MLOCKALL
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $feat_forcednsretry = "1" ]
|
if [ $feat_forcednsretry = "1" ]
|
||||||
then
|
then
|
||||||
EXTRA_DEFS="$EXTRA_DEFS -DFORCE_DNSRETRY=1"
|
add_def FORCE_DNSRETRY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
READLINE_COMPILE=""
|
READLINE_COMPILE=""
|
||||||
@@ -417,7 +440,9 @@ if [ $feat_readline = "1" ]; then
|
|||||||
"$readline_inc" "$readline_lib -ledit" \
|
"$readline_inc" "$readline_lib -ledit" \
|
||||||
'add_history(readline("prompt"));'
|
'add_history(readline("prompt"));'
|
||||||
then
|
then
|
||||||
READLINE_COMPILE="-DFEAT_READLINE=1 -DUSE_EDITLINE=1 $readline_inc"
|
add_def FEAT_READLINE
|
||||||
|
add_def USE_EDITLINE
|
||||||
|
READLINE_COMPILE="$readline_inc"
|
||||||
READLINE_LINK="$readline_lib -ledit"
|
READLINE_LINK="$readline_lib -ledit"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -427,7 +452,8 @@ if [ $feat_readline = "1" ]; then
|
|||||||
"$readline_inc" "$readline_lib $ncurses_lib -lreadline -lncurses" \
|
"$readline_inc" "$readline_lib $ncurses_lib -lreadline -lncurses" \
|
||||||
'add_history(readline("prompt"));'
|
'add_history(readline("prompt"));'
|
||||||
then
|
then
|
||||||
READLINE_COMPILE="-DFEAT_READLINE=1 $readline_inc"
|
add_def FEAT_READLINE
|
||||||
|
READLINE_COMPILE="$readline_inc"
|
||||||
READLINE_LINK="$readline_lib $ncurses_lib -lreadline -lncurses"
|
READLINE_LINK="$readline_lib $ncurses_lib -lreadline -lncurses"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -478,16 +504,22 @@ if [ "x$SETDOCDIR" != "x" ]; then
|
|||||||
DOCDIR=$SETDOCDIR
|
DOCDIR=$SETDOCDIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
add_def DEFAULT_CONF_DIR "\"$SYSCONFDIR\""
|
||||||
|
add_def MAIL_PROGRAM "\"$mail_program\""
|
||||||
|
|
||||||
|
if [ -f version.txt ]; then
|
||||||
|
add_def CHRONY_VERSION "\"`cat version.txt`\""
|
||||||
|
else
|
||||||
|
add_def CHRONY_VERSION "\"DEVELOPMENT\""
|
||||||
|
fi
|
||||||
|
|
||||||
sed -e "s%@EXTRA_OBJECTS@%${EXTRA_OBJECTS}%;\
|
sed -e "s%@EXTRA_OBJECTS@%${EXTRA_OBJECTS}%;\
|
||||||
s%@CC@%${MYCC}%;\
|
s%@CC@%${MYCC}%;\
|
||||||
s%@CFLAGS@%${MYCFLAGS}%;\
|
s%@CFLAGS@%${MYCFLAGS}%;\
|
||||||
s%@CCWARNFLAGS@%${CCWARNFLAGS}%;\
|
|
||||||
s%@CPPFLAGS@%${CPPFLAGS}%;\
|
s%@CPPFLAGS@%${CPPFLAGS}%;\
|
||||||
s%@LIBS@%${LIBS}%;\
|
s%@LIBS@%${LIBS}%;\
|
||||||
s%@LDFLAGS@%${MYLDFLAGS}%;\
|
s%@LDFLAGS@%${MYLDFLAGS}%;\
|
||||||
s%@EXTRA_LIBS@%${EXTRA_LIBS}%;\
|
s%@EXTRA_LIBS@%${EXTRA_LIBS}%;\
|
||||||
s%@SYSDEFS@%${SYSDEFS}%;\
|
|
||||||
s%@EXTRA_DEFS@%${EXTRA_DEFS}%;\
|
|
||||||
s%@EXTRA_CLI_LIBS@%${EXTRA_CLI_LIBS}%;\
|
s%@EXTRA_CLI_LIBS@%${EXTRA_CLI_LIBS}%;\
|
||||||
s%@READLINE_COMPILE@%${READLINE_COMPILE}%;\
|
s%@READLINE_COMPILE@%${READLINE_COMPILE}%;\
|
||||||
s%@READLINE_LINK@%${READLINE_LINK}%;\
|
s%@READLINE_LINK@%${READLINE_LINK}%;\
|
||||||
|
|||||||
2
keys.c
2
keys.c
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|||||||
22
local.c
22
local.c
@@ -28,6 +28,8 @@
|
|||||||
They interface with the system specific driver files in sys_*.c
|
They interface with the system specific driver files in sys_*.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
@@ -356,14 +358,14 @@ LCL_GetOffsetCorrection(struct timeval *raw, double *correction, double *err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* This is just a simple passthrough of the system specific routine */
|
/* Return current frequency */
|
||||||
|
|
||||||
double
|
double
|
||||||
LCL_ReadAbsoluteFrequency(void)
|
LCL_ReadAbsoluteFrequency(void)
|
||||||
{
|
{
|
||||||
double freq;
|
double freq;
|
||||||
|
|
||||||
freq = (*drv_read_freq)();
|
freq = current_freq_ppm;
|
||||||
|
|
||||||
/* Undo temperature compensation */
|
/* Undo temperature compensation */
|
||||||
if (temp_comp_ppm != 0.0) {
|
if (temp_comp_ppm != 0.0) {
|
||||||
@@ -486,6 +488,22 @@ LCL_ApplyStepOffset(double offset)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
void
|
||||||
|
LCL_NotifyExternalTimeStep(struct timeval *raw, struct timeval *cooked,
|
||||||
|
double offset, double dispersion)
|
||||||
|
{
|
||||||
|
ChangeListEntry *ptr;
|
||||||
|
|
||||||
|
/* Dispatch to all handlers */
|
||||||
|
for (ptr = change_list.next; ptr != &change_list; ptr = ptr->next) {
|
||||||
|
(ptr->handler)(raw, cooked, 0.0, offset, 1, ptr->anything);
|
||||||
|
}
|
||||||
|
|
||||||
|
lcl_InvokeDispersionNotifyHandlers(dispersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset)
|
LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset)
|
||||||
{
|
{
|
||||||
|
|||||||
5
local.h
5
local.h
@@ -151,6 +151,11 @@ extern void LCL_AccumulateOffset(double offset);
|
|||||||
|
|
||||||
extern void LCL_ApplyStepOffset(double offset);
|
extern void LCL_ApplyStepOffset(double offset);
|
||||||
|
|
||||||
|
/* Routine to invoke notify handlers on an unexpected time jump
|
||||||
|
in system clock */
|
||||||
|
extern void LCL_NotifyExternalTimeStep(struct timeval *raw, struct timeval *cooked,
|
||||||
|
double offset, double dispersion);
|
||||||
|
|
||||||
/* Perform the combination of modifying the frequency and applying
|
/* Perform the combination of modifying the frequency and applying
|
||||||
a slew, in one easy step */
|
a slew, in one easy step */
|
||||||
extern void LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset);
|
extern void LCL_AccumulateFrequencyAndOffset(double dfreq, double doffset);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
Module to handle logging of diagnostic information
|
Module to handle logging of diagnostic information
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|||||||
11
main.c
11
main.c
@@ -25,6 +25,8 @@
|
|||||||
The main program
|
The main program
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@@ -43,7 +45,6 @@
|
|||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "acquire.h"
|
#include "acquire.h"
|
||||||
#include "manual.h"
|
#include "manual.h"
|
||||||
#include "version.h"
|
|
||||||
#include "rtc.h"
|
#include "rtc.h"
|
||||||
#include "refclock.h"
|
#include "refclock.h"
|
||||||
#include "clientlog.h"
|
#include "clientlog.h"
|
||||||
@@ -286,7 +287,7 @@ int main
|
|||||||
do_init_rtc = 1;
|
do_init_rtc = 1;
|
||||||
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
} else if (!strcmp("-v", *argv) || !strcmp("--version",*argv)) {
|
||||||
/* This write to the terminal is OK, it comes before we turn into a daemon */
|
/* This write to the terminal is OK, it comes before we turn into a daemon */
|
||||||
printf("chronyd (chrony) version %s\n", PROGRAM_VERSION_STRING);
|
printf("chronyd (chrony) version %s\n", CHRONY_VERSION);
|
||||||
exit(0);
|
exit(0);
|
||||||
} else if (!strcmp("-n", *argv)) {
|
} else if (!strcmp("-n", *argv)) {
|
||||||
nofork = 1;
|
nofork = 1;
|
||||||
@@ -320,7 +321,7 @@ int main
|
|||||||
LOG_OpenSystemLog();
|
LOG_OpenSystemLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", PROGRAM_VERSION_STRING);
|
LOG(LOGS_INFO, LOGF_Main, "chronyd version %s starting", CHRONY_VERSION);
|
||||||
|
|
||||||
/* Check whether another chronyd may already be running. Do this after
|
/* Check whether another chronyd may already be running. Do this after
|
||||||
* forking, so that message logging goes to the right place (i.e. syslog), in
|
* forking, so that message logging goes to the right place (i.e. syslog), in
|
||||||
@@ -365,6 +366,8 @@ int main
|
|||||||
SYS_DropRoot(user);
|
SYS_DropRoot(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_CreateLogFileDir();
|
||||||
|
|
||||||
REF_Initialise();
|
REF_Initialise();
|
||||||
SST_Initialise();
|
SST_Initialise();
|
||||||
BRD_Initialise();
|
BRD_Initialise();
|
||||||
@@ -376,8 +379,6 @@ int main
|
|||||||
MNL_Initialise();
|
MNL_Initialise();
|
||||||
TMC_Initialise();
|
TMC_Initialise();
|
||||||
|
|
||||||
LOG_CreateLogFileDir();
|
|
||||||
|
|
||||||
/* From now on, it is safe to do finalisation on exit */
|
/* From now on, it is safe to do finalisation on exit */
|
||||||
initialised = 1;
|
initialised = 1;
|
||||||
|
|
||||||
|
|||||||
77
make_release
77
make_release
@@ -1,52 +1,51 @@
|
|||||||
#!/usr/bin/env perl
|
#!/bin/sh
|
||||||
|
|
||||||
$tool = "chrony";
|
LANG=C
|
||||||
|
export LANG
|
||||||
|
|
||||||
$version = shift || die "Usage : $0 <version>\n";
|
if [ $# -ne 1 ]; then
|
||||||
$subdir = "${tool}-${version}";
|
echo "Usage : $0 <version>"
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
|
||||||
unless (-d ".git") {
|
version=$1
|
||||||
die "No .git subdirectory?"
|
subdir=chrony-${version}
|
||||||
}
|
mandate=$(date +'%B %Y')
|
||||||
|
|
||||||
unless (-d "RELEASES") {
|
umask 022
|
||||||
mkdir "RELEASES", 0755;
|
|
||||||
}
|
|
||||||
|
|
||||||
system ("git tag -s $version");
|
if [ ! -d .git ]; then
|
||||||
die "git-tag failed" if ($? != 0);
|
echo "No .git subdirectory?"
|
||||||
if (-d "RELEASES/$subdir") {
|
exit 3
|
||||||
system ("rm -rf RELEASES/$subdir");
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
system ("git archive --format=tar --prefix=RELEASES/${subdir}/ $version | tar xf -");
|
[ -d RELEASES ] || mkdir RELEASES
|
||||||
die "git-tar-tree failed" if ($? != 0);
|
|
||||||
|
|
||||||
chdir "RELEASES";
|
git tag -s $version || exit 1
|
||||||
$here = qx/pwd/;
|
|
||||||
chomp $here;
|
|
||||||
chdir $subdir;
|
|
||||||
|
|
||||||
open (OUT, ">version.txt");
|
rm -rf RELEASES/$subdir
|
||||||
print OUT $version."\n";
|
|
||||||
close OUT;
|
|
||||||
|
|
||||||
open (IN, "<${tool}.spec.sample");
|
git archive --format=tar --prefix=RELEASES/${subdir}/ $version | \
|
||||||
open (OUT, ">${tool}.spec");
|
tar xf - || exit 1
|
||||||
while (<IN>) {
|
|
||||||
s/\@\@VERSION\@\@/$version/;
|
|
||||||
print OUT;
|
|
||||||
}
|
|
||||||
close (IN);
|
|
||||||
close (OUT);
|
|
||||||
|
|
||||||
system("makeinfo --no-headers --number-sections -o chrony.txt chrony.texi");
|
cd RELEASES/$subdir || exit 1
|
||||||
unlink "make_release";
|
|
||||||
unlink "${tool}.spec.sample";
|
|
||||||
unlink ".gitignore";
|
|
||||||
|
|
||||||
chdir $here;
|
echo $version > version.txt
|
||||||
system ("tar cvf - $subdir | gzip -9 > ${subdir}.tar.gz");
|
|
||||||
system ("gpg -b -a -o ${subdir}-tar-gz-asc.txt ${subdir}.tar.gz");
|
sed -e "s%@@VERSION@@%${version}%" < chrony.spec.sample > chrony.spec
|
||||||
|
|
||||||
|
for m in chrony.1 chronyc.1 chrony.conf.5 chronyd.8; do
|
||||||
|
sed -e "s%@VERSION@%${version}%;s%@MAN_DATE@%${mandate}%" \
|
||||||
|
< $m > ${m}_
|
||||||
|
mv -f ${m}_ $m
|
||||||
|
done
|
||||||
|
|
||||||
|
makeinfo --no-headers --number-sections -o chrony.txt chrony.texi
|
||||||
|
|
||||||
|
rm -f make_release chrony.spec.sample .gitignore
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
tar cvf - $subdir | gzip -9 > ${subdir}.tar.gz
|
||||||
|
gpg -b -a -o ${subdir}-tar-gz-asc.txt ${subdir}.tar.gz
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
manual.c
4
manual.c
@@ -30,6 +30,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "manual.h"
|
#include "manual.h"
|
||||||
@@ -143,6 +145,8 @@ estimate_and_set_system(struct timeval *now, int offset_provided, double offset,
|
|||||||
}
|
}
|
||||||
b1 = freq = 0.0;
|
b1 = freq = 0.0;
|
||||||
found_freq = 0;
|
found_freq = 0;
|
||||||
|
agos[0] = 0.0;
|
||||||
|
offsets[0] = b0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset_provided) {
|
if (offset_provided) {
|
||||||
|
|||||||
2
md5.c
2
md5.c
@@ -37,6 +37,8 @@
|
|||||||
***********************************************************************
|
***********************************************************************
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "md5.h"
|
#include "md5.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "mkdirpp.h"
|
#include "mkdirpp.h"
|
||||||
|
|||||||
15
mkversion
15
mkversion
@@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
rm -f version.h
|
|
||||||
echo "#ifndef VERSION_H" > version.h
|
|
||||||
echo "#define VERSION_H 1" >> version.h
|
|
||||||
|
|
||||||
if [ -f version.txt ]; then
|
|
||||||
ver=`cat version.txt`
|
|
||||||
echo "#define PROGRAM_VERSION_STRING \"$ver\"" >> version.h
|
|
||||||
else
|
|
||||||
echo "#define PROGRAM_VERSION_STRING \"DEVELOPMENT\"" >> version.h
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "#endif /* VERSION_H */" >> version.h
|
|
||||||
|
|
||||||
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "nameserv.h"
|
#include "nameserv.h"
|
||||||
|
|||||||
32
ntp_core.c
32
ntp_core.c
@@ -25,6 +25,8 @@
|
|||||||
Core NTP protocol engine
|
Core NTP protocol engine
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "ntp_core.h"
|
#include "ntp_core.h"
|
||||||
@@ -190,6 +192,10 @@ struct NCR_Instance_Record {
|
|||||||
/* The NTP protocol version that we support */
|
/* The NTP protocol version that we support */
|
||||||
#define NTP_VERSION 3
|
#define NTP_VERSION 3
|
||||||
|
|
||||||
|
/* Compatible NTP protocol versions */
|
||||||
|
#define NTP_MAX_COMPAT_VERSION 4
|
||||||
|
#define NTP_MIN_COMPAT_VERSION 2
|
||||||
|
|
||||||
/* Maximum allowed dispersion - as defined in RFC1305 (16 seconds) */
|
/* Maximum allowed dispersion - as defined in RFC1305 (16 seconds) */
|
||||||
#define NTP_MAX_DISPERSION 16.0
|
#define NTP_MAX_DISPERSION 16.0
|
||||||
|
|
||||||
@@ -509,11 +515,11 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||||||
/* Parameters read from reference module */
|
/* Parameters read from reference module */
|
||||||
int are_we_synchronised, our_stratum;
|
int are_we_synchronised, our_stratum;
|
||||||
NTP_Leap leap_status;
|
NTP_Leap leap_status;
|
||||||
unsigned long our_ref_id;
|
uint32_t our_ref_id;
|
||||||
struct timeval our_ref_time;
|
struct timeval our_ref_time;
|
||||||
double our_root_delay, our_root_dispersion;
|
double our_root_delay, our_root_dispersion;
|
||||||
|
|
||||||
version = 3;
|
version = NTP_VERSION;
|
||||||
|
|
||||||
LCL_ReadCookedTime(&local_transmit, NULL);
|
LCL_ReadCookedTime(&local_transmit, NULL);
|
||||||
REF_GetReferenceParams(&local_transmit,
|
REF_GetReferenceParams(&local_transmit,
|
||||||
@@ -525,7 +531,7 @@ transmit_packet(NTP_Mode my_mode, /* The mode this machine wants to be */
|
|||||||
if (are_we_synchronised) {
|
if (are_we_synchronised) {
|
||||||
leap = (int) leap_status;
|
leap = (int) leap_status;
|
||||||
} else {
|
} else {
|
||||||
leap = 3;
|
leap = LEAP_Unsynchronised;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Generate transmit packet */
|
/* Generate transmit packet */
|
||||||
@@ -1327,7 +1333,7 @@ process_known
|
|||||||
|
|
||||||
/* Check version */
|
/* Check version */
|
||||||
version = (message->lvm >> 3) & 0x7;
|
version = (message->lvm >> 3) & 0x7;
|
||||||
if (version != NTP_VERSION) {
|
if (version < NTP_MIN_COMPAT_VERSION || version > NTP_MAX_COMPAT_VERSION) {
|
||||||
/* Ignore packet, but might want to log it */
|
/* Ignore packet, but might want to log it */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1519,7 +1525,14 @@ NCR_ProcessNoauthUnknown(NTP_Packet *message, struct timeval *now, double now_er
|
|||||||
|
|
||||||
NTP_Mode his_mode;
|
NTP_Mode his_mode;
|
||||||
NTP_Mode my_mode;
|
NTP_Mode my_mode;
|
||||||
int my_poll;
|
int my_poll, version;
|
||||||
|
|
||||||
|
/* Check version */
|
||||||
|
version = (message->lvm >> 3) & 0x7;
|
||||||
|
if (version < NTP_MIN_COMPAT_VERSION || version > NTP_MAX_COMPAT_VERSION) {
|
||||||
|
/* Ignore packet, but might want to log it */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ADF_IsAllowed(access_auth_table, &remote_addr->ip_addr)) {
|
if (ADF_IsAllowed(access_auth_table, &remote_addr->ip_addr)) {
|
||||||
|
|
||||||
@@ -1587,10 +1600,17 @@ NCR_ProcessAuthUnknown(NTP_Packet *message, struct timeval *now, double now_err,
|
|||||||
|
|
||||||
NTP_Mode his_mode;
|
NTP_Mode his_mode;
|
||||||
NTP_Mode my_mode;
|
NTP_Mode my_mode;
|
||||||
int my_poll;
|
int my_poll, version;
|
||||||
int valid_key, valid_auth;
|
int valid_key, valid_auth;
|
||||||
unsigned long key_id;
|
unsigned long key_id;
|
||||||
|
|
||||||
|
/* Check version */
|
||||||
|
version = (message->lvm >> 3) & 0x7;
|
||||||
|
if (version < NTP_MIN_COMPAT_VERSION || version > NTP_MAX_COMPAT_VERSION) {
|
||||||
|
/* Ignore packet, but might want to log it */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ADF_IsAllowed(access_auth_table, &remote_addr->ip_addr)) {
|
if (ADF_IsAllowed(access_auth_table, &remote_addr->ip_addr)) {
|
||||||
|
|
||||||
his_mode = message->lvm & 0x07;
|
his_mode = message->lvm & 0x07;
|
||||||
|
|||||||
42
ntp_io.c
42
ntp_io.c
@@ -26,6 +26,8 @@
|
|||||||
This file deals with the IO aspects of reading and writing NTP packets
|
This file deals with the IO aspects of reading and writing NTP packets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "ntp_io.h"
|
#include "ntp_io.h"
|
||||||
@@ -157,6 +159,16 @@ prepare_socket(int family)
|
|||||||
LOG(LOGS_ERR, LOGF_NtpIO, "Could not request IPV6_V6ONLY socket option");
|
LOG(LOGS_ERR, LOGF_NtpIO, "Could not request IPV6_V6ONLY socket option");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef IPV6_RECVPKTINFO
|
||||||
|
if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
||||||
|
LOG(LOGS_ERR, LOGF_NtpIO, "Could not request IPv6 packet info socket option");
|
||||||
|
}
|
||||||
|
#elif defined(IPV6_PKTINFO)
|
||||||
|
if (setsockopt(sock_fd, IPPROTO_IPV6, IPV6_PKTINFO, (char *)&on_off, sizeof(on_off)) < 0) {
|
||||||
|
LOG(LOGS_ERR, LOGF_NtpIO, "Could not request IPv6 packet info socket option");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -343,6 +355,17 @@ read_from_socket(void *anything)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef IPV6_PKTINFO
|
||||||
|
if (cmsg->cmsg_level == IPPROTO_IPV6 && cmsg->cmsg_type == IPV6_PKTINFO) {
|
||||||
|
struct in6_pktinfo ipi;
|
||||||
|
|
||||||
|
memcpy(&ipi, CMSG_DATA(cmsg), sizeof(ipi));
|
||||||
|
memcpy(&remote_addr.local_ip_addr.addr.in6, &ipi.ipi6_addr.s6_addr,
|
||||||
|
sizeof (remote_addr.local_ip_addr.addr.in6));
|
||||||
|
remote_addr.local_ip_addr.family = IPADDR_INET6;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SO_TIMESTAMP
|
#ifdef SO_TIMESTAMP
|
||||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) {
|
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SO_TIMESTAMP) {
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
@@ -443,6 +466,25 @@ send_packet(void *packet, int packetlen, NTP_Remote_Address *remote_addr)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef IPV6_PKTINFO
|
||||||
|
if (remote_addr->local_ip_addr.family == IPADDR_INET6) {
|
||||||
|
struct cmsghdr *cmsg;
|
||||||
|
struct in6_pktinfo *ipi;
|
||||||
|
|
||||||
|
cmsg = CMSG_FIRSTHDR(&msg);
|
||||||
|
memset(cmsg, 0, CMSG_SPACE(sizeof(struct in6_pktinfo)));
|
||||||
|
cmsglen += CMSG_SPACE(sizeof(struct in6_pktinfo));
|
||||||
|
|
||||||
|
cmsg->cmsg_level = IPPROTO_IPV6;
|
||||||
|
cmsg->cmsg_type = IPV6_PKTINFO;
|
||||||
|
cmsg->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
|
||||||
|
|
||||||
|
ipi = (struct in6_pktinfo *) CMSG_DATA(cmsg);
|
||||||
|
memcpy(&ipi->ipi6_addr.s6_addr, &remote_addr->local_ip_addr.addr.in6,
|
||||||
|
sizeof(ipi->ipi6_addr.s6_addr));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
LOG(LOGS_INFO, LOGF_NtpIO, "sending to %s:%d from %s",
|
LOG(LOGS_INFO, LOGF_NtpIO, "sending to %s:%d from %s",
|
||||||
UTI_IPToString(&remote_addr->ip_addr), remote_addr->port, UTI_IPToString(&remote_addr->local_ip_addr));
|
UTI_IPToString(&remote_addr->ip_addr), remote_addr->port, UTI_IPToString(&remote_addr->local_ip_addr));
|
||||||
|
|||||||
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "ntp_sources.h"
|
#include "ntp_sources.h"
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
integer endianness within the structures.
|
integer endianness within the structures.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|||||||
36
refclock.c
36
refclock.c
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "refclock.h"
|
#include "refclock.h"
|
||||||
#include "reference.h"
|
#include "reference.h"
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
@@ -72,8 +74,8 @@ struct RCL_Instance_Record {
|
|||||||
int leap_status;
|
int leap_status;
|
||||||
int pps_rate;
|
int pps_rate;
|
||||||
struct MedianFilter filter;
|
struct MedianFilter filter;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
unsigned long lock_ref;
|
uint32_t lock_ref;
|
||||||
double offset;
|
double offset;
|
||||||
double delay;
|
double delay;
|
||||||
double precision;
|
double precision;
|
||||||
@@ -148,14 +150,14 @@ RCL_AddRefclock(RefclockParameters *params)
|
|||||||
if (n_sources == MAX_RCL_SOURCES)
|
if (n_sources == MAX_RCL_SOURCES)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (strncmp(params->driver_name, "SHM", 4) == 0) {
|
if (strcmp(params->driver_name, "SHM") == 0) {
|
||||||
inst->driver = &RCL_SHM_driver;
|
inst->driver = &RCL_SHM_driver;
|
||||||
inst->precision = 1e-6;
|
inst->precision = 1e-6;
|
||||||
} else if (strncmp(params->driver_name, "SOCK", 4) == 0) {
|
} else if (strcmp(params->driver_name, "SOCK") == 0) {
|
||||||
inst->driver = &RCL_SOCK_driver;
|
inst->driver = &RCL_SOCK_driver;
|
||||||
inst->precision = 1e-9;
|
inst->precision = 1e-9;
|
||||||
pps_source = 1;
|
pps_source = 1;
|
||||||
} else if (strncmp(params->driver_name, "PPS", 4) == 0) {
|
} else if (strcmp(params->driver_name, "PPS") == 0) {
|
||||||
inst->driver = &RCL_PPS_driver;
|
inst->driver = &RCL_PPS_driver;
|
||||||
inst->precision = 1e-9;
|
inst->precision = 1e-9;
|
||||||
pps_source = 1;
|
pps_source = 1;
|
||||||
@@ -175,7 +177,7 @@ RCL_AddRefclock(RefclockParameters *params)
|
|||||||
inst->driver_poll = params->driver_poll;
|
inst->driver_poll = params->driver_poll;
|
||||||
inst->poll = params->poll;
|
inst->poll = params->poll;
|
||||||
inst->driver_polled = 0;
|
inst->driver_polled = 0;
|
||||||
inst->leap_status = 0;
|
inst->leap_status = LEAP_Normal;
|
||||||
inst->pps_rate = params->pps_rate;
|
inst->pps_rate = params->pps_rate;
|
||||||
inst->lock_ref = params->lock_ref_id;
|
inst->lock_ref = params->lock_ref_id;
|
||||||
inst->offset = params->offset;
|
inst->offset = params->offset;
|
||||||
@@ -242,6 +244,8 @@ RCL_AddRefclock(RefclockParameters *params)
|
|||||||
#endif
|
#endif
|
||||||
n_sources++;
|
n_sources++;
|
||||||
|
|
||||||
|
Free(params->driver_name);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,7 +279,7 @@ void
|
|||||||
RCL_ReportSource(RPT_SourceReport *report, struct timeval *now)
|
RCL_ReportSource(RPT_SourceReport *report, struct timeval *now)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
|
|
||||||
assert(report->ip_addr.family == IPADDR_INET4);
|
assert(report->ip_addr.family == IPADDR_INET4);
|
||||||
ref_id = report->ip_addr.addr.in4;
|
ref_id = report->ip_addr.addr.in4;
|
||||||
@@ -334,7 +338,7 @@ RCL_GetDriverOption(RCL_Instance instance, char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset, NTP_Leap leap_status)
|
RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset, int leap)
|
||||||
{
|
{
|
||||||
double correction, dispersion;
|
double correction, dispersion;
|
||||||
struct timeval cooked_time;
|
struct timeval cooked_time;
|
||||||
@@ -347,7 +351,17 @@ RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset,
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
filter_add_sample(&instance->filter, &cooked_time, offset - correction + instance->offset, dispersion);
|
filter_add_sample(&instance->filter, &cooked_time, offset - correction + instance->offset, dispersion);
|
||||||
instance->leap_status = leap_status;
|
|
||||||
|
switch (leap) {
|
||||||
|
case LEAP_Normal:
|
||||||
|
case LEAP_InsertSecond:
|
||||||
|
case LEAP_DeleteSecond:
|
||||||
|
instance->leap_status = leap;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
instance->leap_status = LEAP_Unsynchronised;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
log_sample(instance, &cooked_time, 0, 0, offset, offset - correction + instance->offset, dispersion);
|
log_sample(instance, &cooked_time, 0, 0, offset, offset - correction + instance->offset, dispersion);
|
||||||
|
|
||||||
@@ -416,7 +430,7 @@ RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second)
|
|||||||
int is_synchronised, stratum;
|
int is_synchronised, stratum;
|
||||||
double root_delay, root_dispersion, distance;
|
double root_delay, root_dispersion, distance;
|
||||||
NTP_Leap leap;
|
NTP_Leap leap;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
|
|
||||||
/* Ignore the pulse if we are not well synchronized */
|
/* Ignore the pulse if we are not well synchronized */
|
||||||
|
|
||||||
@@ -467,7 +481,7 @@ pps_stratum(RCL_Instance instance, struct timeval *tv)
|
|||||||
int is_synchronised, stratum, i;
|
int is_synchronised, stratum, i;
|
||||||
double root_delay, root_dispersion;
|
double root_delay, root_dispersion;
|
||||||
NTP_Leap leap;
|
NTP_Leap leap;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
|
|
||||||
REF_GetReferenceParams(tv, &is_synchronised, &leap, &stratum,
|
REF_GetReferenceParams(tv, &is_synchronised, &leap, &stratum,
|
||||||
&ref_id, &ref_time, &root_delay, &root_dispersion);
|
&ref_id, &ref_time, &root_delay, &root_dispersion);
|
||||||
|
|||||||
@@ -32,14 +32,14 @@
|
|||||||
#include "sources.h"
|
#include "sources.h"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char driver_name[4];
|
char *driver_name;
|
||||||
char *driver_parameter;
|
char *driver_parameter;
|
||||||
int driver_poll;
|
int driver_poll;
|
||||||
int poll;
|
int poll;
|
||||||
int filter_length;
|
int filter_length;
|
||||||
int pps_rate;
|
int pps_rate;
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
unsigned long lock_ref_id;
|
uint32_t lock_ref_id;
|
||||||
double offset;
|
double offset;
|
||||||
double delay;
|
double delay;
|
||||||
double precision;
|
double precision;
|
||||||
@@ -66,7 +66,7 @@ extern void RCL_SetDriverData(RCL_Instance instance, void *data);
|
|||||||
extern void *RCL_GetDriverData(RCL_Instance instance);
|
extern void *RCL_GetDriverData(RCL_Instance instance);
|
||||||
extern char *RCL_GetDriverParameter(RCL_Instance instance);
|
extern char *RCL_GetDriverParameter(RCL_Instance instance);
|
||||||
extern char *RCL_GetDriverOption(RCL_Instance instance, char *name);
|
extern char *RCL_GetDriverOption(RCL_Instance instance, char *name);
|
||||||
extern int RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset, NTP_Leap leap_status);
|
extern int RCL_AddSample(RCL_Instance instance, struct timeval *sample_time, double offset, int leap);
|
||||||
extern int RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second);
|
extern int RCL_AddPulse(RCL_Instance instance, struct timeval *pulse_time, double second);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "refclock.h"
|
#include "refclock.h"
|
||||||
|
|
||||||
#if HAVE_PPSAPI
|
#if HAVE_PPSAPI
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "refclock.h"
|
#include "refclock.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "refclock.h"
|
#include "refclock.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|||||||
26
reference.c
26
reference.c
@@ -25,6 +25,8 @@
|
|||||||
This module keeps track of the source which we are claiming to be
|
This module keeps track of the source which we are claiming to be
|
||||||
our reference, for the purposes of generating outgoing NTP packets */
|
our reference, for the purposes of generating outgoing NTP packets */
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
@@ -43,7 +45,7 @@ static int local_stratum;
|
|||||||
static NTP_Leap our_leap_status;
|
static NTP_Leap our_leap_status;
|
||||||
static int our_leap_sec;
|
static int our_leap_sec;
|
||||||
static int our_stratum;
|
static int our_stratum;
|
||||||
static unsigned long our_ref_id;
|
static uint32_t our_ref_id;
|
||||||
static IPAddr our_ref_ip;
|
static IPAddr our_ref_ip;
|
||||||
struct timeval our_ref_time; /* Stored relative to reference, NOT local time */
|
struct timeval our_ref_time; /* Stored relative to reference, NOT local time */
|
||||||
static double our_offset;
|
static double our_offset;
|
||||||
@@ -76,8 +78,6 @@ static double drift_file_age;
|
|||||||
|
|
||||||
static void update_drift_file(double, double);
|
static void update_drift_file(double, double);
|
||||||
|
|
||||||
#define MAIL_PROGRAM "/usr/lib/sendmail"
|
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
static LOG_FileID logfileid;
|
static LOG_FileID logfileid;
|
||||||
@@ -127,6 +127,7 @@ REF_Initialise(void)
|
|||||||
our_frequency_ppm = 0.0;
|
our_frequency_ppm = 0.0;
|
||||||
our_skew = 1.0; /* i.e. rather bad */
|
our_skew = 1.0; /* i.e. rather bad */
|
||||||
our_residual_freq = 0.0;
|
our_residual_freq = 0.0;
|
||||||
|
drift_file_age = 0.0;
|
||||||
|
|
||||||
/* Now see if we can get the drift file opened */
|
/* Now see if we can get the drift file opened */
|
||||||
drift_file = CNF_GetDriftFile();
|
drift_file = CNF_GetDriftFile();
|
||||||
@@ -139,6 +140,8 @@ REF_Initialise(void)
|
|||||||
our_frequency_ppm = file_freq_ppm;
|
our_frequency_ppm = file_freq_ppm;
|
||||||
our_skew = 1.0e-6 * file_skew_ppm;
|
our_skew = 1.0e-6 * file_skew_ppm;
|
||||||
LOG(LOGS_INFO, LOGF_Reference, "Frequency %.3f +- %.3f ppm read from %s", file_freq_ppm, file_skew_ppm, drift_file);
|
LOG(LOGS_INFO, LOGF_Reference, "Frequency %.3f +- %.3f ppm read from %s", file_freq_ppm, file_skew_ppm, drift_file);
|
||||||
|
LCL_SetAbsoluteFrequency(our_frequency_ppm);
|
||||||
|
LCL_ReadCookedTime(&last_ref_update, NULL);
|
||||||
} else {
|
} else {
|
||||||
LOG(LOGS_WARN, LOGF_Reference, "Could not parse valid frequency and skew from driftfile %s",
|
LOG(LOGS_WARN, LOGF_Reference, "Could not parse valid frequency and skew from driftfile %s",
|
||||||
drift_file);
|
drift_file);
|
||||||
@@ -149,11 +152,14 @@ REF_Initialise(void)
|
|||||||
}
|
}
|
||||||
fclose(in);
|
fclose(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
drift_file_age = 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LCL_SetAbsoluteFrequency(our_frequency_ppm);
|
if (our_frequency_ppm == 0.0) {
|
||||||
|
our_frequency_ppm = LCL_ReadAbsoluteFrequency();
|
||||||
|
if (our_frequency_ppm != 0.0) {
|
||||||
|
LOG(LOGS_INFO, LOGF_Reference, "Initial frequency %.3f ppm", our_frequency_ppm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logfileid = CNF_GetLogTracking() ? LOG_FileOpen("tracking",
|
logfileid = CNF_GetLogTracking() ? LOG_FileOpen("tracking",
|
||||||
" Date (UTC) Time IP Address St Freq ppm Skew ppm Offset")
|
" Date (UTC) Time IP Address St Freq ppm Skew ppm Offset")
|
||||||
@@ -514,7 +520,7 @@ write_log(struct timeval *ref_time, char *ref, int stratum, double freq, double
|
|||||||
void
|
void
|
||||||
REF_SetReference(int stratum,
|
REF_SetReference(int stratum,
|
||||||
NTP_Leap leap,
|
NTP_Leap leap,
|
||||||
unsigned long ref_id,
|
uint32_t ref_id,
|
||||||
IPAddr *ref_ip,
|
IPAddr *ref_ip,
|
||||||
struct timeval *ref_time,
|
struct timeval *ref_time,
|
||||||
double offset,
|
double offset,
|
||||||
@@ -739,7 +745,7 @@ REF_GetReferenceParams
|
|||||||
int *is_synchronised,
|
int *is_synchronised,
|
||||||
NTP_Leap *leap_status,
|
NTP_Leap *leap_status,
|
||||||
int *stratum,
|
int *stratum,
|
||||||
unsigned long *ref_id,
|
uint32_t *ref_id,
|
||||||
struct timeval *ref_time,
|
struct timeval *ref_time,
|
||||||
double *root_delay,
|
double *root_delay,
|
||||||
double *root_dispersion
|
double *root_dispersion
|
||||||
@@ -792,7 +798,7 @@ REF_GetReferenceParams
|
|||||||
|
|
||||||
*leap_status = LEAP_Unsynchronised;
|
*leap_status = LEAP_Unsynchronised;
|
||||||
*stratum = 0;
|
*stratum = 0;
|
||||||
*ref_id = 0UL;
|
*ref_id = 0;
|
||||||
ref_time->tv_sec = ref_time->tv_usec = 0;
|
ref_time->tv_sec = ref_time->tv_usec = 0;
|
||||||
/* These values seem to be standard for a client, and
|
/* These values seem to be standard for a client, and
|
||||||
any peer or client of ours will ignore them anyway because
|
any peer or client of ours will ignore them anyway because
|
||||||
@@ -898,7 +904,7 @@ REF_GetTrackingReport(RPT_TrackingReport *rep)
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
rep->ref_id = 0UL;
|
rep->ref_id = 0;
|
||||||
rep->ip_addr.family = IPADDR_UNSPEC;
|
rep->ip_addr.family = IPADDR_UNSPEC;
|
||||||
rep->stratum = 0;
|
rep->stratum = 0;
|
||||||
rep->ref_time.tv_sec = 0;
|
rep->ref_time.tv_sec = 0;
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ extern void REF_GetReferenceParams
|
|||||||
int *is_synchronised,
|
int *is_synchronised,
|
||||||
NTP_Leap *leap,
|
NTP_Leap *leap,
|
||||||
int *stratum,
|
int *stratum,
|
||||||
unsigned long *ref_id,
|
uint32_t *ref_id,
|
||||||
struct timeval *ref_time,
|
struct timeval *ref_time,
|
||||||
double *root_delay,
|
double *root_delay,
|
||||||
double *root_dispersion
|
double *root_dispersion
|
||||||
@@ -105,7 +105,7 @@ extern void REF_SetReference
|
|||||||
(
|
(
|
||||||
int stratum,
|
int stratum,
|
||||||
NTP_Leap leap,
|
NTP_Leap leap,
|
||||||
unsigned long ref_id,
|
uint32_t ref_id,
|
||||||
IPAddr *ref_ip,
|
IPAddr *ref_ip,
|
||||||
struct timeval *ref_time,
|
struct timeval *ref_time,
|
||||||
double offset,
|
double offset,
|
||||||
|
|||||||
14
regress.c
14
regress.c
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
@@ -232,7 +234,6 @@ RGR_FindBestRegression
|
|||||||
double *b0, /* estimated y axis intercept */
|
double *b0, /* estimated y axis intercept */
|
||||||
double *b1, /* estimated slope */
|
double *b1, /* estimated slope */
|
||||||
double *s2, /* estimated variance of data points */
|
double *s2, /* estimated variance of data points */
|
||||||
double *us2, /* estimated unweighted variance of data points */
|
|
||||||
|
|
||||||
double *sb0, /* estimated standard deviation of
|
double *sb0, /* estimated standard deviation of
|
||||||
intercept */
|
intercept */
|
||||||
@@ -251,7 +252,7 @@ RGR_FindBestRegression
|
|||||||
{
|
{
|
||||||
double P, Q, U, V, W; /* total */
|
double P, Q, U, V, W; /* total */
|
||||||
double resid[MAX_POINTS * REGRESS_RUNS_RATIO];
|
double resid[MAX_POINTS * REGRESS_RUNS_RATIO];
|
||||||
double ss, uss;
|
double ss;
|
||||||
double a, b, u, ui, aa;
|
double a, b, u, ui, aa;
|
||||||
|
|
||||||
int start, resid_start, nruns, npoints;
|
int start, resid_start, nruns, npoints;
|
||||||
@@ -315,20 +316,17 @@ RGR_FindBestRegression
|
|||||||
*b1 = b;
|
*b1 = b;
|
||||||
*b0 = a;
|
*b0 = a;
|
||||||
|
|
||||||
ss = uss = 0.0;
|
ss = 0.0;
|
||||||
for (i=start; i<n; i++) {
|
for (i=start; i<n; i++) {
|
||||||
ss += resid[i - resid_start]*resid[i - resid_start] / w[i];
|
ss += resid[i - resid_start]*resid[i - resid_start] / w[i];
|
||||||
uss += resid[i - resid_start]*resid[i - resid_start];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
npoints = n - start;
|
npoints = n - start;
|
||||||
ss /= npoints - 2;
|
ss /= (double)(npoints - 2);
|
||||||
uss /= npoints - 2;
|
|
||||||
*sb1 = sqrt(ss / V);
|
*sb1 = sqrt(ss / V);
|
||||||
aa = u * (*sb1);
|
aa = u * (*sb1);
|
||||||
*sb0 = sqrt((ss / W) + (aa * aa));
|
*sb0 = sqrt((ss / W) + (aa * aa));
|
||||||
*s2 = ss * npoints / W;
|
*s2 = ss * (double) npoints / W;
|
||||||
*us2 = uss;
|
|
||||||
|
|
||||||
*new_start = start;
|
*new_start = start;
|
||||||
*dof = npoints - 2;
|
*dof = npoints - 2;
|
||||||
|
|||||||
@@ -86,7 +86,6 @@ RGR_FindBestRegression
|
|||||||
double *b0, /* estimated y axis intercept */
|
double *b0, /* estimated y axis intercept */
|
||||||
double *b1, /* estimated slope */
|
double *b1, /* estimated slope */
|
||||||
double *s2, /* estimated variance of data points */
|
double *s2, /* estimated variance of data points */
|
||||||
double *us2, /* estimated unweighted variance of data points */
|
|
||||||
|
|
||||||
double *sb0, /* estimated standard deviation of
|
double *sb0, /* estimated standard deviation of
|
||||||
intercept */
|
intercept */
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ typedef struct {
|
|||||||
} RPT_SourceReport ;
|
} RPT_SourceReport ;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
unsigned long stratum;
|
unsigned long stratum;
|
||||||
struct timeval ref_time;
|
struct timeval ref_time;
|
||||||
@@ -59,7 +59,7 @@ typedef struct {
|
|||||||
} RPT_TrackingReport;
|
} RPT_TrackingReport;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
unsigned long ref_id;
|
uint32_t ref_id;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
unsigned long n_samples;
|
unsigned long n_samples;
|
||||||
unsigned long n_runs;
|
unsigned long n_runs;
|
||||||
|
|||||||
2
rtc.c
2
rtc.c
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "rtc.h"
|
#include "rtc.h"
|
||||||
|
|||||||
58
rtc_linux.c
58
rtc_linux.c
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#if defined LINUX
|
#if defined LINUX
|
||||||
|
|
||||||
#ifdef sparc
|
#ifdef sparc
|
||||||
@@ -505,62 +507,6 @@ write_coefs_to_file(int valid,time_t ref_time,double offset,double rate)
|
|||||||
int
|
int
|
||||||
RTC_Linux_Initialise(void)
|
RTC_Linux_Initialise(void)
|
||||||
{
|
{
|
||||||
int major, minor, patch;
|
|
||||||
|
|
||||||
/* Check whether we can support the real time clock.
|
|
||||||
|
|
||||||
Linux 1.2.x - haven't checked yet
|
|
||||||
|
|
||||||
Linux 1.3.x - don't know, haven't got a system to look at
|
|
||||||
|
|
||||||
Linux 2.0.x - For x<=31, using any variant of the adjtimex() call
|
|
||||||
sets the kernel into a mode where the RTC was updated every 11
|
|
||||||
minutes. The only way to escape this is to use settimeofday().
|
|
||||||
Since we need to have sole control over the RTC to be able to
|
|
||||||
measure its drift rate, and there is no 'notify' callback to warn
|
|
||||||
you that the kernel is going to do this, I can't see a way to
|
|
||||||
support this.
|
|
||||||
|
|
||||||
Linux 2.0.x - For x>=32 the adjtimex()/RTC behaviour was
|
|
||||||
modified, so that as long as the STA_UNSYNC flag is set the RTC
|
|
||||||
is left alone. This is the mode we exploit here, so that the RTC
|
|
||||||
continues to go its own sweet way, unless we make updates to it
|
|
||||||
from this module.
|
|
||||||
|
|
||||||
Linux 2.1.x - don't know, haven't got a system to look at.
|
|
||||||
|
|
||||||
Linux 2.2.x, 2.3.x and 2.4.x are believed to be OK for all
|
|
||||||
patch levels
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
SYS_Linux_GetKernelVersion(&major, &minor, &patch);
|
|
||||||
|
|
||||||
/* Obviously this test can get more elaborate when we know about
|
|
||||||
more system types. */
|
|
||||||
if (major != 2) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
switch (minor) {
|
|
||||||
case 0:
|
|
||||||
if (patch <= 31) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
break; /* OK for all patch levels */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Setup details depending on configuration options */
|
/* Setup details depending on configuration options */
|
||||||
setup_config();
|
setup_config();
|
||||||
|
|
||||||
|
|||||||
104
sched.c
104
sched.c
@@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
@@ -68,9 +70,9 @@ typedef struct {
|
|||||||
|
|
||||||
static FileHandlerEntry file_handlers[FD_SET_SIZE];
|
static FileHandlerEntry file_handlers[FD_SET_SIZE];
|
||||||
|
|
||||||
/* Last timestamp when a file descriptor became readable */
|
/* Timestamp when last select() returned */
|
||||||
static struct timeval last_fdready;
|
static struct timeval last_select_ts, last_select_ts_raw;
|
||||||
static double last_fdready_err;
|
static double last_select_ts_err;
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
@@ -227,9 +229,9 @@ SCH_RemoveInputFileHandler(int fd)
|
|||||||
void
|
void
|
||||||
SCH_GetFileReadyTime(struct timeval *tv, double *err)
|
SCH_GetFileReadyTime(struct timeval *tv, double *err)
|
||||||
{
|
{
|
||||||
*tv = last_fdready;
|
*tv = last_select_ts;
|
||||||
if (err)
|
if (err)
|
||||||
*err = last_fdready_err;
|
*err = last_select_ts_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -316,6 +318,7 @@ SCH_AddTimeoutByDelay(double delay, SCH_TimeoutHandler handler, SCH_ArbitraryArg
|
|||||||
struct timeval now, then;
|
struct timeval now, then;
|
||||||
|
|
||||||
assert(initialised);
|
assert(initialised);
|
||||||
|
assert(delay >= 0.0);
|
||||||
|
|
||||||
LCL_ReadRawTime(&now);
|
LCL_ReadRawTime(&now);
|
||||||
UTI_AddDoubleToTimeval(&now, delay, &then);
|
UTI_AddDoubleToTimeval(&now, delay, &then);
|
||||||
@@ -337,6 +340,7 @@ SCH_AddTimeoutInClass(double min_delay, double separation, double randomness,
|
|||||||
double new_min_delay;
|
double new_min_delay;
|
||||||
|
|
||||||
assert(initialised);
|
assert(initialised);
|
||||||
|
assert(min_delay >= 0.0);
|
||||||
assert(class < SCH_NumberOfClasses);
|
assert(class < SCH_NumberOfClasses);
|
||||||
|
|
||||||
if (randomness > 0.0) {
|
if (randomness > 0.0) {
|
||||||
@@ -426,18 +430,26 @@ SCH_RemoveTimeout(SCH_TimeoutID id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* The current time (now) has to be passed in from the
|
/* Try to dispatch any timeouts that have already gone by, and
|
||||||
caller to avoid race conditions */
|
keep going until all are done. (The earlier ones may take so
|
||||||
|
long to do that the later ones come around by the time they are
|
||||||
|
completed). */
|
||||||
|
|
||||||
static int
|
static void
|
||||||
dispatch_timeouts(struct timeval *now) {
|
dispatch_timeouts(struct timeval *now) {
|
||||||
TimerQueueEntry *ptr;
|
TimerQueueEntry *ptr;
|
||||||
SCH_TimeoutHandler handler;
|
SCH_TimeoutHandler handler;
|
||||||
SCH_ArbitraryArgument arg;
|
SCH_ArbitraryArgument arg;
|
||||||
int n_done = 0;
|
int n_done = 0, n_entries_on_start = n_timer_queue_entries;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
LCL_ReadRawTime(now);
|
||||||
|
|
||||||
|
if (!(n_timer_queue_entries > 0 &&
|
||||||
|
UTI_CompareTimevals(now, &(timer_queue.next->tv)) >= 0)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if ((n_timer_queue_entries > 0) &&
|
|
||||||
(UTI_CompareTimevals(now, &(timer_queue.next->tv)) >= 0)) {
|
|
||||||
ptr = timer_queue.next;
|
ptr = timer_queue.next;
|
||||||
|
|
||||||
last_class_dispatch[ptr->class] = *now;
|
last_class_dispatch[ptr->class] = *now;
|
||||||
@@ -452,10 +464,16 @@ dispatch_timeouts(struct timeval *now) {
|
|||||||
|
|
||||||
/* Increment count of timeouts handled */
|
/* Increment count of timeouts handled */
|
||||||
++n_done;
|
++n_done;
|
||||||
|
|
||||||
|
/* If more timeouts were handled than there were in the timer queue on
|
||||||
|
start, assume some code is scheduling timeouts with negative delays and
|
||||||
|
abort. Make the actual limit higher in case the machine is temporarily
|
||||||
|
overloaded and dispatching the handlers takes more time than was delay
|
||||||
|
of a scheduled timeout. */
|
||||||
|
if (n_done > n_entries_on_start * 4) {
|
||||||
|
LOG_FATAL(LOGF_Scheduler, "Possible infinite loop in scheduling");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return n_done;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -507,18 +525,50 @@ handle_slew(struct timeval *raw,
|
|||||||
for (i = 0; i < SCH_NumberOfClasses; i++) {
|
for (i = 0; i < SCH_NumberOfClasses; i++) {
|
||||||
UTI_AddDoubleToTimeval(&last_class_dispatch[i], -doffset, &last_class_dispatch[i]);
|
UTI_AddDoubleToTimeval(&last_class_dispatch[i], -doffset, &last_class_dispatch[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UTI_AddDoubleToTimeval(&last_select_ts_raw, -doffset, &last_select_ts_raw);
|
||||||
|
UTI_AddDoubleToTimeval(&last_select_ts, -doffset, &last_select_ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
/* Try to handle unexpected backward time jump */
|
||||||
|
|
||||||
|
static void
|
||||||
|
recover_backjump(struct timeval *raw, struct timeval *cooked, int timeout)
|
||||||
|
{
|
||||||
|
double diff, err;
|
||||||
|
|
||||||
|
UTI_DiffTimevalsToDouble(&diff, &last_select_ts_raw, raw);
|
||||||
|
|
||||||
|
if (n_timer_queue_entries > 0) {
|
||||||
|
UTI_DiffTimevalsToDouble(&err, &(timer_queue.next->tv), &last_select_ts_raw);
|
||||||
|
} else {
|
||||||
|
err = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff += err;
|
||||||
|
|
||||||
|
if (timeout) {
|
||||||
|
err = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG(LOGS_WARN, LOGF_Scheduler, "Backward time jump detected! (correction %.1f +- %.1f seconds)", diff, err);
|
||||||
|
|
||||||
|
LCL_NotifyExternalTimeStep(raw, cooked, diff, err);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
SCH_MainLoop(void)
|
SCH_MainLoop(void)
|
||||||
{
|
{
|
||||||
fd_set rd;
|
fd_set rd;
|
||||||
int status;
|
int status;
|
||||||
struct timeval tv, *ptv;
|
struct timeval tv, *ptv;
|
||||||
struct timeval now;
|
struct timeval now, cooked;
|
||||||
|
double err;
|
||||||
|
|
||||||
assert(initialised);
|
assert(initialised);
|
||||||
|
|
||||||
@@ -527,20 +577,15 @@ SCH_MainLoop(void)
|
|||||||
/* Copy current set of read file descriptors */
|
/* Copy current set of read file descriptors */
|
||||||
memcpy((void *) &rd, (void *) &read_fds, sizeof(fd_set));
|
memcpy((void *) &rd, (void *) &read_fds, sizeof(fd_set));
|
||||||
|
|
||||||
/* Try to dispatch any timeouts that have already gone by, and
|
/* Dispatch timeouts and fill now with current raw time */
|
||||||
keep going until all are done. (The earlier ones may take so
|
dispatch_timeouts(&now);
|
||||||
long to do that the later ones come around by the time they are
|
|
||||||
completed). */
|
|
||||||
|
|
||||||
do {
|
|
||||||
LCL_ReadRawTime(&now);
|
|
||||||
} while (dispatch_timeouts(&now) > 0);
|
|
||||||
|
|
||||||
/* Check whether there is a timeout and set it up */
|
/* Check whether there is a timeout and set it up */
|
||||||
if (n_timer_queue_entries > 0) {
|
if (n_timer_queue_entries > 0) {
|
||||||
|
|
||||||
UTI_DiffTimevals(&tv, &(timer_queue.next->tv), &now);
|
UTI_DiffTimevals(&tv, &(timer_queue.next->tv), &now);
|
||||||
ptv = &tv;
|
ptv = &tv;
|
||||||
|
assert(tv.tv_sec > 0 || tv.tv_usec > 0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ptv = NULL;
|
ptv = NULL;
|
||||||
@@ -555,12 +600,23 @@ SCH_MainLoop(void)
|
|||||||
|
|
||||||
status = select(one_highest_fd, &rd, NULL, NULL, ptv);
|
status = select(one_highest_fd, &rd, NULL, NULL, ptv);
|
||||||
|
|
||||||
|
LCL_ReadRawTime(&now);
|
||||||
|
LCL_CookTime(&now, &cooked, &err);
|
||||||
|
|
||||||
|
/* Check if time didn't jump backwards */
|
||||||
|
if (last_select_ts_raw.tv_sec > now.tv_sec + 1) {
|
||||||
|
recover_backjump(&now, &cooked, status == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
last_select_ts_raw = now;
|
||||||
|
last_select_ts = cooked;
|
||||||
|
last_select_ts_err = err;
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
assert(need_to_exit);
|
assert(need_to_exit);
|
||||||
} else if (status > 0) {
|
} else if (status > 0) {
|
||||||
/* A file descriptor is ready to read */
|
/* A file descriptor is ready to read */
|
||||||
|
|
||||||
LCL_ReadCookedTime(&last_fdready, &last_fdready_err);
|
|
||||||
dispatch_filehandlers(status, &rd);
|
dispatch_filehandlers(status, &rd);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
22
sources.c
22
sources.c
@@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "sources.h"
|
#include "sources.h"
|
||||||
@@ -82,8 +84,8 @@ struct SRC_Instance_Record {
|
|||||||
SST_Stats stats;
|
SST_Stats stats;
|
||||||
NTP_Leap leap_status; /* Leap status */
|
NTP_Leap leap_status; /* Leap status */
|
||||||
int index; /* Index back into the array of source */
|
int index; /* Index back into the array of source */
|
||||||
unsigned long ref_id; /* The reference ID of this source
|
uint32_t ref_id; /* The reference ID of this source
|
||||||
(i.e. its IP address, NOT the
|
(i.e. from its IP address, NOT the
|
||||||
reference _it_ is sync'd to) */
|
reference _it_ is sync'd to) */
|
||||||
IPAddr *ip_addr; /* Its IP address if NTP source */
|
IPAddr *ip_addr; /* Its IP address if NTP source */
|
||||||
|
|
||||||
@@ -181,7 +183,7 @@ void SRC_Finalise(void)
|
|||||||
/* Function to create a new instance. This would be called by one of
|
/* Function to create a new instance. This would be called by one of
|
||||||
the individual source-type instance creation routines. */
|
the individual source-type instance creation routines. */
|
||||||
|
|
||||||
SRC_Instance SRC_CreateNewInstance(unsigned long ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr)
|
SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr)
|
||||||
{
|
{
|
||||||
SRC_Instance result;
|
SRC_Instance result;
|
||||||
|
|
||||||
@@ -418,10 +420,10 @@ source_to_string(SRC_Instance inst)
|
|||||||
of sources we are holding.
|
of sources we are holding.
|
||||||
|
|
||||||
Updates are only made to the local reference if a new source is selected
|
Updates are only made to the local reference if a new source is selected
|
||||||
or match_addr is equal to the selected reference source address */
|
or match_refid is equal to the selected reference source refid */
|
||||||
|
|
||||||
void
|
void
|
||||||
SRC_SelectSource(unsigned long match_addr)
|
SRC_SelectSource(uint32_t match_refid)
|
||||||
{
|
{
|
||||||
int i, j, index, old_selected_index;
|
int i, j, index, old_selected_index;
|
||||||
struct timeval now, ref_time;
|
struct timeval now, ref_time;
|
||||||
@@ -781,8 +783,8 @@ SRC_SelectSource(unsigned long match_addr)
|
|||||||
|
|
||||||
/* Update score, but only for source pairs where one source
|
/* Update score, but only for source pairs where one source
|
||||||
has a new sample */
|
has a new sample */
|
||||||
if (sources[i]->ref_id == match_addr ||
|
if (sources[i]->ref_id == match_refid ||
|
||||||
sources[selected_source_index]->ref_id == match_addr) {
|
sources[selected_source_index]->ref_id == match_refid) {
|
||||||
|
|
||||||
sources[i]->sel_score *= sel_src_distance / distance;
|
sources[i]->sel_score *= sel_src_distance / distance;
|
||||||
|
|
||||||
@@ -801,7 +803,7 @@ SRC_SelectSource(unsigned long match_addr)
|
|||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
LOG(LOGS_INFO, LOGF_Sources, "select score=%f refid=%lx match_refid=%lx status=%d dist=%f",
|
LOG(LOGS_INFO, LOGF_Sources, "select score=%f refid=%lx match_refid=%lx status=%d dist=%f",
|
||||||
sources[i]->sel_score, sources[i]->ref_id, match_addr, sources[i]->status, distance);
|
sources[i]->sel_score, sources[i]->ref_id, match_refid, sources[i]->status, distance);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (max_score < sources[i]->sel_score) {
|
if (max_score < sources[i]->sel_score) {
|
||||||
@@ -838,9 +840,9 @@ SRC_SelectSource(unsigned long match_addr)
|
|||||||
sources[selected_source_index]->status = SRC_SYNC;
|
sources[selected_source_index]->status = SRC_SYNC;
|
||||||
|
|
||||||
/* Update local reference only when a new source was selected or a new
|
/* Update local reference only when a new source was selected or a new
|
||||||
sample was received (i.e. match_addr is equal to selected ref_id) */
|
sample was received (i.e. match_refid is equal to selected refid) */
|
||||||
if (selected_source_index != old_selected_index ||
|
if (selected_source_index != old_selected_index ||
|
||||||
match_addr == sources[selected_source_index]->ref_id) {
|
match_refid == sources[selected_source_index]->ref_id) {
|
||||||
|
|
||||||
/* Now just use the statistics of the selected source for
|
/* Now just use the statistics of the selected source for
|
||||||
trimming the local clock */
|
trimming the local clock */
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ typedef enum {
|
|||||||
/* Function to create a new instance. This would be called by one of
|
/* Function to create a new instance. This would be called by one of
|
||||||
the individual source-type instance creation routines. */
|
the individual source-type instance creation routines. */
|
||||||
|
|
||||||
extern SRC_Instance SRC_CreateNewInstance(unsigned long ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr);
|
extern SRC_Instance SRC_CreateNewInstance(uint32_t ref_id, SRC_Type type, SRC_SelectOption sel_option, IPAddr *addr);
|
||||||
|
|
||||||
/* Function to get rid of a source when it is being unconfigured.
|
/* Function to get rid of a source when it is being unconfigured.
|
||||||
This may cause the current reference source to be reselected, if this
|
This may cause the current reference source to be reselected, if this
|
||||||
@@ -135,7 +135,7 @@ extern void SRC_ResetReachability(SRC_Instance inst);
|
|||||||
reference source address. (This avoids updating the frequency
|
reference source address. (This avoids updating the frequency
|
||||||
tracking for every sample from other sources - only the ones from
|
tracking for every sample from other sources - only the ones from
|
||||||
the selected reference make a difference) */
|
the selected reference make a difference) */
|
||||||
extern void SRC_SelectSource(unsigned long match_addr);
|
extern void SRC_SelectSource(uint32_t match_refid);
|
||||||
|
|
||||||
/* Force reselecting the best source */
|
/* Force reselecting the best source */
|
||||||
extern void SRC_ReselectSource(void);
|
extern void SRC_ReselectSource(void);
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
analysis on the samples obtained from the sources,
|
analysis on the samples obtained from the sources,
|
||||||
to determined frequencies and error bounds. */
|
to determined frequencies and error bounds. */
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "sourcestats.h"
|
#include "sourcestats.h"
|
||||||
@@ -56,7 +58,7 @@ static LOG_FileID logfileid;
|
|||||||
struct SST_Stats_Record {
|
struct SST_Stats_Record {
|
||||||
|
|
||||||
/* Reference ID and IP address of source, used for logging to statistics log */
|
/* Reference ID and IP address of source, used for logging to statistics log */
|
||||||
unsigned long refid;
|
uint32_t refid;
|
||||||
IPAddr *ip_addr;
|
IPAddr *ip_addr;
|
||||||
|
|
||||||
/* Number of samples currently stored. The samples are stored in circular
|
/* Number of samples currently stored. The samples are stored in circular
|
||||||
@@ -105,9 +107,6 @@ struct SST_Stats_Record {
|
|||||||
/* This is the estimated residual variance of the data points */
|
/* This is the estimated residual variance of the data points */
|
||||||
double variance;
|
double variance;
|
||||||
|
|
||||||
/* This is the estimated unweighted variance of the data points */
|
|
||||||
double uvariance;
|
|
||||||
|
|
||||||
/* This array contains the sample epochs, in terms of the local
|
/* This array contains the sample epochs, in terms of the local
|
||||||
clock. */
|
clock. */
|
||||||
struct timeval sample_times[MAX_SAMPLES * REGRESS_RUNS_RATIO];
|
struct timeval sample_times[MAX_SAMPLES * REGRESS_RUNS_RATIO];
|
||||||
@@ -174,7 +173,7 @@ SST_Finalise(void)
|
|||||||
/* This function creates a new instance of the statistics handler */
|
/* This function creates a new instance of the statistics handler */
|
||||||
|
|
||||||
SST_Stats
|
SST_Stats
|
||||||
SST_CreateInstance(unsigned long refid, IPAddr *addr)
|
SST_CreateInstance(uint32_t refid, IPAddr *addr)
|
||||||
{
|
{
|
||||||
SST_Stats inst;
|
SST_Stats inst;
|
||||||
inst = MallocNew(struct SST_Stats_Record);
|
inst = MallocNew(struct SST_Stats_Record);
|
||||||
@@ -193,7 +192,7 @@ SST_CreateInstance(unsigned long refid, IPAddr *addr)
|
|||||||
inst->estimated_offset_sd = 86400.0; /* Assume it's at least within a day! */
|
inst->estimated_offset_sd = 86400.0; /* Assume it's at least within a day! */
|
||||||
inst->offset_time.tv_sec = 0;
|
inst->offset_time.tv_sec = 0;
|
||||||
inst->offset_time.tv_usec = 0;
|
inst->offset_time.tv_usec = 0;
|
||||||
inst->variance = inst->uvariance = 16.0;
|
inst->variance = 16.0;
|
||||||
inst->nruns = 0;
|
inst->nruns = 0;
|
||||||
return inst;
|
return inst;
|
||||||
}
|
}
|
||||||
@@ -367,7 +366,7 @@ find_min_delay_sample(SST_Stats inst)
|
|||||||
time. E.g. a value of 4 means that we think the standard deviation
|
time. E.g. a value of 4 means that we think the standard deviation
|
||||||
is four times the fluctuation of the peer distance */
|
is four times the fluctuation of the peer distance */
|
||||||
|
|
||||||
#define SD_TO_DIST_RATIO 1.4
|
#define SD_TO_DIST_RATIO 1.0
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* This function runs the linear regression operation on the data. It
|
/* This function runs the linear regression operation on the data. It
|
||||||
@@ -385,9 +384,9 @@ SST_DoNewRegression(SST_Stats inst)
|
|||||||
|
|
||||||
int degrees_of_freedom;
|
int degrees_of_freedom;
|
||||||
int best_start, times_back_start;
|
int best_start, times_back_start;
|
||||||
double est_intercept, est_slope, est_var, est_uvar, est_intercept_sd, est_slope_sd;
|
double est_intercept, est_slope, est_var, est_intercept_sd, est_slope_sd;
|
||||||
int i, j, nruns;
|
int i, j, nruns;
|
||||||
double min_distance;
|
double min_distance, mean_distance;
|
||||||
double sd_weight, sd;
|
double sd_weight, sd;
|
||||||
double old_skew, old_freq, stress;
|
double old_skew, old_freq, stress;
|
||||||
|
|
||||||
@@ -398,17 +397,19 @@ SST_DoNewRegression(SST_Stats inst)
|
|||||||
offsets[i + inst->runs_samples] = inst->offsets[get_runsbuf_index(inst, i)];
|
offsets[i + inst->runs_samples] = inst->offsets[get_runsbuf_index(inst, i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, min_distance = DBL_MAX; i < inst->n_samples; i++) {
|
for (i = 0, mean_distance = 0.0, min_distance = DBL_MAX; i < inst->n_samples; i++) {
|
||||||
j = get_buf_index(inst, i);
|
j = get_buf_index(inst, i);
|
||||||
peer_distances[i] = 0.5 * inst->peer_delays[j] + inst->peer_dispersions[j];
|
peer_distances[i] = 0.5 * inst->peer_delays[j] + inst->peer_dispersions[j];
|
||||||
|
mean_distance += peer_distances[i];
|
||||||
if (peer_distances[i] < min_distance) {
|
if (peer_distances[i] < min_distance) {
|
||||||
min_distance = peer_distances[i];
|
min_distance = peer_distances[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mean_distance /= inst->n_samples;
|
||||||
|
|
||||||
/* And now, work out the weight vector */
|
/* And now, work out the weight vector */
|
||||||
|
|
||||||
sd = sqrt(inst->uvariance);
|
sd = mean_distance - min_distance;
|
||||||
if (sd > min_distance || sd <= 0.0)
|
if (sd > min_distance || sd <= 0.0)
|
||||||
sd = min_distance;
|
sd = min_distance;
|
||||||
|
|
||||||
@@ -421,7 +422,7 @@ SST_DoNewRegression(SST_Stats inst)
|
|||||||
inst->regression_ok = RGR_FindBestRegression(times_back + inst->runs_samples,
|
inst->regression_ok = RGR_FindBestRegression(times_back + inst->runs_samples,
|
||||||
offsets + inst->runs_samples, weights,
|
offsets + inst->runs_samples, weights,
|
||||||
inst->n_samples, inst->runs_samples,
|
inst->n_samples, inst->runs_samples,
|
||||||
&est_intercept, &est_slope, &est_var, &est_uvar,
|
&est_intercept, &est_slope, &est_var,
|
||||||
&est_intercept_sd, &est_slope_sd,
|
&est_intercept_sd, &est_slope_sd,
|
||||||
&best_start, &nruns, °rees_of_freedom);
|
&best_start, &nruns, °rees_of_freedom);
|
||||||
|
|
||||||
@@ -436,7 +437,6 @@ SST_DoNewRegression(SST_Stats inst)
|
|||||||
inst->offset_time = inst->sample_times[inst->last_sample];
|
inst->offset_time = inst->sample_times[inst->last_sample];
|
||||||
inst->estimated_offset_sd = est_intercept_sd;
|
inst->estimated_offset_sd = est_intercept_sd;
|
||||||
inst->variance = est_var;
|
inst->variance = est_var;
|
||||||
inst->uvariance = est_uvar;
|
|
||||||
inst->nruns = nruns;
|
inst->nruns = nruns;
|
||||||
|
|
||||||
stress = fabs(old_freq - inst->estimated_frequency) / old_skew;
|
stress = fabs(old_freq - inst->estimated_frequency) / old_skew;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ extern void SST_Initialise(void);
|
|||||||
extern void SST_Finalise(void);
|
extern void SST_Finalise(void);
|
||||||
|
|
||||||
/* This function creates a new instance of the statistics handler */
|
/* This function creates a new instance of the statistics handler */
|
||||||
extern SST_Stats SST_CreateInstance(unsigned long refid, IPAddr *addr);
|
extern SST_Stats SST_CreateInstance(uint32_t refid, IPAddr *addr);
|
||||||
|
|
||||||
/* This function deletes an instance of the statistics handler. */
|
/* This function deletes an instance of the statistics handler. */
|
||||||
extern void SST_DeleteInstance(SST_Stats inst);
|
extern void SST_DeleteInstance(SST_Stats inst);
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
Replacement strerror function for systems that don't have it
|
Replacement strerror function for systems that don't have it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef SUNOS
|
#ifdef SUNOS
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
2
sys.c
2
sys.c
@@ -25,6 +25,8 @@
|
|||||||
in the various operating-system specific modules
|
in the various operating-system specific modules
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sys.h"
|
#include "sys.h"
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
|
|||||||
238
sys_linux.c
238
sys_linux.c
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
@@ -104,8 +106,7 @@ static int version_patchlevel;
|
|||||||
/* Flag indicating whether adjtimex() returns the remaining time adjustment
|
/* Flag indicating whether adjtimex() returns the remaining time adjustment
|
||||||
or not. If not we have to read the outstanding adjustment by setting it to
|
or not. If not we have to read the outstanding adjustment by setting it to
|
||||||
zero, examining the return value and setting the outstanding adjustment back
|
zero, examining the return value and setting the outstanding adjustment back
|
||||||
again. If 1, txc.modes equal to zero is used to read the time. If 2,
|
again. */
|
||||||
txc.modes is set to ADJ_OFFSET_SS_READ. */
|
|
||||||
|
|
||||||
static int have_readonly_adjtime;
|
static int have_readonly_adjtime;
|
||||||
|
|
||||||
@@ -648,29 +649,11 @@ set_frequency(double freq_ppm)
|
|||||||
double scaled_freq; /* what adjtimex & the kernel use */
|
double scaled_freq; /* what adjtimex & the kernel use */
|
||||||
double old_total_tick;
|
double old_total_tick;
|
||||||
int required_delta_tick;
|
int required_delta_tick;
|
||||||
int neg; /* True if estimate is that local clock runs slow,
|
|
||||||
i.e. positive frequency correction required */
|
|
||||||
|
|
||||||
|
|
||||||
if (freq_ppm < 0.0) {
|
|
||||||
neg = 1;
|
|
||||||
freq_ppm = -freq_ppm;
|
|
||||||
} else {
|
|
||||||
neg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
required_delta_tick = our_round(freq_ppm / dhz);
|
required_delta_tick = our_round(freq_ppm / dhz);
|
||||||
required_freq = freq_ppm - dhz * (double) required_delta_tick;
|
required_freq = -(freq_ppm - dhz * required_delta_tick);
|
||||||
|
|
||||||
if (neg) {
|
|
||||||
/* Uncompensated local clock runs slow */
|
|
||||||
required_tick = nominal_tick + required_delta_tick;
|
|
||||||
scaled_freq = freq_scale * required_freq;
|
|
||||||
} else {
|
|
||||||
/* Uncompensated local clock runs fast */
|
|
||||||
required_tick = nominal_tick - required_delta_tick;
|
required_tick = nominal_tick - required_delta_tick;
|
||||||
scaled_freq = -freq_scale * required_freq;
|
scaled_freq = freq_scale * required_freq;
|
||||||
}
|
|
||||||
|
|
||||||
min_allowed_tick = nominal_tick - max_tick_bias;
|
min_allowed_tick = nominal_tick - max_tick_bias;
|
||||||
max_allowed_tick = nominal_tick + max_tick_bias;
|
max_allowed_tick = nominal_tick + max_tick_bias;
|
||||||
@@ -719,15 +702,17 @@ read_frequency(void)
|
|||||||
double tick_term;
|
double tick_term;
|
||||||
double unscaled_freq;
|
double unscaled_freq;
|
||||||
double freq_term;
|
double freq_term;
|
||||||
|
long tick;
|
||||||
|
|
||||||
if (TMX_GetFrequency(&unscaled_freq) < 0) {
|
if (TMX_GetFrequency(&unscaled_freq, &tick) < 0) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Use current_tick here rather than txc.tick, otherwise we're
|
if (fast_slewing) {
|
||||||
thrown off course when doing a fast slew (in which case, txc.tick
|
tick -= slewing_tick - current_tick;
|
||||||
is nowhere near the nominal value) */
|
}
|
||||||
tick_term = dhz * (double)(nominal_tick - current_tick);
|
|
||||||
|
tick_term = dhz * (double)(nominal_tick - tick);
|
||||||
freq_term = unscaled_freq / freq_scale;
|
freq_term = unscaled_freq / freq_scale;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -764,13 +749,11 @@ get_offset_correction(struct timeval *raw,
|
|||||||
if (!slow_slewing) {
|
if (!slow_slewing) {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
} else {
|
} else {
|
||||||
switch (have_readonly_adjtime) {
|
if (have_readonly_adjtime) {
|
||||||
case 2:
|
|
||||||
if (TMX_GetOffsetLeft(&offset) < 0) {
|
if (TMX_GetOffsetLeft(&offset) < 0) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
||||||
}
|
}
|
||||||
break;
|
} else {
|
||||||
case 0:
|
|
||||||
toffset = 0;
|
toffset = 0;
|
||||||
if (TMX_ApplyOffset(&toffset) < 0) {
|
if (TMX_ApplyOffset(&toffset) < 0) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
||||||
@@ -779,14 +762,6 @@ get_offset_correction(struct timeval *raw,
|
|||||||
if (TMX_ApplyOffset(&toffset) < 0) {
|
if (TMX_ApplyOffset(&toffset) < 0) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (TMX_GetOffsetLeftOld(&offset) < 0) {
|
|
||||||
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset == 0) {
|
if (offset == 0) {
|
||||||
@@ -879,6 +854,43 @@ guess_hz_and_shift_hz(int tick, int *hz, int *shift_hz)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
get_hz_and_shift_hz(int *hz, int *shift_hz)
|
||||||
|
{
|
||||||
|
#ifdef _SC_CLK_TCK
|
||||||
|
if ((*hz = sysconf(_SC_CLK_TCK)) < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*hz == 100) {
|
||||||
|
*shift_hz = 7;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (*shift_hz = 1; (*hz >> *shift_hz) > 1; (*shift_hz)++)
|
||||||
|
;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
|
static int
|
||||||
|
kernelvercmp(int major1, int minor1, int patch1,
|
||||||
|
int major2, int minor2, int patch2)
|
||||||
|
{
|
||||||
|
if (major1 != major2)
|
||||||
|
return major1 - major2;
|
||||||
|
if (minor1 != minor2)
|
||||||
|
return minor1 - minor2;
|
||||||
|
return patch1 - patch2;
|
||||||
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
/* Compute the scaling to use on any frequency we set, according to
|
/* Compute the scaling to use on any frequency we set, according to
|
||||||
the vintage of the Linux kernel being used. */
|
the vintage of the Linux kernel being used. */
|
||||||
@@ -893,10 +905,10 @@ get_version_specific_details(void)
|
|||||||
int config_hz, set_config_hz; /* values of HZ from conf file */
|
int config_hz, set_config_hz; /* values of HZ from conf file */
|
||||||
int set_config_freq_scale;
|
int set_config_freq_scale;
|
||||||
double config_freq_scale;
|
double config_freq_scale;
|
||||||
double calculated_freq_scale;
|
|
||||||
struct tmx_params tmx_params;
|
struct tmx_params tmx_params;
|
||||||
struct utsname uts;
|
struct utsname uts;
|
||||||
|
|
||||||
|
if (!get_hz_and_shift_hz(&hz, &shift_hz)) {
|
||||||
TMX_ReadCurrentParams(&tmx_params);
|
TMX_ReadCurrentParams(&tmx_params);
|
||||||
|
|
||||||
guess_hz_and_shift_hz(tmx_params.tick, &hz, &shift_hz);
|
guess_hz_and_shift_hz(tmx_params.tick, &hz, &shift_hz);
|
||||||
@@ -910,6 +922,7 @@ get_version_specific_details(void)
|
|||||||
tmx_params.tick, tmx_params.freq, tmx_params.dfreq, tmx_params.offset, hz, shift_hz);
|
tmx_params.tick, tmx_params.freq, tmx_params.dfreq, tmx_params.offset, hz, shift_hz);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CNF_GetLinuxHz(&set_config_hz, &config_hz);
|
CNF_GetLinuxHz(&set_config_hz, &config_hz);
|
||||||
if (set_config_hz) hz = config_hz;
|
if (set_config_hz) hz = config_hz;
|
||||||
@@ -924,10 +937,6 @@ get_version_specific_details(void)
|
|||||||
max_tick_bias = nominal_tick / 10;
|
max_tick_bias = nominal_tick / 10;
|
||||||
tick_update_hz = hz;
|
tick_update_hz = hz;
|
||||||
|
|
||||||
LOG(LOGS_INFO, LOGF_SysLinux, "set_config_hz=%d hz=%d shift_hz=%d basic_freq_scale=%.8f nominal_tick=%d slew_delta_tick=%d max_tick_bias=%d",
|
|
||||||
set_config_hz, hz, shift_hz, basic_freq_scale, nominal_tick, slew_delta_tick, max_tick_bias);
|
|
||||||
|
|
||||||
|
|
||||||
/* The basic_freq_scale comes from:
|
/* The basic_freq_scale comes from:
|
||||||
* the kernel increments the usec counter HZ times per second (if the timer
|
* the kernel increments the usec counter HZ times per second (if the timer
|
||||||
interrupt period were perfect)
|
interrupt period were perfect)
|
||||||
@@ -958,7 +967,9 @@ get_version_specific_details(void)
|
|||||||
if (uname(&uts) < 0) {
|
if (uname(&uts) < 0) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "Cannot uname(2) to get kernel version, sorry.");
|
LOG_FATAL(LOGF_SysLinux, "Cannot uname(2) to get kernel version, sorry.");
|
||||||
}
|
}
|
||||||
if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3) {
|
|
||||||
|
patch = 0;
|
||||||
|
if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) < 2) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "Cannot read information from uname, sorry");
|
LOG_FATAL(LOGF_SysLinux, "Cannot read information from uname, sorry");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,102 +979,45 @@ get_version_specific_details(void)
|
|||||||
version_minor = minor;
|
version_minor = minor;
|
||||||
version_patchlevel = patch;
|
version_patchlevel = patch;
|
||||||
|
|
||||||
have_nanopll = 0;
|
if (kernelvercmp(major, minor, patch, 2, 2, 0) < 0) {
|
||||||
|
LOG_FATAL(LOGF_SysLinux, "Kernel version not supported, sorry.");
|
||||||
|
}
|
||||||
|
|
||||||
switch (major) {
|
if (kernelvercmp(major, minor, patch, 2, 6, 27) < 0) {
|
||||||
case 1:
|
freq_scale = (hz == 100) ? (128.0 / 128.125) : basic_freq_scale;
|
||||||
/* Does Linux v1.x even support HZ!=100? */
|
|
||||||
switch (minor) {
|
|
||||||
case 2:
|
|
||||||
if (patch == 13) {
|
|
||||||
freq_scale = (hz==100) ? (128.0 / 100.0) : basic_freq_scale ; /* I _think_! */
|
|
||||||
have_readonly_adjtime = 1;
|
|
||||||
} else {
|
} else {
|
||||||
LOG_FATAL(LOGF_SysLinux, "Kernel version not supported yet, sorry.");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
/* I guess the change from the 1.2.x scaling to the 2.0.x
|
|
||||||
scaling must have happened during 1.3 development. I
|
|
||||||
haven't a clue where though, until someone looks it
|
|
||||||
up. */
|
|
||||||
LOG_FATAL(LOGF_SysLinux, "Kernel version not supported yet, sorry.");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOG_FATAL(LOGF_SysLinux, "Kernel version not supported yet, sorry.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
switch (minor) {
|
|
||||||
case 0:
|
|
||||||
if (patch < 32) {
|
|
||||||
freq_scale = (hz==100) ? (128.0 / 125.0) : basic_freq_scale;
|
|
||||||
have_readonly_adjtime = 1;
|
|
||||||
} else if (patch >= 32) {
|
|
||||||
freq_scale = (hz==100) ? (128.0 / 128.125) : basic_freq_scale;
|
|
||||||
|
|
||||||
/* The functionality in kernel/time.c in the kernel source
|
|
||||||
was modified with regard to what comes back in the
|
|
||||||
txc.offset field on return from adjtimex. If txc.modes
|
|
||||||
was ADJ_OFFSET_SINGLESHOT on entry, the outstanding
|
|
||||||
adjustment is returned, however the running offset will
|
|
||||||
be modified to the passed value. */
|
|
||||||
have_readonly_adjtime = 0;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
/* I know that earlier 2.1 kernels were like 2.0.31, hence
|
|
||||||
the settings below. However, the 2.0.32 behaviour may
|
|
||||||
have been added late in the 2.1 series, however I have no
|
|
||||||
idea at which patch level. Leave it like this until
|
|
||||||
someone supplies some info. */
|
|
||||||
freq_scale = (hz==100) ? (128.0 / 125.0) : basic_freq_scale;
|
|
||||||
have_readonly_adjtime = 0; /* For safety ! */
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
if (minor < 6 || patch < 27) {
|
|
||||||
/* These seem to be like 2.0.32 */
|
|
||||||
freq_scale = (hz==100) ? (128.0 / 128.125) : basic_freq_scale;
|
|
||||||
have_readonly_adjtime = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (patch < 33) {
|
|
||||||
/* Tickless kernels before 2.6.33 accumulated ticks only in
|
|
||||||
half-second intervals. */
|
|
||||||
tick_update_hz = 2;
|
|
||||||
}
|
|
||||||
/* Let's be optimistic that these will be the same until proven
|
|
||||||
otherwise :-) */
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
/* These don't seem to need scaling */
|
/* These don't seem to need scaling */
|
||||||
freq_scale = 1.0;
|
freq_scale = 1.0;
|
||||||
have_readonly_adjtime = 2;
|
|
||||||
have_nanopll = 1;
|
if (kernelvercmp(major, minor, patch, 2, 6, 33) < 0) {
|
||||||
break;
|
/* Tickless kernels before 2.6.33 accumulated ticks only in
|
||||||
default:
|
half-second intervals */
|
||||||
LOG_FATAL(LOGF_SysLinux, "Kernel version not supported yet, sorry.");
|
tick_update_hz = 2;
|
||||||
}
|
}
|
||||||
break;
|
}
|
||||||
default:
|
|
||||||
LOG_FATAL(LOGF_SysLinux, "Kernel's major version not supported yet, sorry");
|
/* ADJ_OFFSET_SS_READ support */
|
||||||
break;
|
if (kernelvercmp(major, minor, patch, 2, 6, 27) < 0) {
|
||||||
|
have_readonly_adjtime = 0;
|
||||||
|
} else {
|
||||||
|
have_readonly_adjtime = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ADJ_NANO support */
|
||||||
|
if (kernelvercmp(major, minor, patch, 2, 6, 27) < 0) {
|
||||||
|
have_nanopll = 0;
|
||||||
|
} else {
|
||||||
|
have_nanopll = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Override freq_scale if it appears in conf file */
|
/* Override freq_scale if it appears in conf file */
|
||||||
CNF_GetLinuxFreqScale(&set_config_freq_scale, &config_freq_scale);
|
CNF_GetLinuxFreqScale(&set_config_freq_scale, &config_freq_scale);
|
||||||
calculated_freq_scale = freq_scale;
|
|
||||||
if (set_config_freq_scale) {
|
if (set_config_freq_scale) {
|
||||||
freq_scale = config_freq_scale;
|
freq_scale = config_freq_scale;
|
||||||
LOG(LOGS_INFO, LOGF_SysLinux, "calculated_freq_scale=%.8f freq_scale=%.8f",
|
|
||||||
calculated_freq_scale, freq_scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG(LOGS_INFO, LOGF_SysLinux, "hz=%d shift_hz=%d freq_scale=%.8f nominal_tick=%d slew_delta_tick=%d max_tick_bias=%d",
|
||||||
|
hz, shift_hz, freq_scale, nominal_tick, slew_delta_tick, max_tick_bias);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -1073,25 +1027,19 @@ void
|
|||||||
SYS_Linux_Initialise(void)
|
SYS_Linux_Initialise(void)
|
||||||
{
|
{
|
||||||
long offset;
|
long offset;
|
||||||
|
double freq;
|
||||||
|
|
||||||
offset_register = 0.0;
|
offset_register = 0.0;
|
||||||
fast_slewing = 0;
|
fast_slewing = 0;
|
||||||
|
|
||||||
get_version_specific_details();
|
get_version_specific_details();
|
||||||
|
|
||||||
current_tick = nominal_tick;
|
|
||||||
current_total_tick = 1.0 / dhz;
|
|
||||||
|
|
||||||
lcl_RegisterSystemDrivers(read_frequency, set_frequency,
|
|
||||||
accrue_offset, apply_step_offset,
|
|
||||||
get_offset_correction, set_leap);
|
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
if (TMX_ApplyOffset(&offset) < 0) {
|
if (TMX_ApplyOffset(&offset) < 0) {
|
||||||
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
LOG_FATAL(LOGF_SysLinux, "adjtimex() failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_readonly_adjtime == 2 && (TMX_GetOffsetLeft(&offset) < 0 || offset)) {
|
if (have_readonly_adjtime && (TMX_GetOffsetLeft(&offset) < 0 || offset)) {
|
||||||
LOG(LOGS_INFO, LOGF_SysLinux, "adjtimex() doesn't support ADJ_OFFSET_SS_READ");
|
LOG(LOGS_INFO, LOGF_SysLinux, "adjtimex() doesn't support ADJ_OFFSET_SS_READ");
|
||||||
have_readonly_adjtime = 0;
|
have_readonly_adjtime = 0;
|
||||||
}
|
}
|
||||||
@@ -1102,6 +1050,14 @@ SYS_Linux_Initialise(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
TMX_SetSync(CNF_GetRTCSync());
|
TMX_SetSync(CNF_GetRTCSync());
|
||||||
|
|
||||||
|
/* Read current kernel frequency */
|
||||||
|
TMX_GetFrequency(&freq, ¤t_tick);
|
||||||
|
current_total_tick = (current_tick + freq / freq_scale / dhz) / 1.0e6;
|
||||||
|
|
||||||
|
lcl_RegisterSystemDrivers(read_frequency, set_frequency,
|
||||||
|
accrue_offset, apply_step_offset,
|
||||||
|
get_offset_correction, set_leap);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -1117,16 +1073,6 @@ SYS_Linux_Finalise(void)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
|
||||||
SYS_Linux_GetKernelVersion(int *major, int *minor, int *patchlevel)
|
|
||||||
{
|
|
||||||
*major = version_major;
|
|
||||||
*minor = version_minor;
|
|
||||||
*patchlevel = version_patchlevel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ================================================== */
|
|
||||||
|
|
||||||
#ifdef FEAT_LINUXCAPS
|
#ifdef FEAT_LINUXCAPS
|
||||||
void
|
void
|
||||||
SYS_Linux_DropRoot(char *user)
|
SYS_Linux_DropRoot(char *user)
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ extern void SYS_Linux_Initialise(void);
|
|||||||
|
|
||||||
extern void SYS_Linux_Finalise(void);
|
extern void SYS_Linux_Finalise(void);
|
||||||
|
|
||||||
extern void SYS_Linux_GetKernelVersion(int *major, int *minor, int *patchlevel);
|
|
||||||
|
|
||||||
extern void SYS_Linux_DropRoot(char *user);
|
extern void SYS_Linux_DropRoot(char *user);
|
||||||
|
|
||||||
extern void SYS_Linux_MemLockAll(int LockAll);
|
extern void SYS_Linux_MemLockAll(int LockAll);
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
Driver file for the NetBSD operating system.
|
Driver file for the NetBSD operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef __NetBSD__
|
#ifdef __NetBSD__
|
||||||
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
Driver file for Solaris operating system
|
Driver file for Solaris operating system
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
|
|||||||
@@ -24,6 +24,8 @@
|
|||||||
Driver file for the SunOS 4.1.x operating system.
|
Driver file for the SunOS 4.1.x operating system.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef SUNOS
|
#ifdef SUNOS
|
||||||
|
|
||||||
#include <kvm.h>
|
#include <kvm.h>
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "conf.h"
|
#include "conf.h"
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|||||||
6
util.c
6
util.c
@@ -25,6 +25,8 @@
|
|||||||
Various utility functions
|
Various utility functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -238,7 +240,7 @@ UTI_TimestampToString(NTP_int64 *ts)
|
|||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
char *
|
char *
|
||||||
UTI_RefidToString(unsigned long ref_id)
|
UTI_RefidToString(uint32_t ref_id)
|
||||||
{
|
{
|
||||||
unsigned int i, j, c;
|
unsigned int i, j, c;
|
||||||
char buf[5], *result;
|
char buf[5], *result;
|
||||||
@@ -331,7 +333,7 @@ UTI_StringToIP(const char *addr, IPAddr *ip)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
unsigned long
|
uint32_t
|
||||||
UTI_IPToRefid(IPAddr *ip)
|
UTI_IPToRefid(IPAddr *ip)
|
||||||
{
|
{
|
||||||
MD5_CTX ctx;
|
MD5_CTX ctx;
|
||||||
|
|||||||
4
util.h
4
util.h
@@ -71,13 +71,13 @@ extern char *UTI_TimevalToString(struct timeval *tv);
|
|||||||
extern char *UTI_TimestampToString(NTP_int64 *ts);
|
extern char *UTI_TimestampToString(NTP_int64 *ts);
|
||||||
|
|
||||||
/* Convert ref_id into a temporary string, for diagnostics */
|
/* Convert ref_id into a temporary string, for diagnostics */
|
||||||
extern char *UTI_RefidToString(unsigned long ref_id);
|
extern char *UTI_RefidToString(uint32_t ref_id);
|
||||||
|
|
||||||
/* Convert an IP address to string, for diagnostics */
|
/* Convert an IP address to string, for diagnostics */
|
||||||
extern char *UTI_IPToString(IPAddr *ip);
|
extern char *UTI_IPToString(IPAddr *ip);
|
||||||
|
|
||||||
extern int UTI_StringToIP(const char *addr, IPAddr *ip);
|
extern int UTI_StringToIP(const char *addr, IPAddr *ip);
|
||||||
extern unsigned long UTI_IPToRefid(IPAddr *ip);
|
extern uint32_t UTI_IPToRefid(IPAddr *ip);
|
||||||
extern void UTI_IPHostToNetwork(IPAddr *src, IPAddr *dest);
|
extern void UTI_IPHostToNetwork(IPAddr *src, IPAddr *dest);
|
||||||
extern void UTI_IPNetworkToHost(IPAddr *src, IPAddr *dest);
|
extern void UTI_IPNetworkToHost(IPAddr *src, IPAddr *dest);
|
||||||
extern int UTI_CompareIPs(IPAddr *a, IPAddr *b, IPAddr *mask);
|
extern int UTI_CompareIPs(IPAddr *a, IPAddr *b, IPAddr *mask);
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
DEVELOPMENT
|
|
||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
#ifdef LINUX
|
#ifdef LINUX
|
||||||
|
|
||||||
#define _LOOSE_KERNEL_NAMES
|
#define _LOOSE_KERNEL_NAMES
|
||||||
@@ -84,24 +86,14 @@ TMX_SetFrequency(double *freq, long tick)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TMX_GetFrequency(double *freq)
|
TMX_GetFrequency(double *freq, long *tick)
|
||||||
{
|
{
|
||||||
struct timex txc;
|
struct timex txc;
|
||||||
int result;
|
int result;
|
||||||
txc.modes = 0; /* pure read */
|
txc.modes = 0; /* pure read */
|
||||||
result = adjtimex(&txc);
|
result = adjtimex(&txc);
|
||||||
*freq = txc.freq / (double)(1 << SHIFT_USEC);
|
*freq = txc.freq / (double)(1 << SHIFT_USEC);
|
||||||
return result;
|
*tick = txc.tick;
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
TMX_GetOffsetLeftOld(long *offset)
|
|
||||||
{
|
|
||||||
struct timex txc;
|
|
||||||
int result;
|
|
||||||
txc.modes = 0; /* pure read */
|
|
||||||
result = adjtimex(&txc);
|
|
||||||
*offset = txc.offset;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,8 +67,7 @@ struct tmx_params {
|
|||||||
int TMX_SetTick(long tick);
|
int TMX_SetTick(long tick);
|
||||||
int TMX_ApplyOffset(long *offset);
|
int TMX_ApplyOffset(long *offset);
|
||||||
int TMX_SetFrequency(double *freq, long tick);
|
int TMX_SetFrequency(double *freq, long tick);
|
||||||
int TMX_GetFrequency(double *freq);
|
int TMX_GetFrequency(double *freq, long *tick);
|
||||||
int TMX_GetOffsetLeftOld(long *offset);
|
|
||||||
int TMX_GetOffsetLeft(long *offset);
|
int TMX_GetOffsetLeft(long *offset);
|
||||||
int TMX_ReadCurrentParams(struct tmx_params *params);
|
int TMX_ReadCurrentParams(struct tmx_params *params);
|
||||||
int TMX_SetLeap(int leap);
|
int TMX_SetLeap(int leap);
|
||||||
|
|||||||
Reference in New Issue
Block a user