]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
7 years agotest: add hash unit test
Miroslav Lichvar [Mon, 12 Mar 2018 11:42:07 +0000 (12:42 +0100)] 
test: add hash unit test

7 years agodoc: fix typo in chrony.conf man page
Miroslav Lichvar [Mon, 12 Mar 2018 11:30:05 +0000 (12:30 +0100)] 
doc: fix typo in chrony.conf man page

7 years agontp: add missing breaks in switch statement
Miroslav Lichvar [Mon, 12 Mar 2018 08:58:40 +0000 (09:58 +0100)] 
ntp: add missing breaks in switch statement

Fortunately, they didn't change the behavior of the code.

7 years agotest: use random version in ntp_core unit test
Miroslav Lichvar [Wed, 7 Mar 2018 12:17:29 +0000 (13:17 +0100)] 
test: use random version in ntp_core unit test

7 years agontp: respond to NTPv1 client requests with zero mode
Miroslav Lichvar [Wed, 7 Mar 2018 10:12:52 +0000 (11:12 +0100)] 
ntp: respond to NTPv1 client requests with zero mode

NTPv1 packets have a reserved field instead of the mode field and the
actual mode is determined from the port numbers. It seems there is still
a large number of clients sending NTPv1 requests with a zero value in
the field (per RFC 1059).

Follow ntpd and respond to the requests with server mode packets.

7 years agoclient: improve handling of unknown responses
Miroslav Lichvar [Tue, 6 Mar 2018 10:48:44 +0000 (11:48 +0100)] 
client: improve handling of unknown responses

Rework the code to not ignore valid packets with unknown or obsolete
responses and return immediately with "bad reply from daemon" instead of
timing out with "cannot talk to daemon".

7 years agocmdmon: initialize all bytes of reply buffer
Miroslav Lichvar [Tue, 6 Mar 2018 10:30:34 +0000 (11:30 +0100)] 
cmdmon: initialize all bytes of reply buffer

Instead of zeroing individual fields, zero all bytes of the buffer
before the reply is formed.

This may have a small impact on performance, but it simplifies the code
and minimizes the risk of leaking uninitialized memory.

7 years agocmdmon: update protocol changelog
Miroslav Lichvar [Mon, 5 Mar 2018 17:42:16 +0000 (18:42 +0100)] 
cmdmon: update protocol changelog

7 years agocmdmon: make length of manual list constant
Miroslav Lichvar [Mon, 5 Mar 2018 17:37:20 +0000 (18:37 +0100)] 
cmdmon: make length of manual list constant

Make the length of responses containing manual samples constant to
simplify the protocol. It was the only type of response that had a
variable length.

This reverts commit 2343e7a89c0bacdfccf892f881c4b89b2990c512.

7 years agontp: check RX and TX timestamp in interleaved client requests
Miroslav Lichvar [Mon, 5 Mar 2018 09:15:42 +0000 (10:15 +0100)] 
ntp: check RX and TX timestamp in interleaved client requests

Clients sending packets in the interleaved mode are supposed to use
a different receive and transmit timestamp in order to reliably detect
the mode of the response. If an interleaved request with the receive
timestamp equal to the transmit timestamp is detected, respond in the
basic mode.

7 years agodoc: update README
Miroslav Lichvar [Fri, 2 Mar 2018 13:46:08 +0000 (14:46 +0100)] 
doc: update README

7 years agocmdmon: add shutdown command
Miroslav Lichvar [Fri, 2 Mar 2018 11:51:52 +0000 (12:51 +0100)] 
cmdmon: add shutdown command

The command is functionally equivalent to sending the process the
SIGTERM signal.

7 years agontp: delay enabling permanent kernel RX timestamping on Linux
Miroslav Lichvar [Fri, 2 Mar 2018 10:49:53 +0000 (11:49 +0100)] 
ntp: delay enabling permanent kernel RX timestamping on Linux

Wait until a kernel RX timestamp is actually missing before opening the
dummy socket in order to avoid a small performance impact in case the
servers are so slow/distant that the kernel can constantly win the race.

7 years agotest: add 126-burst test
Miroslav Lichvar [Tue, 27 Feb 2018 17:41:24 +0000 (18:41 +0100)] 
test: add 126-burst test

7 years agontp: add burst option
Miroslav Lichvar [Tue, 27 Feb 2018 16:35:16 +0000 (17:35 +0100)] 
ntp: add burst option

When the burst option is specified in the server/pool directive and the
current poll is longer than the minimum poll, initiate on each poll a
burst with 1 good sample and 2 or 4 total samples according to the
difference between the current and minimum poll.

7 years agodoc: improve description of server options
Miroslav Lichvar [Tue, 27 Feb 2018 15:25:31 +0000 (16:25 +0100)] 
doc: improve description of server options

7 years agotest: make 119-smoothtime more reliable
Miroslav Lichvar [Mon, 26 Feb 2018 16:23:06 +0000 (17:23 +0100)] 
test: make 119-smoothtime more reliable

7 years agosources: include maxclockerror in source selection
Miroslav Lichvar [Thu, 22 Feb 2018 16:30:23 +0000 (17:30 +0100)] 
sources: include maxclockerror in source selection

In the source selection algorithm, include extra dispersion due to
maxclockerror in the root distance of sources that don't have new
samples (the last sample is older than span of all samples) to not
prefer unreachable sources with a short distance and small skew over
reachable sources for too long, and also to decrease their chances of
becoming falsetickers.

7 years agomain: open /dev/null as stdin/out/err in daemonization
Miroslav Lichvar [Wed, 21 Feb 2018 11:50:14 +0000 (12:50 +0100)] 
main: open /dev/null as stdin/out/err in daemonization

chronyd doesn't normally write anything to stdout or stderr when running
as a daemon, but it is a good practice to replace them with descriptors
of /dev/null to prevent accidental writes to other files or sockets that
would otherwise take their place.

7 years agologging: don't write fatal messages to invalid descriptor
Miroslav Lichvar [Wed, 21 Feb 2018 11:40:53 +0000 (12:40 +0100)] 
logging: don't write fatal messages to invalid descriptor

If opening the log file specified with the -l option failed (after
closing all descriptors), the error message is written to an invalid
descriptor as no log file or syslog is opened yet. Fix the code to track
when the output is usable.

7 years agoutil: replace assert for missing MD5 with fatal log message
Miroslav Lichvar [Wed, 21 Feb 2018 10:10:26 +0000 (11:10 +0100)] 
util: replace assert for missing MD5 with fatal log message

Apparently, on some systems the MD5 function is missing with the NSS
support (freebl3). Instead of failing an assertion, exit with a log
message.

7 years agotest: update util unit test
Miroslav Lichvar [Fri, 23 Feb 2018 15:33:42 +0000 (16:33 +0100)] 
test: update util unit test

7 years agotest: improve and extend ntp_core unit test
Miroslav Lichvar [Tue, 20 Feb 2018 16:35:16 +0000 (17:35 +0100)] 
test: improve and extend ntp_core unit test

7 years agosourcestats: limit minimum value of std_dev
Miroslav Lichvar [Fri, 23 Feb 2018 11:30:20 +0000 (12:30 +0100)] 
sourcestats: limit minimum value of std_dev

7 years agontp: compare receive timestamp when checking for duplicate
Miroslav Lichvar [Fri, 23 Feb 2018 13:17:07 +0000 (14:17 +0100)] 
ntp: compare receive timestamp when checking for duplicate

Compare both receive and transmit timestamps in the NTP test number 1.

This prevents a client from dropping a valid response in the interleaved
mode if it follows a response in the basic mode and the server did not
have a kernel/hardware transmit timestamp, and the random bits of the
two timestamps happen to be the same (chance of 1 in 2^(32-precision)).

7 years agontp: don't send packets with RX/TX timestamp equal to another timestamp
Miroslav Lichvar [Tue, 20 Feb 2018 08:46:08 +0000 (09:46 +0100)] 
ntp: don't send packets with RX/TX timestamp equal to another timestamp

Before sending a new packet, check if the receive/transmit timestamp
is not equal to the origin timestamp or the previous receive/transmit
timestamp in order to prevent the packet from being its own valid
response (in the symmetric mode) and invalidate responses to the
previous packet.

This improves protection against replay attacks in the symmetric mode.

7 years agontp: separate timestamps for restarting symmetric protocol
Miroslav Lichvar [Fri, 16 Feb 2018 16:07:56 +0000 (17:07 +0100)] 
ntp: separate timestamps for restarting symmetric protocol

Save the local receive and remote transmit timestamp needed for
(re)starting the symmetric protocol when no valid reply was received
separately from the timestamps that are used for synchronization of the
local clock.

This extends the interval in which the local NTP state is (partially)
protected against replay attacks in order to complete a measurement
in the interleaved symmetric mode from [last valid RX, next TX] to
[last TX, next TX], i.e. it should be the same as in the basic mode.

7 years agomain: create directories before refclock initialization
Miroslav Lichvar [Fri, 16 Feb 2018 09:36:41 +0000 (10:36 +0100)] 
main: create directories before refclock initialization

This allows the SOCK refclock to open sockets in the /var/run/chrony
directory.

7 years agomain: improve error message for failed getpwnam()
Miroslav Lichvar [Fri, 16 Feb 2018 09:33:04 +0000 (10:33 +0100)] 
main: improve error message for failed getpwnam()

7 years agoconfigure: improve check for timestamping options
Miroslav Lichvar [Fri, 16 Feb 2018 08:41:22 +0000 (09:41 +0100)] 
configure: improve check for timestamping options

The socket.h header provided by musl doesn't seem to include the kernel
headers and is missing SCM_TIMESTAMPING_PKTINFO, which causes the
Linux-specific code in chrony to fail to build.

7 years agopktlength: handle truncated MANUAL_LIST reply
Miroslav Lichvar [Thu, 15 Feb 2018 16:29:40 +0000 (17:29 +0100)] 
pktlength: handle truncated MANUAL_LIST reply

Before reading the n_samples field of the MANUAL_LIST reply, check if it
is actually contained in the received message. This does not change the
outcome of the client's length check as the returned length was always
larger than the length of the truncated reply and it was dropped anyway,
but it prevents the client from reading uninitialized memory.

7 years agosourcestats: reset instance before loading dump file
Miroslav Lichvar [Thu, 15 Feb 2018 16:10:45 +0000 (17:10 +0100)] 
sourcestats: reset instance before loading dump file

Don't rely on the caller to reset the instance and always reset it
before loading data to make sure it can't get to an unexpected state.

7 years agodoc: improve description of refclock tai option
Miroslav Lichvar [Thu, 15 Feb 2018 15:47:41 +0000 (16:47 +0100)] 
doc: improve description of refclock tai option

Emphasize that tzdata must be kept up to date in order for the
correction to work as expected.

7 years agotest: add 125-packetloss test
Miroslav Lichvar [Thu, 15 Feb 2018 15:47:01 +0000 (16:47 +0100)] 
test: add 125-packetloss test

7 years agotest: extend 106-refclock
Miroslav Lichvar [Thu, 15 Feb 2018 13:05:26 +0000 (14:05 +0100)] 
test: extend 106-refclock

7 years agotest: extend 110-chronyc
Miroslav Lichvar [Thu, 15 Feb 2018 12:35:06 +0000 (13:35 +0100)] 
test: extend 110-chronyc

7 years agontp: keep kernel RX timestamping permanently enabled on Linux
Miroslav Lichvar [Wed, 14 Feb 2018 09:11:19 +0000 (10:11 +0100)] 
ntp: keep kernel RX timestamping permanently enabled on Linux

The Linux kernel has a counter for sockets using kernel RX timestamping
and timestamps (all) received packets only when it is not zero. However,
this counter is updated asynchronously from setsockopt(). If there are
currently no other sockets using the timestamping, it is possible that a
fast server response is received before the kernel timestamping is
actually enabled after setting the socket option and sending a request.

Open a dummy socket on start to make sure there is always at least one
timestamping socket to avoid the race condition.

7 years agoexamples: ignore non-up/down events in nm-dispatcher script
Miroslav Lichvar [Tue, 13 Feb 2018 10:44:24 +0000 (11:44 +0100)] 
examples: ignore non-up/down events in nm-dispatcher script

7 years agosys_linux: don't keep CAP_SYS_TIME with -x option
Miroslav Lichvar [Mon, 5 Feb 2018 13:00:05 +0000 (14:00 +0100)] 
sys_linux: don't keep CAP_SYS_TIME with -x option

When dropping the root privileges, don't try to keep the CAP_SYS_TIME
capability if the -x option was enabled. This allows chronyd to be
started without the capability (e.g. in containers) and also drop the
root privileges.

7 years agontp: wait for late HW TX timestamps
Miroslav Lichvar [Fri, 2 Feb 2018 10:29:23 +0000 (11:29 +0100)] 
ntp: wait for late HW TX timestamps

When sending client requests to a close and fast server, it is possible
that a response will be received before the HW transmit timestamp of
the request itself. To avoid processing of the response without the HW
timestamp, monitor events returned by select() and suspend reading of
packets from the receive queue for up to 200 microseconds. As the
requests are normally separated by at least 200 milliseconds, it is
sufficient to monitor and suspend one socket at a time.

7 years agontp: don't request TX timestamp when SW/HW timestamping is disabled
Miroslav Lichvar [Thu, 1 Feb 2018 16:24:26 +0000 (17:24 +0100)] 
ntp: don't request TX timestamp when SW/HW timestamping is disabled

7 years agontp: add missing header guard
Miroslav Lichvar [Wed, 31 Jan 2018 16:23:40 +0000 (17:23 +0100)] 
ntp: add missing header guard

7 years agosched: allow enabling/disabling individual file handler events
Miroslav Lichvar [Tue, 30 Jan 2018 14:16:44 +0000 (15:16 +0100)] 
sched: allow enabling/disabling individual file handler events

7 years agoclient: avoid reading clock after sending request
Miroslav Lichvar [Tue, 12 Dec 2017 10:03:04 +0000 (11:03 +0100)] 
client: avoid reading clock after sending request

If chronyc sent a request which caused chronyd to step the clock (e.g.
makestep, settime) and the second reading of the clock before calling
select() to wait for a response happened after the clock was stepped, a
new request could be sent immediately and chronyd would process the same
command twice. If the second request failed (e.g. a settime request too
close to the first request), chronyc would report an error.

Change the submit_request() function to read the clock only once per
select() to wait for the first response even when the clock was stepped.

7 years agoclient: remove unused file descriptor sets
Miroslav Lichvar [Tue, 5 Dec 2017 11:09:25 +0000 (12:09 +0100)] 
client: remove unused file descriptor sets

7 years agoclient: don't call select() with invalid timeout
Miroslav Lichvar [Tue, 5 Dec 2017 10:08:24 +0000 (11:08 +0100)] 
client: don't call select() with invalid timeout

If the system clock was stepped forward after chronyc sent a request and
before it read the clock in order to calculate the receive timeout,
select() could be called with a negative timeout, which resulted in an
infinite loop waiting for select() to succeed.

Fix the submit_request() function to not call select() with a negative
timeout. Also, return immediately on any error of select().

7 years agotest: extend util unit test
Miroslav Lichvar [Tue, 5 Dec 2017 09:14:19 +0000 (10:14 +0100)] 
test: extend util unit test

7 years agoutil: avoid casting to long in UTI_DoubleToTimeval()
Miroslav Lichvar [Tue, 5 Dec 2017 08:44:59 +0000 (09:44 +0100)] 
util: avoid casting to long in UTI_DoubleToTimeval()

7 years agodoc: fix typo in chronyd man page
Vincent Blut [Thu, 30 Nov 2017 21:30:10 +0000 (22:30 +0100)] 
doc: fix typo in chronyd man page

7 years agodoc: improve leapsectz description
Miroslav Lichvar [Thu, 12 Oct 2017 11:14:25 +0000 (13:14 +0200)] 
doc: improve leapsectz description

7 years agotest: add 124-tai test
Miroslav Lichvar [Wed, 11 Oct 2017 15:30:02 +0000 (17:30 +0200)] 
test: add 124-tai test

7 years agotest: check for maxchange message in check_chronyd_exit()
Miroslav Lichvar [Wed, 11 Oct 2017 15:10:04 +0000 (17:10 +0200)] 
test: check for maxchange message in check_chronyd_exit()

7 years agorefclock: improve TAI-UTC conversion
Miroslav Lichvar [Wed, 11 Oct 2017 14:57:10 +0000 (16:57 +0200)] 
refclock: improve TAI-UTC conversion

Instead of using the TAI-UTC offset which corresponds to the current
system time, get the offset for the reference time. This allows the
clock to be accurately stepped from a time with different TAI-UTC
offset.

7 years agorefclock: remove unnecessary return statements
Miroslav Lichvar [Wed, 11 Oct 2017 10:14:25 +0000 (12:14 +0200)] 
refclock: remove unnecessary return statements

7 years agorefclock: add tai option
Chris Perl [Tue, 10 Oct 2017 17:23:21 +0000 (13:23 -0400)] 
refclock: add tai option

This option is for indicating to chronyd that the reference clock is
kept in TAI and that chrony should attempt to convert from TAI to UTC by
using the timezone configured by the "leapsectz" directive.

7 years agoreference: add function to get TAI-UTC offset
Chris Perl [Tue, 10 Oct 2017 17:23:20 +0000 (13:23 -0400)] 
reference: add function to get TAI-UTC offset

7 years agorefclock: add stratum option
Andreas Steinmetz [Mon, 9 Oct 2017 08:39:20 +0000 (10:39 +0200)] 
refclock: add stratum option

7 years agoconfigure: allow to override build date
Bernhard M. Wiedemann [Thu, 5 Oct 2017 12:13:53 +0000 (14:13 +0200)] 
configure: allow to override build date

in order to make builds reproducible.
See https://reproducible-builds.org/ for why this is good
and https://reproducible-builds.org/specs/source-date-epoch/
for the definition of this variable.

7 years agonameserv: set hints for getaddrinfo() according to -4/-6 option
Miroslav Lichvar [Wed, 4 Oct 2017 09:03:11 +0000 (11:03 +0200)] 
nameserv: set hints for getaddrinfo() according to -4/-6 option

Avoid sending unnecessary DNS requests when the -4/-6 option is
specified.

7 years agoexamples: add leapsectz to configuration examples 3.2
Miroslav Lichvar [Thu, 14 Sep 2017 13:59:59 +0000 (15:59 +0200)] 
examples: add leapsectz to configuration examples

7 years agoreference: check for gmtime() error
Miroslav Lichvar [Thu, 14 Sep 2017 13:28:37 +0000 (15:28 +0200)] 
reference: check for gmtime() error

Although gmtime() is expected to convert any time of the system clock at
least in the next few NTP eras, a correct code should always check the
returned value and this shouldn't be a fatal error in handling of leap
seconds.

7 years agodoc: fix typo in chrony.conf man page
Vincent Blut [Sun, 3 Sep 2017 12:41:14 +0000 (14:41 +0200)] 
doc: fix typo in chrony.conf man page

7 years agoconf: check if GLOB_NOMAGIC is defined
Miroslav Lichvar [Fri, 1 Sep 2017 09:32:16 +0000 (11:32 +0200)] 
conf: check if GLOB_NOMAGIC is defined

This option is not supported by musl and possibly other libc
implementations.

7 years agotest: fix keys unit test
Miroslav Lichvar [Fri, 1 Sep 2017 09:28:55 +0000 (11:28 +0200)] 
test: fix keys unit test

7 years agodoc: update NEWS 3.2-pre2
Miroslav Lichvar [Tue, 29 Aug 2017 10:59:55 +0000 (12:59 +0200)] 
doc: update NEWS

7 years agoupdate copyright years
Miroslav Lichvar [Mon, 28 Aug 2017 11:07:01 +0000 (13:07 +0200)] 
update copyright years

7 years agodoc: fix spelling
Miroslav Lichvar [Mon, 28 Aug 2017 10:44:44 +0000 (12:44 +0200)] 
doc: fix spelling

Don't mix UK and US spelling.

7 years agotest: add 123-mindelay test
Miroslav Lichvar [Fri, 25 Aug 2017 14:47:18 +0000 (16:47 +0200)] 
test: add 123-mindelay test

7 years agontp: improve maxdelayratio test
Miroslav Lichvar [Fri, 25 Aug 2017 12:57:25 +0000 (14:57 +0200)] 
ntp: improve maxdelayratio test

Similarly to the maxdelaydevratio test, include in the maximum delay
dispersion which accumulated in the interval since the last sample.
Also, enable the test for symmetric associations.

7 years agosourcestats: move maxdelaydevratio test to ntp_core
Miroslav Lichvar [Fri, 25 Aug 2017 10:29:13 +0000 (12:29 +0200)] 
sourcestats: move maxdelaydevratio test to ntp_core

Instead of giving NTP-specific data to sourcestats in order to perform
the test, provide a function to get all data needed for the test in
ntp_core. While at it, improve the naming of variables.

7 years agomemory: check for overflow when (re)allocating array
Miroslav Lichvar [Thu, 24 Aug 2017 10:10:46 +0000 (12:10 +0200)] 
memory: check for overflow when (re)allocating array

When (re)allocating an array with very large number of elements using
the MallocArray or ReallocArray macros, the calculated size of the array
could overflow size_t and less memory would be allocated than requested.

Add new functions for (re)allocating arrays that check the size and use
them in the MallocArray and ReallocArray macros.

This couldn't be exploited, because all arrays that can grow with cmdmon
or NTP requests already have their size checked before allocation, or
they are much smaller than memory allocated for structures to which they
are related (i.e. ntp_core and sourcestats instances), so a memory
allocation would fail before their size could overflow.

This issue was found in an audit performed by Cure53 and sponsored by
Mozilla.

7 years agoutil: check for gmtime() error
Miroslav Lichvar [Thu, 24 Aug 2017 09:12:14 +0000 (11:12 +0200)] 
util: check for gmtime() error

Fix the UTI_TimeToLogForm() function to check if gmtime() didn't fail.
This caused chronyc to crash due to dereferencing a NULL pointer when
a response to the "manual list" request contained time which gmtime()
could not convert to broken-down representation.

This issue was found in an audit performed by Cure53 and sponsored by
Mozilla.

7 years agoconf: use enum for RX filter
Miroslav Lichvar [Wed, 23 Aug 2017 11:55:38 +0000 (13:55 +0200)] 
conf: use enum for RX filter

7 years agontp: allow TX-only HW timestamping by default
Miroslav Lichvar [Wed, 23 Aug 2017 09:33:37 +0000 (11:33 +0200)] 
ntp: allow TX-only HW timestamping by default

If no rxfilter is specified in the hwtimestamp directive and the NIC
doesn't support the all or ntp filter, enable TX-only HW timestamping
with the none filter.

7 years agohwclock: improve debug message
Miroslav Lichvar [Tue, 22 Aug 2017 11:45:09 +0000 (13:45 +0200)] 
hwclock: improve debug message

7 years agohwclock: check if estimated frequency is sane
Miroslav Lichvar [Tue, 22 Aug 2017 11:29:48 +0000 (13:29 +0200)] 
hwclock: check if estimated frequency is sane

7 years agohwclock: drop all samples on reset
Miroslav Lichvar [Tue, 22 Aug 2017 11:13:45 +0000 (13:13 +0200)] 
hwclock: drop all samples on reset

On some HW it seems it's possible to get an occasional bad reading of
the PHC (with normal delay), or in a worse case the clock can step due
to a HW/driver bug, which triggers reset of the HW clock instance. To
avoid having a bad estimate of the frequency when the next (good) sample
is accumulated, drop also the last sample which triggered the reset.

7 years agodoc: include uncorrected offset in bound on maximum error
Miroslav Lichvar [Fri, 18 Aug 2017 18:04:31 +0000 (20:04 +0200)] 
doc: include uncorrected offset in bound on maximum error

7 years agoreference: add new fields to tracking log
Miroslav Lichvar [Tue, 22 Aug 2017 13:36:43 +0000 (15:36 +0200)] 
reference: add new fields to tracking log

Add the root delay, root dispersion and maximum estimated error in the
interval since the previous update to the tracking log.

7 years agoreference: separate calculation of root dispersion
Miroslav Lichvar [Fri, 18 Aug 2017 16:44:17 +0000 (18:44 +0200)] 
reference: separate calculation of root dispersion

7 years agoreference: refactor log writing
Miroslav Lichvar [Fri, 18 Aug 2017 16:17:16 +0000 (18:17 +0200)] 
reference: refactor log writing

Remove unnecessary parameters of the write_log() function.

7 years agoreference: don't update fallback drift on manual input
Miroslav Lichvar [Fri, 18 Aug 2017 15:43:02 +0000 (17:43 +0200)] 
reference: don't update fallback drift on manual input

This fixes a crash due to assertion failure in update_fb_drifts() when
fallbackdrift is enabled and manual input is provided.

7 years agoreference: simplify check for NaN
Miroslav Lichvar [Fri, 18 Aug 2017 15:24:41 +0000 (17:24 +0200)] 
reference: simplify check for NaN

7 years agocmdmon: add new fields to ADD_SERVER/ADD_PEER request
Miroslav Lichvar [Tue, 22 Aug 2017 15:13:27 +0000 (17:13 +0200)] 
cmdmon: add new fields to ADD_SERVER/ADD_PEER request

7 years agoconf: add mindelay and asymmetry options to NTP sources
Miroslav Lichvar [Fri, 18 Aug 2017 14:20:12 +0000 (16:20 +0200)] 
conf: add mindelay and asymmetry options to NTP sources

7 years agosourcestats: add fixed asymmetry
Miroslav Lichvar [Tue, 22 Aug 2017 14:26:40 +0000 (16:26 +0200)] 
sourcestats: add fixed asymmetry

Rework the code to allow the jitter asymmetry to be specified.

7 years agosourcestats: add fixed minimum delay
Miroslav Lichvar [Thu, 17 Aug 2017 14:44:18 +0000 (16:44 +0200)] 
sourcestats: add fixed minimum delay

If the minimum delay is known (in a static network configuration), it
can replace the measured minimum from the register. This should improve
the stability of corrections for asymmetric jitter, sample weighting and
maxdelay* tests.

7 years agosys_linux: fix building with older kernel headers
Miroslav Lichvar [Tue, 15 Aug 2017 11:39:39 +0000 (13:39 +0200)] 
sys_linux: fix building with older kernel headers

Programming pins for external PHC timestamping was added in Linux 3.15,
but the PHC subsystem is older than that. Compile the programming code
only when the ioctl is defined.

7 years agoutil: simplify clamping in UTI_TimespecNetworkToHost()
Miroslav Lichvar [Tue, 15 Aug 2017 08:53:02 +0000 (10:53 +0200)] 
util: simplify clamping in UTI_TimespecNetworkToHost()

This should fix a coverity warning.

7 years agoutil: add assertion for NTP timestamp size
Miroslav Lichvar [Tue, 15 Aug 2017 08:51:44 +0000 (10:51 +0200)] 
util: add assertion for NTP timestamp size

7 years agosmooth: don't adjust invalid time of last update
Miroslav Lichvar [Tue, 15 Aug 2017 08:03:29 +0000 (10:03 +0200)] 
smooth: don't adjust invalid time of last update

7 years agoreference: don't adjust invalid reference time
Miroslav Lichvar [Tue, 15 Aug 2017 08:01:27 +0000 (10:01 +0200)] 
reference: don't adjust invalid reference time

8 years agotest: fix ntp_core unit test
Miroslav Lichvar [Wed, 9 Aug 2017 08:41:03 +0000 (10:41 +0200)] 
test: fix ntp_core unit test

This fixes commit b896bb5a783d3fc741b94bf65616b69097b5ecaf.

8 years agosys_netbsd: fix adjtime() fault on macOS
Bryan Christianson [Tue, 8 Aug 2017 17:14:05 +0000 (05:14 +1200)] 
sys_netbsd: fix adjtime() fault on macOS

On some systems, passing NULL as the first argument to adjtime, will
result in returning the amount of adjustment outstanding from a previous
call to adjtime().

On macOS this is not allowed and the adjtime call will fault. We can
simulate the behaviour of the other systems by cancelling the current
adjustment then restarting the adjustment using the outstanding time
that was returned. On macOS 10.13 and later, the netbsd driver is now
used and must use these semantics when making/measuring corrections.

8 years agoclient: fix parsing of -v command option
Miroslav Lichvar [Tue, 8 Aug 2017 12:08:30 +0000 (14:08 +0200)] 
client: fix parsing of -v command option

The sources and sourcestats commands accept -v as an option, but the
glibc implementation of getopt() reorders the arguments and parses the
option as a command-line option of chronyc.

Add '+' to the getopt string to disable this feature. Other getopt()
implementations should consider it a new command-line option, which will
be handled as an error if present.

8 years agosched: add new timeout class for peer transmissions
Miroslav Lichvar [Tue, 8 Aug 2017 11:27:30 +0000 (13:27 +0200)] 
sched: add new timeout class for peer transmissions

This allows transmissions in symmetric mode to be scheduled
independently from client transmissions. This reduces maximum delay
in scheduling when chronyd is configured with a larger number of
servers.

8 years agotest: improve hwclock unit test
Miroslav Lichvar [Fri, 4 Aug 2017 13:24:03 +0000 (15:24 +0200)] 
test: improve hwclock unit test

8 years agohwclock: fix conversion of HW timestamps
Miroslav Lichvar [Fri, 4 Aug 2017 13:08:40 +0000 (15:08 +0200)] 
hwclock: fix conversion of HW timestamps

Fix a sign error in conversion of HW time to local time, which caused
the jitter to be amplified instead of reduced. NTP with HW timestamping
should now be more stable and able to ignore occasionally delayed
readings of PHC.

8 years agontp: minimize data in client mode packets
Miroslav Lichvar [Thu, 3 Aug 2017 15:21:16 +0000 (17:21 +0200)] 
ntp: minimize data in client mode packets

In basic client mode, set the origin and receive timestamp to zero.
This reduces the amount of information useful for fingerprinting and
improves privacy as the origin timestamp allows a passive observer to
track individual NTP clients as they move across networks. (With chrony
clients that assumes the timestamp wasn't reset by the chronyc offline
and online commands.)

This follows recommendations from the current version of IETF draft on
NTP data minimization [1].

The timestamp could be theoretically useful for enhanced rate limiting
which can limit individual clients behind NAT and better deal with DoS
attacks, but no server implementation is known to do that.

[1] https://tools.ietf.org/html/draft-ietf-ntp-data-minimization-01

8 years agoexamples: improve NetworkManager dispatcher script
Miroslav Lichvar [Thu, 3 Aug 2017 14:13:05 +0000 (16:13 +0200)] 
examples: improve NetworkManager dispatcher script

When no default route is configured, check each source if it has a
route. If the system has multiple network interfaces, this prevents
setting local NTP servers to offline when they can still be reached over
one of the interfaces.