]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
8 years agoMerge branch '2.4-stable' into HEAD
Miroslav Lichvar [Tue, 22 Nov 2016 15:06:05 +0000 (16:06 +0100)] 
Merge branch '2.4-stable' into HEAD

8 years agorefclock: don't compare sample time with samples from previous poll
Miroslav Lichvar [Mon, 21 Nov 2016 10:20:57 +0000 (11:20 +0100)] 
refclock: don't compare sample time with samples from previous poll

This is an improvement of commit 8f85291d23560508e03938bfa894294f73ad2d9e.

8 years agodoc: update NEWS 2.4-stable 2.4.1
Miroslav Lichvar [Mon, 21 Nov 2016 10:58:26 +0000 (11:58 +0100)] 
doc: update NEWS

8 years agosources: add new status for sources that overlap trusted sources
Miroslav Lichvar [Fri, 11 Nov 2016 13:04:12 +0000 (14:04 +0100)] 
sources: add new status for sources that overlap trusted sources

Sources that overlap trusted sources should be displayed in the chronyc
sources report with the '-' symbol and they shouldn't trigger a
replacement.

8 years agorefclock: don't compare sample time with samples from previous poll
Miroslav Lichvar [Mon, 21 Nov 2016 10:20:57 +0000 (11:20 +0100)] 
refclock: don't compare sample time with samples from previous poll

This is an improvement of commit 0a848e2528aaef0b3347de0b49ce50da8dc1c9a4.

8 years agorefclock: fix check for old samples
Miroslav Lichvar [Fri, 7 Oct 2016 08:59:45 +0000 (10:59 +0200)] 
refclock: fix check for old samples

The fix in commit 0a848e2528aaef0b3347de0b49ce50da8dc1c9a4 was
incorrect.

8 years agorefclock: require new samples to have newer timestamp
Miroslav Lichvar [Thu, 6 Oct 2016 13:21:43 +0000 (15:21 +0200)] 
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.

8 years agotest: add smooth unit test
Miroslav Lichvar [Mon, 12 Sep 2016 10:55:57 +0000 (12:55 +0200)] 
test: add smooth unit test

8 years agosmooth: fix selection of 1st stage direction
Miroslav Lichvar [Mon, 12 Sep 2016 10:23:09 +0000 (12:23 +0200)] 
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.

8 years agoclient: flush stdout after printing prompt
Miroslav Lichvar [Tue, 6 Sep 2016 13:47:40 +0000 (15:47 +0200)] 
client: flush stdout after printing prompt

Apparently fgets() doesn't flush stdout in some libc implementations.

8 years agoclient: fix printing of negative poll in sources report again
Miroslav Lichvar [Tue, 6 Sep 2016 13:42:00 +0000 (15:42 +0200)] 
client: fix printing of negative poll in sources report again

This was broken in commit 3f51805e6214cad5cb9a863491316937541601ec.

8 years agontp: fix processing of kernel timestamps on non-Linux systems
Miroslav Lichvar [Mon, 22 Aug 2016 11:14:45 +0000 (13:14 +0200)] 
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.

8 years agoconf: fix parsing of refclock directive
Miroslav Lichvar [Mon, 27 Jun 2016 12:38:51 +0000 (14:38 +0200)] 
conf: fix parsing of refclock directive

Don't accept refclock directive which has as the last argument an option
that requires a value.

8 years agontp: add debug message for truncated control messages
Miroslav Lichvar [Tue, 15 Nov 2016 11:13:49 +0000 (12:13 +0100)] 
ntp: add debug message for truncated control messages

8 years agontp: ignore truncated messages
Miroslav Lichvar [Tue, 15 Nov 2016 11:10:50 +0000 (12:10 +0100)] 
ntp: ignore truncated messages

Don't waste time with processing messages that don't fit in the receive
buffer as they most likely wouldn't pass the format check due to an
invalid length of an extension field.

8 years agohwclock: fix order of samples
Miroslav Lichvar [Tue, 15 Nov 2016 10:26:18 +0000 (11:26 +0100)] 
hwclock: fix order of samples

In order to trim oldest samples in the regression function, they need to
be sorted in the data arrays from the oldest to newest.

8 years agontp: detect unexpected TX updates of unknown sources
Miroslav Lichvar [Mon, 14 Nov 2016 11:18:56 +0000 (12:18 +0100)] 
ntp: detect unexpected TX updates of unknown sources

8 years agontp: improve replay protection in symmetric mode
Miroslav Lichvar [Mon, 14 Nov 2016 08:27:07 +0000 (09:27 +0100)] 
ntp: improve replay protection in symmetric mode

Always allow update from the first valid response, even if its transmit
timestamp is not newer than the currently saved timestamp. This shoud
provide a temporary protection in the case where the attacker does have
an authenticated packet from future, but the peers are using the same
polling interval and the protocol is already synchronised. This could be
also useful in the case where the attacker cannot observe the traffic
and authentication is disabled.

8 years agosched: add more random bits to timeout scheduling
Miroslav Lichvar [Mon, 14 Nov 2016 07:43:54 +0000 (08:43 +0100)] 
sched: add more random bits to timeout scheduling

Extend the random value which is included in the calculation of the
delay from 16 to 32 bits. This makes scheduling of NTP transmissions
random to one microsecond for polling intervals up to 17.

8 years agoclient: randomize sequence number in requests
Miroslav Lichvar [Fri, 11 Nov 2016 16:20:38 +0000 (17:20 +0100)] 
client: randomize sequence number in requests

Don't rely on random source port of a connected socket alone as a
protection against spoofed packets in chronyc. Generate a fully random
32-bit sequence number for each request and modify the code to not send
a new request until the timeout expires or a valid response is received.
For a monitoring protocol this should be more than good enough.

8 years agoclient: fix attempt number in requests to be in network order
Miroslav Lichvar [Fri, 11 Nov 2016 15:53:51 +0000 (16:53 +0100)] 
client: fix attempt number in requests to be in network order

8 years agoreport: remove unused definition
Miroslav Lichvar [Fri, 11 Nov 2016 13:17:02 +0000 (14:17 +0100)] 
report: remove unused definition

8 years agosources: add new status for sources that overlap trusted sources
Miroslav Lichvar [Fri, 11 Nov 2016 13:04:12 +0000 (14:04 +0100)] 
sources: add new status for sources that overlap trusted sources

Sources that overlap trusted sources should be displayed in the chronyc
sources report with the '-' symbol and they shouldn't trigger a
replacement.

8 years agosources: don't log warning when opening dump file fails
Miroslav Lichvar [Fri, 11 Nov 2016 12:32:54 +0000 (13:32 +0100)] 
sources: don't log warning when opening dump file fails

Instead of complaining when the file doesn't exist, which is common when
using pool servers, log an informational message when the file is
loaded.

8 years agoconf: create socket directory before logdir and dumpdir
Miroslav Lichvar [Fri, 11 Nov 2016 12:07:28 +0000 (13:07 +0100)] 
conf: create socket directory before logdir and dumpdir

This allows sharing of the same directory for sockets, logs and dumps as
the socket directory needs to be created first (with mode 0770) in order
to pass the check of the permissions.

8 years agontp: print offset and delay in debug messages in nanosecond resolution
Miroslav Lichvar [Wed, 9 Nov 2016 16:33:03 +0000 (17:33 +0100)] 
ntp: print offset and delay in debug messages in nanosecond resolution

8 years agontp: fix remote poll in measurements log
Miroslav Lichvar [Wed, 9 Nov 2016 16:31:55 +0000 (17:31 +0100)] 
ntp: fix remote poll in measurements log

Write the poll value from the received packet instead of the saved
value, which doesn't have to be always updated.

8 years agontp: add new fields to measurements log
Miroslav Lichvar [Wed, 9 Nov 2016 16:31:34 +0000 (17:31 +0100)] 
ntp: add new fields to measurements log

Include reference ID, NTP mode and source of the local transmit and
receive timestamp in the measurements log.

8 years agontp: add partial protection against replay attacks on symmetric mode
Miroslav Lichvar [Tue, 8 Nov 2016 14:53:40 +0000 (15:53 +0100)] 
ntp: add partial protection against replay attacks on symmetric mode

A recently published paper [1] (section VIII) describes a DoS attack
on symmetric associations authenticated with a symmetric key where the
attacker can only observe and replay packets. Although the attacker
cannot prevent packets from reaching the other peer (not even by
flooding the network for example), s/he has the same power as a MitM
attacker.

As the authors explain, this is a fundamental flaw of the protocol,
which cannot be fixed in the general case. However, we can at least try
to protect associations in a case where the peers use the same polling
interval (i.e. for each request is expected one response) and all peers
that share the symmetric key never start with clocks in future or very
distant past (i.e. the attacker does not have any packets from future
that could be replayed).

Require that updates of the NTP state between requests have increasing
transmit timestamp and when a packet that passed all NTP tests to be
considered a valid response was received, don't allow any more updates
of the state from packets that don't pass the tests. This should ensure
the last update of the state is from the first time the last real
response was received and still allow the protocol to recover in case
one of the peers steps its clock back or the attacker does have a packet
from future and the attack stops.

[1] Aanchal Malhotra, Matthew Van Gundy, Mayank Varia, Haydn Kennedy,
    Jonathan Gardner, and Sharon Goldberg. The Security of NTP's
    Datagram Protocol. https://eprint.iacr.org/2016/1006

8 years agontp: disable presend in symmetric and interleaved modes
Miroslav Lichvar [Thu, 3 Nov 2016 07:06:26 +0000 (08:06 +0100)] 
ntp: disable presend in symmetric and interleaved modes

The presend packet can't be used in symmetric and interleaved modes as
it breaks the protocol with unexpected packets.

8 years agotest: add util unit test
Miroslav Lichvar [Mon, 24 Oct 2016 15:10:28 +0000 (17:10 +0200)] 
test: add util unit test

8 years agoutil: add functions for zeroing and comparing NTP timestamps
Miroslav Lichvar [Mon, 24 Oct 2016 14:46:29 +0000 (16:46 +0200)] 
util: add functions for zeroing and comparing NTP timestamps

8 years agontp: fix poll value in broadcast mode packets
Miroslav Lichvar [Mon, 24 Oct 2016 12:54:58 +0000 (14:54 +0200)] 
ntp: fix poll value in broadcast mode packets

Set poll in broadcast mode packets to the rounded log2 value of the
actual interval instead of a hardcoded value.

8 years agodoc: update chrony.conf man page for recent changes
Miroslav Lichvar [Mon, 24 Oct 2016 12:34:50 +0000 (14:34 +0200)] 
doc: update chrony.conf man page for recent changes

8 years agontp: add support for HW timestamping on Linux
Miroslav Lichvar [Mon, 24 Oct 2016 10:44:59 +0000 (12:44 +0200)] 
ntp: add support for HW timestamping on Linux

Add a new directive to specify interfaces which should be used for HW
timestamping. Extend the Linux ntp_io initialization to enable HW
timestamping, configure the RX filter using the SIOCSHWTSTAMP ioctl,
open their PHC devices, and track them as hwclock instances. When
messages with HW timestamps are received, use the PTP_SYS_OFFSET ioctl
to make PHC samples for hwclock.

8 years agontp: read interface index from control messages
Miroslav Lichvar [Mon, 24 Oct 2016 10:35:01 +0000 (12:35 +0200)] 
ntp: read interface index from control messages

8 years agotest: add 122-xleave
Miroslav Lichvar [Thu, 27 Oct 2016 08:57:29 +0000 (10:57 +0200)] 
test: add 122-xleave

8 years agotest: add hwclock unit test
Miroslav Lichvar [Fri, 21 Oct 2016 14:51:06 +0000 (16:51 +0200)] 
test: add hwclock unit test

8 years agohwclock: add support for tracking hardware clocks
Miroslav Lichvar [Wed, 19 Oct 2016 14:57:32 +0000 (16:57 +0200)] 
hwclock: add support for tracking hardware clocks

Add a general support for tracking independent hardware clocks like PTP
hardware clocks (PHC) or real-time clocks (RTC).

8 years agoclientlog: move status check to get_record()
Miroslav Lichvar [Wed, 12 Oct 2016 08:02:18 +0000 (10:02 +0200)] 
clientlog: move status check to get_record()

8 years agontp: add support for interleaved client/server mode
Miroslav Lichvar [Tue, 11 Oct 2016 15:15:56 +0000 (17:15 +0200)] 
ntp: add support for interleaved client/server mode

Adapt the interleaved symmetric mode for client/server associations.
On server, save the state needed for detection and responding in the
interleaved mode in the client log. On client, enable the interleaved
mode when the server is specified with the xleave option. Always accept
responses in basic mode to allow synchronization with servers that
don't support the interleaved mode, have too many clients, or have
multiple clients behing the same IP address. This is also necessary to
prevent DoS attacks on the client by overwriting or flushing the server
state. Protect the client's state variables against replay attacks as
the timestamps are now needed when processing the subsequent packet.

8 years agontp: check also NTP receive timestamp when updating TX timestamp
Miroslav Lichvar [Tue, 11 Oct 2016 15:06:58 +0000 (17:06 +0200)] 
ntp: check also NTP receive timestamp when updating TX timestamp

8 years agontp: add support for interleaved symmetric mode
Miroslav Lichvar [Mon, 10 Oct 2016 10:15:34 +0000 (12:15 +0200)] 
ntp: add support for interleaved symmetric mode

Add xleave option to the peer directive to enable an interleaved mode
compatible with ntpd. This allows peers to exchange transmit timestamps
captured after the actual transmission and significantly improve
the accuracy of the measurements.

8 years agontp: add support for software timestamping on Linux
Miroslav Lichvar [Fri, 7 Oct 2016 15:03:09 +0000 (17:03 +0200)] 
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.

8 years agontp: save source of local timestamps
Miroslav Lichvar [Fri, 7 Oct 2016 13:40:49 +0000 (15:40 +0200)] 
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.

8 years agontp: add support for processing of transmitted packets
Miroslav Lichvar [Fri, 7 Oct 2016 12:08:07 +0000 (14:08 +0200)] 
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.

8 years agosys_linux: add function for checking kernel version
Miroslav Lichvar [Wed, 26 Oct 2016 08:24:49 +0000 (10:24 +0200)] 
sys_linux: add function for checking kernel version

8 years agorefclock: fix check for old samples
Miroslav Lichvar [Fri, 7 Oct 2016 08:59:45 +0000 (10:59 +0200)] 
refclock: fix check for old samples

The fix in commit 8f85291d23560508e03938bfa894294f73ad2d9e was
incorrect.

8 years agorefclock: require new samples to have newer timestamp
Miroslav Lichvar [Thu, 6 Oct 2016 13:21:43 +0000 (15:21 +0200)] 
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.

8 years agontp: inline send_packet()
Miroslav Lichvar [Mon, 26 Sep 2016 10:28:31 +0000 (12:28 +0200)] 
ntp: inline send_packet()

Also, reuse existing function for checking server sockets.

8 years agontp: use ipi_addr from struct in_pktinfo as local address
Miroslav Lichvar [Mon, 26 Sep 2016 10:24:49 +0000 (12:24 +0200)] 
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.

8 years agontp: check for missing source address after recvmsg()
Miroslav Lichvar [Mon, 26 Sep 2016 10:21:07 +0000 (12:21 +0200)] 
ntp: check for missing source address after recvmsg()

8 years agontp: fix updating of transmit delay in symmetric mode
Miroslav Lichvar [Mon, 26 Sep 2016 10:18:17 +0000 (12:18 +0200)] 
ntp: fix updating of transmit delay in symmetric mode

This was broken in commit cea21adbbbaf38271e33cd8b412c55ee541c0c37.

8 years agosched: add support for handling exceptions on descriptors
Miroslav Lichvar [Mon, 26 Sep 2016 10:16:42 +0000 (12:16 +0200)] 
sched: add support for handling exceptions on descriptors

8 years agosys_linux: allow getdents in seccomp filter
Miroslav Lichvar [Wed, 21 Sep 2016 08:35:57 +0000 (10:35 +0200)] 
sys_linux: allow getdents in seccomp filter

This is needed for glob(), which is used with the include and dumpdir
directives.

8 years agorefclock: use UTI_TimespecToString() in debug message
Miroslav Lichvar [Fri, 16 Sep 2016 08:13:08 +0000 (10:13 +0200)] 
refclock: use UTI_TimespecToString() in debug message

8 years agoutil: add UTI_IsZeroTimespec()
Miroslav Lichvar [Fri, 16 Sep 2016 08:01:37 +0000 (10:01 +0200)] 
util: add UTI_IsZeroTimespec()

8 years agotest: add smooth unit test
Miroslav Lichvar [Mon, 12 Sep 2016 10:55:57 +0000 (12:55 +0200)] 
test: add smooth unit test

8 years agosmooth: fix selection of 1st stage direction
Miroslav Lichvar [Mon, 12 Sep 2016 10:23:09 +0000 (12:23 +0200)] 
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.

8 years agosched: initialize sub-second part of saved_tv in SCH_MainLoop()
Miroslav Lichvar [Wed, 7 Sep 2016 09:49:36 +0000 (11:49 +0200)] 
sched: initialize sub-second part of saved_tv in SCH_MainLoop()

This is needed since commit d0dfa1de9e85510a584cdec5faae96c66d6847c9 to
avoid valgrind errors.

8 years agouse correct facility in LOG messages
Miroslav Lichvar [Wed, 7 Sep 2016 08:37:26 +0000 (10:37 +0200)] 
use correct facility in LOG messages

8 years agosources: remove dump files on start
Miroslav Lichvar [Wed, 7 Sep 2016 08:26:42 +0000 (10:26 +0200)] 
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.

8 years agoconf: disable dumpdir and logdir by default
Miroslav Lichvar [Tue, 6 Sep 2016 15:23:39 +0000 (17:23 +0200)] 
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.

8 years agoclient: flush stdout after printing prompt
Miroslav Lichvar [Tue, 6 Sep 2016 13:47:40 +0000 (15:47 +0200)] 
client: flush stdout after printing prompt

Apparently fgets() doesn't flush stdout in some libc implementations.

8 years agoclient: remove out of date comment
Miroslav Lichvar [Tue, 6 Sep 2016 13:46:49 +0000 (15:46 +0200)] 
client: remove out of date comment

8 years agoclient: fix printing of negative poll in sources report again
Miroslav Lichvar [Tue, 6 Sep 2016 13:42:00 +0000 (15:42 +0200)] 
client: fix printing of negative poll in sources report again

This was broken in commit 3f51805e6214cad5cb9a863491316937541601ec.

8 years agoclient: check address in waitsync command
Miroslav Lichvar [Tue, 6 Sep 2016 13:24:31 +0000 (15:24 +0200)] 
client: check address in waitsync command

8 years agoutil: convert invalid addresses as IPADDR_UNSPEC
Miroslav Lichvar [Tue, 6 Sep 2016 12:49:00 +0000 (14:49 +0200)] 
util: convert invalid addresses as IPADDR_UNSPEC

8 years agotest: add 011-asymjitter
Miroslav Lichvar [Wed, 24 Aug 2016 11:13:58 +0000 (13:13 +0200)] 
test: add 011-asymjitter

8 years agotest: add support for testing with asymmetric jitter
Miroslav Lichvar [Wed, 24 Aug 2016 11:13:20 +0000 (13:13 +0200)] 
test: add support for testing with asymmetric jitter

8 years agotest: extend 113-leapsecond
Miroslav Lichvar [Wed, 24 Aug 2016 08:40:21 +0000 (10:40 +0200)] 
test: extend 113-leapsecond

8 years agosources: include trust option in leap second voting
Miroslav Lichvar [Wed, 24 Aug 2016 08:21:39 +0000 (10:21 +0200)] 
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.

8 years agoconfigure: add options to set default pidfile and rtcdevice
Miroslav Lichvar [Mon, 22 Aug 2016 13:47:42 +0000 (15:47 +0200)] 
configure: add options to set default pidfile and rtcdevice

8 years agoconfigure: add option --without-clock-gettime
Bryan Christianson [Mon, 22 Aug 2016 13:03:24 +0000 (01:03 +1200)] 
configure: add option --without-clock-gettime

clock_gettime() will be ignored even if it is present

8 years agontp: fix processing of kernel timestamps on non-Linux systems
Miroslav Lichvar [Mon, 22 Aug 2016 11:14:45 +0000 (13:14 +0200)] 
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.

8 years agontp: add corrected delay to debug message in process_receive()
Miroslav Lichvar [Mon, 22 Aug 2016 11:08:27 +0000 (13:08 +0200)] 
ntp: add corrected delay to debug message in process_receive()

8 years agosourcestats: return success when loading dump file with no samples
Miroslav Lichvar [Fri, 19 Aug 2016 15:58:30 +0000 (17:58 +0200)] 
sourcestats: return success when loading dump file with no samples

8 years agosourcestats: remove warning messages from SST_LoadFromFile()
Miroslav Lichvar [Fri, 19 Aug 2016 15:53:08 +0000 (17:53 +0200)] 
sourcestats: remove warning messages from SST_LoadFromFile()

There is a generic error message in SRC_ReloadSources().

8 years agosourcestats: make reading/writing dump files Y2106 ready
Miroslav Lichvar [Fri, 19 Aug 2016 14:32:56 +0000 (16:32 +0200)] 
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.

8 years agosources: improve naming of dump files
Miroslav Lichvar [Fri, 19 Aug 2016 14:30:22 +0000 (16:30 +0200)] 
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.

8 years agosourcestats: update regression after loading dump file
Miroslav Lichvar [Fri, 19 Aug 2016 14:21:27 +0000 (16:21 +0200)] 
sourcestats: update regression after loading dump file

Call SST_DoNewRegression() immediately in SST_LoadFromFile instead of
relying on SRC_ReloadSources().

8 years agolocal: fix typo in strerror() call
Bryan Christianson [Fri, 19 Aug 2016 16:19:52 +0000 (18:19 +0200)] 
local: fix typo in strerror() call

8 years agontp: add support for SO_TIMESTAMPNS socket option
Miroslav Lichvar [Thu, 18 Aug 2016 13:39:14 +0000 (15:39 +0200)] 
ntp: add support for SO_TIMESTAMPNS socket option

Enable the SO_TIMESTAMPNS option to get kernel timestamps in nanosecond
resolution.

8 years agolocal: add support for clock_gettime()
Miroslav Lichvar [Thu, 18 Aug 2016 13:07:01 +0000 (15:07 +0200)] 
local: add support for clock_gettime()

Use clock_gettime() to read the system clock in nanosecond resolution.

8 years agoutil: modify UTI_*ToDouble functions to return double directly
Miroslav Lichvar [Thu, 18 Aug 2016 10:10:09 +0000 (12:10 +0200)] 
util: modify UTI_*ToDouble functions to return double directly

8 years agoutil: rename functions dealing with integers in NTP format
Miroslav Lichvar [Thu, 18 Aug 2016 09:48:17 +0000 (11:48 +0200)] 
util: rename functions dealing with integers in NTP format

This should prevent confusion with int32_t, int64_t and other types.

8 years agoadopt struct timespec
Miroslav Lichvar [Wed, 17 Aug 2016 14:05:53 +0000 (16:05 +0200)] 
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.

8 years agoutil: return normalised timevals
Miroslav Lichvar [Wed, 17 Aug 2016 10:13:35 +0000 (12:13 +0200)] 
util: return normalised timevals

8 years agontp: don't send crypto-NAKs
Miroslav Lichvar [Wed, 17 Aug 2016 09:54:34 +0000 (11:54 +0200)] 
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.

9 years agosourcestats: report asymmetry in statistics log
Miroslav Lichvar [Wed, 10 Aug 2016 14:17:51 +0000 (16:17 +0200)] 
sourcestats: report asymmetry in statistics log

9 years agosourcestats: correct offsets with asymmetric network jitter
Miroslav Lichvar [Wed, 10 Aug 2016 13:51:51 +0000 (15:51 +0200)] 
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.

9 years agosourcestats: add debug message for regression results
Miroslav Lichvar [Wed, 10 Aug 2016 13:10:11 +0000 (15:10 +0200)] 
sourcestats: add debug message for regression results

9 years agoregress: add linear regression with two independent variables
Miroslav Lichvar [Tue, 9 Aug 2016 13:28:32 +0000 (15:28 +0200)] 
regress: add linear regression with two independent variables

9 years agosourcestats: extend array holding peer delays
Miroslav Lichvar [Mon, 8 Aug 2016 13:51:51 +0000 (15:51 +0200)] 
sourcestats: extend array holding peer delays

Keep the same number of peer delays as offsets. This will be needed when
peer delay is included in offset correction.

9 years agoregress: save arrays of constants in single-precision
Miroslav Lichvar [Thu, 4 Aug 2016 11:59:42 +0000 (13:59 +0200)] 
regress: save arrays of constants in single-precision

No need to waste space on double precision. Also, declare them as const.

9 years agorename 'Mac OS X' to 'macOS'
Bryan Christianson [Thu, 4 Aug 2016 08:08:07 +0000 (20:08 +1200)] 
rename 'Mac OS X' to 'macOS'

From the the release of macOS Sierra (Version 10.12) the Macintosh
operating system is called 'macOS'

9 years agontp: reset tentative flag only when sample was accumulated
Miroslav Lichvar [Wed, 3 Aug 2016 10:13:22 +0000 (12:13 +0200)] 
ntp: reset tentative flag only when sample was accumulated

When selecting sources from a pool, ignore responses which didn't
produce a new sample. Sources with acceptable delay (as configured by
the maxdelay* options) should be prefered.

9 years agontp: close client sockets sooner with unsynchronised sources
Miroslav Lichvar [Wed, 3 Aug 2016 10:07:43 +0000 (12:07 +0200)] 
ntp: close client sockets sooner with unsynchronised sources

When a valid packet is received from an unsynchronised source (i.e. only
a test of leap, stratum or root distance failed), there is no point in
waiting for another packet or the RX timeout, and the client socket can
be immediately closed.

9 years agotest: add 010-multrecv
Miroslav Lichvar [Tue, 2 Aug 2016 11:44:57 +0000 (13:44 +0200)] 
test: add 010-multrecv

9 years agontp: add support for recvmmsg()
Miroslav Lichvar [Tue, 2 Aug 2016 10:17:15 +0000 (12:17 +0200)] 
ntp: add support for recvmmsg()

This is used to read multiple packets with one system call. It should
work on Linux and NetBSD.