Commit graph

1544 commits

Author SHA1 Message Date
Miroslav Lichvar
997406fe47 ntp: add support for software timestamping on Linux
Enable SCM_TIMESTAMPING control messages and the socket's error queue in
order to receive our transmitted packets with a more accurate transmit
timestamp. Add a new file for Linux-specific NTP I/O and implement
processing of these messages there.
2016-11-10 15:26:56 +01:00
Miroslav Lichvar
14c8f07629 ntp: save source of local timestamps
Introduce a new structure for local timestamps that will hold the
timestamp with its estimated error and also its source (daemon, kernel
or HW). While at it, reorder parameters of the functions that accept the
timestamps.
2016-11-10 15:26:56 +01:00
Miroslav Lichvar
8f6a1b5318 ntp: add support for processing of transmitted packets
Add new functions for processing of packets after they are actually
sent by the kernel or HW in order to get a more accurate transmit
timestamp. Rename old functions for processing of received packets and
their parameters to make the naming more consistent.
2016-11-10 15:26:56 +01:00
Miroslav Lichvar
a8c6bea2d5 sys_linux: add function for checking kernel version 2016-11-10 15:26:55 +01:00
Miroslav Lichvar
19fde8f49c refclock: fix check for old samples
The fix in commit 8f85291d23 was
incorrect.
2016-10-07 11:03:59 +02:00
Miroslav Lichvar
8f85291d23 refclock: require new samples to have newer timestamp
If all or most SHM/SOCK samples collected in a polling interval had the
same local timestamp, the dispersion could end up as nan, which could
trigger an assert failure later in the code.

Before accumulating a refclock sample, check if the timestamp is newer
than the previous one.
2016-10-06 16:09:24 +02:00
Miroslav Lichvar
9c48166e90 ntp: inline send_packet()
Also, reuse existing function for checking server sockets.
2016-09-26 12:40:44 +02:00
Miroslav Lichvar
b536296c05 ntp: use ipi_addr from struct in_pktinfo as local address
Use the ipi_addr field instead of ipi_spec_dst as the local address
after recvmsg() to be consistent with the processing of struct
in6_pktinfo. This may make a difference for messages from the error
queue.
2016-09-26 12:40:44 +02:00
Miroslav Lichvar
d36c522453 ntp: check for missing source address after recvmsg() 2016-09-26 12:40:44 +02:00
Miroslav Lichvar
2577e20f09 ntp: fix updating of transmit delay in symmetric mode
This was broken in commit cea21adbbb.
2016-09-26 12:40:43 +02:00
Miroslav Lichvar
c169ad3f58 sched: add support for handling exceptions on descriptors 2016-09-26 12:40:43 +02:00
Miroslav Lichvar
411f4697ca sys_linux: allow getdents in seccomp filter
This is needed for glob(), which is used with the include and dumpdir
directives.
2016-09-26 12:40:43 +02:00
Miroslav Lichvar
6c5de8dcb0 refclock: use UTI_TimespecToString() in debug message 2016-09-26 12:40:43 +02:00
Miroslav Lichvar
c8373f1649 util: add UTI_IsZeroTimespec() 2016-09-26 12:40:43 +02:00
Miroslav Lichvar
45f86122fa test: add smooth unit test 2016-09-12 13:13:30 +02:00
Miroslav Lichvar
c0a8afdb68 smooth: fix selection of 1st stage direction
When the smoothing process is updated with extremely small (e.g.
sub-nanosecond) values, both directions may give a negative length of
the 1st or 3rd stage due to numerical errors and the selection will fail
an in assertion. Rework the code to select the direction which gives a
smaller error.
2016-09-12 13:13:14 +02:00
Miroslav Lichvar
1afb285aad sched: initialize sub-second part of saved_tv in SCH_MainLoop()
This is needed since commit d0dfa1de9e to
avoid valgrind errors.
2016-09-12 12:49:18 +02:00
Miroslav Lichvar
c08e7e716d use correct facility in LOG messages 2016-09-07 11:16:01 +02:00
Miroslav Lichvar
a06a5f1baa sources: remove dump files on start
When chronyd is starting, after the point where dump files are loaded,
remove all files in the dump directory that match the naming scheme used
for dump files. This prevents loading stale dump files that were not
saved in the latest run of chronyd.
2016-09-07 11:16:01 +02:00
Miroslav Lichvar
fb5d4f1da4 conf: disable dumpdir and logdir by default
Use empty string instead of "." (which is normally the root directory)
as the default value of dumpdir and logdir to indicate they are not
specified. Print warnings in syslog when trying to log or dump
measurements without dumpdir or logdir.
2016-09-07 11:16:01 +02:00
Miroslav Lichvar
d2e5b41369 client: flush stdout after printing prompt
Apparently fgets() doesn't flush stdout in some libc implementations.
2016-09-07 11:16:01 +02:00
Miroslav Lichvar
4b6b6e5cba client: remove out of date comment 2016-09-07 11:16:01 +02:00
Miroslav Lichvar
27b4c396d0 client: fix printing of negative poll in sources report again
This was broken in commit 3f51805e62.
2016-09-07 11:16:01 +02:00
Miroslav Lichvar
41eb5b79cb client: check address in waitsync command 2016-09-07 11:16:01 +02:00
Miroslav Lichvar
23cf74d5c7 util: convert invalid addresses as IPADDR_UNSPEC 2016-09-07 11:15:57 +02:00
Miroslav Lichvar
1a038bfd50 test: add 011-asymjitter 2016-09-06 15:48:59 +02:00
Miroslav Lichvar
dd02d67224 test: add support for testing with asymmetric jitter 2016-09-06 15:48:59 +02:00
Miroslav Lichvar
648bf8bd3e test: extend 113-leapsecond 2016-09-06 15:48:59 +02:00
Miroslav Lichvar
82c4bfe5d2 sources: include trust option in leap second voting
When sources specified with the trust option pass the source selection,
ignore other sources in the vote of leap second status.
2016-09-06 15:48:59 +02:00
Miroslav Lichvar
98ba4ce4d5 configure: add options to set default pidfile and rtcdevice 2016-08-22 15:50:35 +02:00
Bryan Christianson
f63e414024 configure: add option --without-clock-gettime
clock_gettime() will be ignored even if it is present
2016-08-22 15:50:35 +02:00
Miroslav Lichvar
a8886603c2 ntp: fix processing of kernel timestamps on non-Linux systems
When the SO_TIMESTAMP socket option was enabled, the expected type of
control messages containing timestamps was SO_TIMESTAMP instead of
SCM_TIMESTAMP. This worked on Linux, where the two values are equal, but
not on the other supported systems. The timestamps were ignored and this
probably worsened the accuracy and stability of the synchronisation.
2016-08-22 15:50:35 +02:00
Miroslav Lichvar
4f10144b09 ntp: add corrected delay to debug message in process_receive() 2016-08-22 15:50:28 +02:00
Miroslav Lichvar
af664e6cec sourcestats: return success when loading dump file with no samples 2016-08-22 15:05:48 +02:00
Miroslav Lichvar
c30816eb65 sourcestats: remove warning messages from SST_LoadFromFile()
There is a generic error message in SRC_ReloadSources().
2016-08-22 15:05:48 +02:00
Miroslav Lichvar
b1accfd0ff sourcestats: make reading/writing dump files Y2106 ready
The sample times were written and read as unsigned long, which would
overflow in year 2016 on platforms that have 32-bit long.
2016-08-22 15:05:48 +02:00
Miroslav Lichvar
5c45e4ccb5 sources: improve naming of dump files
Include IP address instead of reference ID in the name of dump file
for NTP sources and for reference clocks format the reference ID as a
hexadecimal number instead of quad dotted notation.

Also, avoid dynamic memory allocation and improve warning messages.
2016-08-22 15:05:02 +02:00
Miroslav Lichvar
41cf867738 sourcestats: update regression after loading dump file
Call SST_DoNewRegression() immediately in SST_LoadFromFile instead of
relying on SRC_ReloadSources().
2016-08-19 18:25:02 +02:00
Bryan Christianson
02844e9b01 local: fix typo in strerror() call 2016-08-19 18:25:02 +02:00
Miroslav Lichvar
7a1ebc3467 ntp: add support for SO_TIMESTAMPNS socket option
Enable the SO_TIMESTAMPNS option to get kernel timestamps in nanosecond
resolution.
2016-08-19 13:55:20 +02:00
Miroslav Lichvar
8d89610ff6 local: add support for clock_gettime()
Use clock_gettime() to read the system clock in nanosecond resolution.
2016-08-19 13:54:58 +02:00
Miroslav Lichvar
cfe706f032 util: modify UTI_*ToDouble functions to return double directly 2016-08-19 12:53:09 +02:00
Miroslav Lichvar
99cc94529d util: rename functions dealing with integers in NTP format
This should prevent confusion with int32_t, int64_t and other types.
2016-08-19 12:53:09 +02:00
Miroslav Lichvar
d0dfa1de9e adopt struct timespec
Replace struct timeval with struct timespec as the main data type for
timestamps. This will allow the NTP code to work with timestamps in
nanosecond resolution.
2016-08-19 12:53:09 +02:00
Miroslav Lichvar
0899ab52dd util: return normalised timevals 2016-08-19 11:33:38 +02:00
Miroslav Lichvar
71e0ebcb6b ntp: don't send crypto-NAKs
Crypto-NAK is useful only with Autokey where it allows quick reset
of the association. There is no plan to support Autokey and NTS will
specify its own message for authentication errors.
2016-08-17 11:54:34 +02:00
Miroslav Lichvar
e488371b01 sourcestats: report asymmetry in statistics log 2016-08-11 11:24:48 +02:00
Miroslav Lichvar
39f34eb674 sourcestats: correct offsets with asymmetric network jitter
Estimate asymmetry of network jitter on the path to the source as a
slope of offset against network delay in multiple linear regression. If
the asymmetry is significant and its sign doesn't change frequently, the
measured offsets (which are used later to estimate the offset and
frequency of the clock) are corrected to correspond to the minimum
network delay. This can significantly improve the accuracy and stability
of the estimated offset and frequency.
2016-08-11 11:24:48 +02:00
Miroslav Lichvar
9d9d6c30cf sourcestats: add debug message for regression results 2016-08-11 10:45:48 +02:00
Miroslav Lichvar
27d59e54cc regress: add linear regression with two independent variables 2016-08-11 10:45:48 +02:00