]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
17 months agontp: add per-source counters of kernel and hardware timestamps
Miroslav Lichvar [Tue, 6 Feb 2024 13:27:14 +0000 (14:27 +0100)] 
ntp: add per-source counters of kernel and hardware timestamps

17 months agocmdmon: add ipv4/ipv6 options to add source command
Miroslav Lichvar [Mon, 5 Feb 2024 13:43:03 +0000 (14:43 +0100)] 
cmdmon: add ipv4/ipv6 options to add source command

17 months agocmdmon: simplify flag checking in handle_add_source()
Miroslav Lichvar [Mon, 5 Feb 2024 13:38:51 +0000 (14:38 +0100)] 
cmdmon: simplify flag checking in handle_add_source()

17 months agoconf: add ipv4 and ipv6 options to server/pool/peer directive
Miroslav Lichvar [Mon, 5 Feb 2024 13:20:19 +0000 (14:20 +0100)] 
conf: add ipv4 and ipv6 options to server/pool/peer directive

Accept "ipv4" and "ipv6" options in the server/pool/peer directive to
use only IPv4 or IPv6 addresses respectively.

The configuration is different from the "server [-4|-6] hostname" syntax
supported by ntpd to avoid breaking existing scripts which expect the
hostname to always be the first argument of the directives.

17 months agontp: support per-source IP family restriction
Miroslav Lichvar [Mon, 5 Feb 2024 13:06:52 +0000 (14:06 +0100)] 
ntp: support per-source IP family restriction

Add a new parameter to the NSR_AddSourceByName() function to allow
individual sources to be limited to IPv4 or IPv6 addresses. This doesn't
change the options passed to the resolver. It's just an additional
filter in the processing of resolved addresses following the -4/-6
command-line option of chronyd.

18 months agontp: fix authenticated requests in serverstats
Miroslav Lichvar [Mon, 8 Jan 2024 10:35:56 +0000 (11:35 +0100)] 
ntp: fix authenticated requests in serverstats

Fix the CLG_UpdateNtpStats() call to count requests passing the
authentication check instead of requests triggering a KoD response
(i.e. NTS NAK).

20 months agoupdate copyright years 4.5
Miroslav Lichvar [Tue, 5 Dec 2023 13:14:00 +0000 (14:14 +0100)] 
update copyright years

20 months agodoc: update FAQ on improving accuracy
Miroslav Lichvar [Tue, 5 Dec 2023 12:54:44 +0000 (13:54 +0100)] 
doc: update FAQ on improving accuracy

20 months agodoc: mention dependency of net corrections on HW timestamping
Miroslav Lichvar [Tue, 5 Dec 2023 12:03:27 +0000 (13:03 +0100)] 
doc: mention dependency of net corrections on HW timestamping

20 months agodoc: improve description of reload sources command
Miroslav Lichvar [Mon, 4 Dec 2023 11:38:03 +0000 (12:38 +0100)] 
doc: improve description of reload sources command

20 months agosources: rework logging of selection loss
Miroslav Lichvar [Tue, 28 Nov 2023 10:28:03 +0000 (11:28 +0100)] 
sources: rework logging of selection loss

The commit 5dd288dc0cbd ("sources: reselect earlier when removing
selected source") didn't cover all paths that can lead to a missing log
message when all sources are removed.

Add a flag to track the loss of selection and postpone the log message
in transient states where no message is logged to avoid spamming in
normal operation. Call SRC_SelectSource() after removing the source
to get a log message if there are no (selectable) sources left.

Reported-by: Thomas Lange <thomas@corelatus.se>
20 months agodoc: update NEWS 4.5-pre1
Miroslav Lichvar [Wed, 22 Nov 2023 09:46:33 +0000 (10:46 +0100)] 
doc: update NEWS

20 months agodoc: update README
Miroslav Lichvar [Wed, 22 Nov 2023 09:34:59 +0000 (10:34 +0100)] 
doc: update README

20 months agodoc: replace foobar naming in examples
Miroslav Lichvar [Wed, 22 Nov 2023 09:29:01 +0000 (10:29 +0100)] 
doc: replace foobar naming in examples

20 months agodoc: update description of NTP over PTP in FAQ
Miroslav Lichvar [Wed, 22 Nov 2023 08:51:14 +0000 (09:51 +0100)] 
doc: update description of NTP over PTP in FAQ

20 months agodoc: mention version supporting socket activation in FAQ
Miroslav Lichvar [Wed, 22 Nov 2023 08:50:44 +0000 (09:50 +0100)] 
doc: mention version supporting socket activation in FAQ

20 months agodoc: improve ntstrustedcerts description
Miroslav Lichvar [Wed, 22 Nov 2023 09:19:53 +0000 (10:19 +0100)] 
doc: improve ntstrustedcerts description

20 months agodoc: improve cmdport description
Miroslav Lichvar [Wed, 22 Nov 2023 08:48:36 +0000 (09:48 +0100)] 
doc: improve cmdport description

20 months agosources: drop unreachable log message
Miroslav Lichvar [Tue, 21 Nov 2023 10:25:10 +0000 (11:25 +0100)] 
sources: drop unreachable log message

With forced reselection during source removal selected_source_index
can only be INVALID_SOURCE if there are no sources. The "Can't
synchronise: no sources" message couldn't be logged even before that as
SRC_ReselectSource() resets the index before calling SRC_SelectSource().

Replace the message with an assertion.

20 months agosources: reselect earlier when removing selected source
Miroslav Lichvar [Tue, 21 Nov 2023 10:10:23 +0000 (11:10 +0100)] 
sources: reselect earlier when removing selected source

When a selected source is being removed, reset the instance and rerun
the selection while the source is still marked as selected. This forces
a "Can't synchronise" message to be logged when all sources are removed.

Reported-by: Thomas Lange <thomas@corelatus.se>
20 months agosources: reselect after resetting selected source
Miroslav Lichvar [Tue, 21 Nov 2023 10:05:41 +0000 (11:05 +0100)] 
sources: reselect after resetting selected source

Avoid showing in the sources report a selected source which has no
samples (e.g. after replacement).

20 months agontp: allow reusing timestamps of unused samples
Miroslav Lichvar [Tue, 21 Nov 2023 08:28:40 +0000 (09:28 +0100)] 
ntp: allow reusing timestamps of unused samples

When switching from basic mode to interleaved mode following a response
which wasn't accumulated due to failed test A, B, C, or D, allow
timestamps of the failed sample to be reused in interleaved mode, i.e.
replacing the server's less accurate transmit timestamp with a more
accurate timestamp server can turn a failed sample into acceptable one.

Move the presend check into test A to simplify the code.

20 months agontp: fix presend in interleaved mode
Miroslav Lichvar [Tue, 21 Nov 2023 06:51:37 +0000 (07:51 +0100)] 
ntp: fix presend in interleaved mode

The presend option in interleaved mode uses two presend requests instead
of one to get an interleaved response from servers like chrony which
delay the first interleaved response due to an optimization saving
timestamps only for clients actually using the interleaved mode.

After commit 0ae6f2485b97 ("ntp: don't use first response in interleaved
mode") the first interleaved response following the two presend
responses in basic mode is dropped as the preferred set of timestamps
minimizing error in delay was already used by the second sample in
basic mode. There are only three responses in the burst and no sample is
accumulated.

Increasing the number of presend requests to three to get a fourth
sample would be wasteful. Instead, allow reusing timestamps of the
second presend sample in basic mode, which is never accumulated.

Reported-by: Aaron Thompson
Fixes: 0ae6f2485b97 ("ntp: don't use first response in interleaved mode")
20 months agonts: close reusable sockets in helper process
Miroslav Lichvar [Mon, 20 Nov 2023 12:34:59 +0000 (13:34 +0100)] 
nts: close reusable sockets in helper process

Close all reusable sockets when the NTS-KE server helper is forked. It
is not supposed to have access to any of the server sockets, just the
socket for getting requests from the main process and the syslog socket.

20 months agosocket: provide function for closing reusable sockets
Miroslav Lichvar [Mon, 20 Nov 2023 12:34:38 +0000 (13:34 +0100)] 
socket: provide function for closing reusable sockets

20 months agosocket: set close-on-exec on all reusable sockets
Miroslav Lichvar [Mon, 20 Nov 2023 12:25:27 +0000 (13:25 +0100)] 
socket: set close-on-exec on all reusable sockets

Set the CLOEXEC flag on all reusable sockets in the initialization to
avoid leaking them to sendmail (mailonchange directive) in case the
chrony configuration doesn't use all sockets provided by systemd.

20 months agodoc: add FAQ section on minimizing service downtime
Luke Valenta [Wed, 1 Nov 2023 20:40:35 +0000 (16:40 -0400)] 
doc: add FAQ section on minimizing service downtime

20 months agosocket: add support for systemd sockets
Luke Valenta [Thu, 26 Oct 2023 16:48:56 +0000 (12:48 -0400)] 
socket: add support for systemd sockets

Before opening new IPv4/IPv6 server sockets, chronyd will check for
matching reusable sockets passed from the service manager (for example,
passed via systemd socket activation:
https://www.freedesktop.org/software/systemd/man/latest/sd_listen_fds.html)
and use those instead.

Aside from IPV6_V6ONLY (which cannot be set on already-bound sockets),
the daemon sets the same socket options on reusable sockets as it would
on sockets it opens itself.

Unit tests test the correct parsing of the LISTEN_FDS environment
variable.

Add 011-systemd system test to test socket activation for DGRAM and
STREAM sockets (both IPv4 and IPv6).  The tests use the
systemd-socket-activate test tool, which has some limitations requiring
workarounds discussed in inline comments.

20 months agologging: move severity_chars to fix compiler warning
Luke Valenta [Tue, 7 Nov 2023 19:39:40 +0000 (14:39 -0500)] 
logging: move severity_chars to fix compiler warning

20 months agologging: add log severity to file log prefix when debug is enabled
Luke Valenta [Wed, 1 Nov 2023 20:32:45 +0000 (16:32 -0400)] 
logging: add log severity to file log prefix when debug is enabled

21 months agontp: initialize network correction of transmitted packets
Miroslav Lichvar [Thu, 2 Nov 2023 11:41:55 +0000 (12:41 +0100)] 
ntp: initialize network correction of transmitted packets

Initialize the unused value of network correction parsed from
own transmitted packets to avoid a use-of-uninitialized-value error
in NIO_UnwrapMessage() reported by clang.

Fixes: 6372a9f93f59 ("ntp: save PTP correction from NTP-over-PTP messages")
21 months agodoc: document '-L -1' option for debug logging output
Luke Valenta [Fri, 20 Oct 2023 15:54:41 +0000 (11:54 -0400)] 
doc: document '-L -1' option for debug logging output

22 months agontp: add client support for network correction
Miroslav Lichvar [Tue, 26 Sep 2023 10:52:39 +0000 (12:52 +0200)] 
ntp: add client support for network correction

If the network correction is known for both the request and response,
and their sum is not larger that the measured peer delay, allowing the
transparent clocks to be running up to 100 ppm faster than the client's
clock, apply the corrections to the NTP offset and peer delay. Don't
correct the root delay to not change the estimated maximum error.

22 months agontp: add server support for network correction
Miroslav Lichvar [Tue, 26 Sep 2023 10:39:25 +0000 (12:39 +0200)] 
ntp: add server support for network correction

Provide the network correction (PTP correction + RX duration) of the
request in the new extension field if included in the request and
NTP-over-PTP is enabled.

22 months agontp: add extension field to provide network correction
Miroslav Lichvar [Tue, 26 Sep 2023 10:30:10 +0000 (12:30 +0200)] 
ntp: add extension field to provide network correction

To be able to verify PTP corrections, the client will need to know both
the correction of the request received by the server and the correction
of the response. Add a new experimental NTP extension field that the
clients will use to request the correction and servers return the
value.

22 months agontp: save PTP correction from NTP-over-PTP messages
Miroslav Lichvar [Tue, 26 Sep 2023 10:22:47 +0000 (12:22 +0200)] 
ntp: save PTP correction from NTP-over-PTP messages

When the RX duration is known (HW timestamping), save the PTP correction
from received PTP messages in the local RX timestamp.

22 months agontp: extend local timestamp for PTP correction
Miroslav Lichvar [Tue, 26 Sep 2023 10:14:56 +0000 (12:14 +0200)] 
ntp: extend local timestamp for PTP correction

Add two new fields to the NTP_Local_Timestamp structure:
- receive duration as the time it takes to receive the ethernet frame,
  currently known only with HW timestamping
- network correction as a generalized PTP correction

The PTP correction is provided by transparent clocks in the correction
field of PTP messages to remove the receive, processing and queueing
delays of network switches and routers. Only one-step end-to-end unicast
transparent clocks are useful for NTP-over-PTP. Two-step transparent
clocks use follow-up messages and peer-to-peer transparent clocks don't
handle delay requests.

The RX duration will be included in the network correction to compensate
for asymmetric link speeds of the server and client as the NTP RX
timestamp corresponds to the end of the reception (in order to
compensate for the asymmetry in the normal case when no corrections
are applied).

22 months agontp: add function for detection of experimental fields
Miroslav Lichvar [Thu, 21 Sep 2023 09:02:24 +0000 (11:02 +0200)] 
ntp: add function for detection of experimental fields

22 months agontp: assert size of exp_mono_root field
Miroslav Lichvar [Tue, 12 Sep 2023 12:03:50 +0000 (14:03 +0200)] 
ntp: assert size of exp_mono_root field

22 months agontp: rename exp1 extension field
Miroslav Lichvar [Tue, 12 Sep 2023 10:19:03 +0000 (12:19 +0200)] 
ntp: rename exp1 extension field

Rename the exp1 extension field to exp_mono_root (monotonic timestamp +
root delay/dispersion) to better distinguish it from future experimental
extension fields.

22 months agoutil: add conversion between intervals and NTP 64-bit format
Miroslav Lichvar [Thu, 21 Sep 2023 12:02:11 +0000 (14:02 +0200)] 
util: add conversion between intervals and NTP 64-bit format

This will be needed to save PTP correction in NTP timestamp format.

22 months agodoc: don't require same version for experimental features
Miroslav Lichvar [Tue, 26 Sep 2023 10:12:14 +0000 (12:12 +0200)] 
doc: don't require same version for experimental features

22 months agoconfigure: prefer gnutls over nss and tomcrypt for hashing
Miroslav Lichvar [Tue, 12 Sep 2023 08:36:23 +0000 (10:36 +0200)] 
configure: prefer gnutls over nss and tomcrypt for hashing

Reorder the tests in the configure script to prefer gnutls over nss and
tomcrypt as its support includes AES-CMAC.

22 months agoconfigure: don't try AES-SIV-CMAC in nettle when disabled
Miroslav Lichvar [Tue, 12 Sep 2023 08:19:09 +0000 (10:19 +0200)] 
configure: don't try AES-SIV-CMAC in nettle when disabled

Avoid confusing message when --without-nettle is specified.

22 months agosiv: add support for AES-GCM-SIV in gnutls
Miroslav Lichvar [Tue, 12 Sep 2023 08:18:01 +0000 (10:18 +0200)] 
siv: add support for AES-GCM-SIV in gnutls

Add support for AES-128-GCM-SIV in the current development code of
gnutls. There doesn't seem to be an API to get the cipher's minimum and
maximum nonce length and it doesn't check for invalid lengths. Hardcode
and check the limits in chrony for now.

22 months agoconf: improve log message for failed additions in sources reload
Miroslav Lichvar [Mon, 11 Sep 2023 14:14:53 +0000 (16:14 +0200)] 
conf: improve log message for failed additions in sources reload

Describe the error status in the log message when adding a source from
sourcedir failed.

22 months agoconf: cast subtraction operands in source comparison
Miroslav Lichvar [Mon, 11 Sep 2023 13:58:17 +0000 (15:58 +0200)] 
conf: cast subtraction operands in source comparison

Cast the values to int to not break the sorting in case they are changed
to unsigned types.

22 months agoconf: fix reloading modified sources specified by IP address
Miroslav Lichvar [Mon, 11 Sep 2023 13:29:04 +0000 (15:29 +0200)] 
conf: fix reloading modified sources specified by IP address

When reloading a modified source from sourcedir which is ordered before
the original source (e.g. maxpoll was decreased), the new source is
added before the original one is removed. If the source is specified by
IP address, the addition fails due to the conflict with the original
source. Sources specified by hostname don't conflict. They are resolved
later (repeatedly if the resolver provides only conflicting addresses).

Split the processing of sorted source lists into two phases, so all
modified sources are removed before they are added again to avoid the
conflict.

Reported-by: Thomas Lange <thomas@corelatus.se>
23 months agodoc: update NEWS and README 4.4
Miroslav Lichvar [Wed, 9 Aug 2023 13:20:55 +0000 (15:20 +0200)] 
doc: update NEWS and README

23 months agosocket: enable nanosecond resolution RX timestamp on FreeBSD
Josef 'Jeff' Sipek [Wed, 9 Aug 2023 11:58:38 +0000 (07:58 -0400)] 
socket: enable nanosecond resolution RX timestamp on FreeBSD

FreeBSD allows switching the receive timestamp format to struct timespec by
setting the SO_TS_CLOCK socket option to SO_TS_REALTIME after enabling
SO_TIMESTAMP.  If successful, the kernel then starts adding SCM_REALTIME
control messages instead of SCM_TIMESTAMP.

23 months agotest: make 139-nts more reliable
Miroslav Lichvar [Tue, 8 Aug 2023 15:11:46 +0000 (17:11 +0200)] 
test: make 139-nts more reliable

23 months agotest: make 114-presend more reliable
Miroslav Lichvar [Tue, 8 Aug 2023 14:21:39 +0000 (16:21 +0200)] 
test: make 114-presend more reliable

Avoid frequently ending in the middle of a client/server exchange with
long delays. This changed after commit 4a11399c2ebb ("ntp: rework
calculation of transmit timeout").

23 months agontp: don't require previous HW TX timestamp to wait for another
Miroslav Lichvar [Tue, 8 Aug 2023 13:44:25 +0000 (15:44 +0200)] 
ntp: don't require previous HW TX timestamp to wait for another

Clients sockets are closed immediately after receiving valid response.
Don't wait for the first early HW TX timestamp to enable waiting for
late timestamps. It may take a long time or never come if the HW/driver
is consistently slow. It's a chicken and egg problem.

Instead, simply check if HW timestamping is enabled on at least one
interface. Responses from NTP sources on other interfaces will always be
saved (for 1 millisecond by default).

23 months agontp: fix adding noselect to selection options
Miroslav Lichvar [Mon, 7 Aug 2023 12:52:01 +0000 (14:52 +0200)] 
ntp: fix adding noselect to selection options

If noselect is present in the configured options, don't assume it
cannot change and the effective options are equal. This fixes chronyc
selectopts +noselect command.

Fixes: 38777348143e ("sources: add function to modify selection options")
2 years agocontrib: replace tuxfamily with chrony-project
Bryan Christianson [Thu, 27 Jul 2023 23:16:00 +0000 (11:16 +1200)] 
contrib: replace tuxfamily with chrony-project

The chrony project has moved from tuxfamily.org to chrony-project.org.
Reflect these changes in the macOS startup files and documentation.

2 years agodoc: update links to chrony website
Miroslav Lichvar [Wed, 26 Jul 2023 14:36:39 +0000 (16:36 +0200)] 
doc: update links to chrony website

2 years agodoc: don't mention mailing lists in README
Miroslav Lichvar [Wed, 26 Jul 2023 14:32:28 +0000 (16:32 +0200)] 
doc: don't mention mailing lists in README

Current information about mailing lists is available on the project's
website.

2 years agoupdate copyright years
Miroslav Lichvar [Thu, 20 Jul 2023 10:57:33 +0000 (12:57 +0200)] 
update copyright years

2 years agodoc: add more questions to FAQ
Miroslav Lichvar [Thu, 20 Jul 2023 08:59:05 +0000 (10:59 +0200)] 
doc: add more questions to FAQ

2 years agodoc: fix typo in FAQ
Miroslav Lichvar [Thu, 20 Jul 2023 08:58:54 +0000 (10:58 +0200)] 
doc: fix typo in FAQ

2 years agodoc: refer to root distance in chronyc sources report
Miroslav Lichvar [Wed, 28 Jun 2023 12:53:09 +0000 (14:53 +0200)] 
doc: refer to root distance in chronyc sources report

2 years agotest: make 132-logchange more reliable
Miroslav Lichvar [Tue, 18 Jul 2023 13:16:03 +0000 (15:16 +0200)] 
test: make 132-logchange more reliable

2 years agotest: make 148-replacement more reliable
Miroslav Lichvar [Tue, 18 Jul 2023 13:15:45 +0000 (15:15 +0200)] 
test: make 148-replacement more reliable

2 years agotest: improve ntp_sources unit test
Miroslav Lichvar [Tue, 18 Jul 2023 11:08:40 +0000 (13:08 +0200)] 
test: improve ntp_sources unit test

2 years agontp: handle negotiated NTS-KE server in refreshment
Miroslav Lichvar [Mon, 17 Jul 2023 14:22:19 +0000 (16:22 +0200)] 
ntp: handle negotiated NTS-KE server in refreshment

When refreshing a source, compare the newly resolved addresses with the
originally resolved address instead of the current address to avoid
unnecessary replacements when the address is changed due to the NTS-KE
server negotiation.

2 years agonts: fix log severity for loaded server keys
Miroslav Lichvar [Tue, 11 Jul 2023 15:35:46 +0000 (17:35 +0200)] 
nts: fix log severity for loaded server keys

2 years agomakefile: compile getdate.o with -fwrapv option
Miroslav Lichvar [Mon, 26 Jun 2023 11:20:22 +0000 (13:20 +0200)] 
makefile: compile getdate.o with -fwrapv option

The getdate code (copied from gnulib before it was switched to GPLv3)
has multiple issues with signed integer overflows. Use the -fwrapv
compiler option for this object to at least make the operations defined.

2 years agodoc: update NEWS 4.4-pre2
Miroslav Lichvar [Wed, 21 Jun 2023 09:27:41 +0000 (11:27 +0200)] 
doc: update NEWS

2 years agontp: refresh IP addresses periodically
Miroslav Lichvar [Tue, 20 Jun 2023 14:23:34 +0000 (16:23 +0200)] 
ntp: refresh IP addresses periodically

Refresh NTP sources specified by hostname periodically (every 2 weeks
by default) to avoid long-running instances using a server which is no
longer intended for service, even if it is still responding correctly
and would not be replaced as unreachable, and help redistributing load
in large pools like pool.ntp.org. Only one source is refreshed at a time
to not interrupt clock updates if there are multiple selectable servers.

The refresh directive configures the interval. A value of 0 disables
the periodic refreshment.

Suggested-by: Ask Bjørn Hansen <ask@develooper.com>
2 years agodoc: remove out-of-date statement in server description
Miroslav Lichvar [Tue, 20 Jun 2023 13:28:07 +0000 (15:28 +0200)] 
doc: remove out-of-date statement in server description

chronyc refresh no longer forces replacement of sources.

Fixes: b2dac47c8267 ("ntp: avoid unneccessary replacements on refresh command")
2 years agontp: remove resolving timeout in finalization
Miroslav Lichvar [Mon, 19 Jun 2023 14:46:10 +0000 (16:46 +0200)] 
ntp: remove resolving timeout in finalization

Don't assume NSR_Finalise() can be called only on exit when the
scheduler is finalized.

2 years agosched: reset timer queue in finalization
Miroslav Lichvar [Mon, 19 Jun 2023 14:10:45 +0000 (16:10 +0200)] 
sched: reset timer queue in finalization

Don't leave dangling pointers to timer queue entries when they are
freed in the scheduler finalization in case some code tried to remove
a timer later.

Fixes: 6ea1082a72d8 ("sched: free timer blocks on exit")
2 years agoexamples: don't set ProcSubset=pid in systemd unit files
Miroslav Lichvar [Thu, 15 Jun 2023 13:23:40 +0000 (15:23 +0200)] 
examples: don't set ProcSubset=pid in systemd unit files

This option seems to break detection of the FIPS mode, which is needed
by gnutls.

2 years agosources: delay source replacement
Miroslav Lichvar [Thu, 15 Jun 2023 10:54:32 +0000 (12:54 +0200)] 
sources: delay source replacement

Wait for four consecutive source selections giving a bad status
(falseticker, bad distance or jittery) before triggering the source
replacement. This should reduce the rate of unnecessary replacements
and shorten the time needed to find a solution when unreplaceable
falsetickers are preventing other sources from forming a majority due
to switching back and forth to unreachable servers.

2 years agosources: replace reachable sources in selection
Miroslav Lichvar [Wed, 14 Jun 2023 12:52:10 +0000 (14:52 +0200)] 
sources: replace reachable sources in selection

Instead of waiting for the next update of reachability, trigger
replacement of falsetickers, jittery and distant sources as soon as
the selection status is updated in their SRC_SelectSource() call.

2 years agontp: reset poll score
Miroslav Lichvar [Thu, 15 Jun 2023 12:09:21 +0000 (14:09 +0200)] 
ntp: reset poll score

When the polling interval is reset (e.g. after replacement), don't
forget to reset also the score impacting the next poll adjustment.

2 years agomain: wait for parent process to terminate
Miroslav Lichvar [Mon, 12 Jun 2023 14:11:10 +0000 (16:11 +0200)] 
main: wait for parent process to terminate

When starting the daemon, wait in the grandparent process for the parent
process to terminate before exiting to avoid systemd logging a warning
"Supervising process $PID which is not our child". Waiting for the pipe
to be closed by the kernel when the parent process exits is not
sufficient.

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
2 years agontp: randomize replacement interval
Miroslav Lichvar [Tue, 6 Jun 2023 10:02:53 +0000 (12:02 +0200)] 
ntp: randomize replacement interval

Replacement attempts are globally rate limited to one per 7*2^8 seconds
to limit the rate of DNS requests for public servers like pool.ntp.org.
If multiple sources are repeatedly attempting replacement (at their
polling intervals), one source can be getting all attempts for periods
of time.

Use a randomly generated interval to randomize the order of source
replacements without changing the average rate.

2 years agontp: use monotonic time for replacement interval
Miroslav Lichvar [Tue, 6 Jun 2023 08:40:51 +0000 (10:40 +0200)] 
ntp: use monotonic time for replacement interval

Avoid errors in the measured interval due to clock steps.

2 years agontp: add debug message for bad sources
Miroslav Lichvar [Mon, 5 Jun 2023 13:18:27 +0000 (15:18 +0200)] 
ntp: add debug message for bad sources

2 years agoclient: check for allocation errors in tab completition
Miroslav Lichvar [Thu, 8 Jun 2023 14:04:21 +0000 (16:04 +0200)] 
client: check for allocation errors in tab completition

2 years agoclient: avoid passing uninitialized address to format_name()
Miroslav Lichvar [Mon, 5 Jun 2023 14:10:46 +0000 (16:10 +0200)] 
client: avoid passing uninitialized address to format_name()

The clang memory sanitizer seems to trigger on an uninitialized value
passed to format_name() when the source is a refclock, even though the
value is not used for anything. Pass 0 in this case to avoid the error.

2 years agomemory: use free() instead of realloc() for size 0
Miroslav Lichvar [Mon, 5 Jun 2023 13:40:22 +0000 (15:40 +0200)] 
memory: use free() instead of realloc() for size 0

valgrind 3.21.0 reports realloc() of 0 bytes as an error due to having
different behavior on different systems. The only place where this can
happen in chrony is the array, which doesn't care what value realloc()
returns.

Modify the realloc wrapper to call free() in this case to make valgrind
happy.

2 years agosys_linux: allow writev and TIOCGWINSZ in seccomp filter
Miroslav Lichvar [Thu, 1 Jun 2023 12:30:40 +0000 (14:30 +0200)] 
sys_linux: allow writev and TIOCGWINSZ in seccomp filter

Allow more syscalls for musl.

Reported-by: jvoisin <julien.voisin@dustri.org>
2 years agotest: set root ownership of tmp directory in system tests
Miroslav Lichvar [Thu, 1 Jun 2023 09:56:29 +0000 (11:56 +0200)] 
test: set root ownership of tmp directory in system tests

Allow the tests to be started under a non-zero GID.

2 years agotest: modify order of scfilter levels in system tests
Miroslav Lichvar [Mon, 29 May 2023 14:17:39 +0000 (16:17 +0200)] 
test: modify order of scfilter levels in system tests

Start with positive levels to get the offending system calls in the
system or audit log.

2 years agotest: fix 010-nts test for AES-GCM-SIV support
Miroslav Lichvar [Thu, 1 Jun 2023 12:51:38 +0000 (14:51 +0200)] 
test: fix 010-nts test for AES-GCM-SIV support

2 years agonts: don't load zero-length keys with unsupported algorithm
Miroslav Lichvar [Mon, 29 May 2023 12:12:54 +0000 (14:12 +0200)] 
nts: don't load zero-length keys with unsupported algorithm

Don't load keys and cookies from the client's dump file if it has an
unsupported algorithm and unparseable keys (matching the algorithm's
expected length of zero). They would fail all SIV operations and trigger
new NTS-KE session.

2 years agodoc: clarify limitation of refresh command
Miroslav Lichvar [Wed, 24 May 2023 13:41:45 +0000 (15:41 +0200)] 
doc: clarify limitation of refresh command

2 years agosys_linux: allow membarrier in seccomp filter
Miroslav Lichvar [Wed, 24 May 2023 08:56:07 +0000 (10:56 +0200)] 
sys_linux: allow membarrier in seccomp filter

This system call is used by musl.

Reported-by: jvoisin <julien.voisin@dustri.org>
2 years agoconfigure: add option to disable AES-GCM-SIV support
Miroslav Lichvar [Tue, 23 May 2023 14:36:25 +0000 (16:36 +0200)] 
configure: add option to disable AES-GCM-SIV support

2 years agonts: remove superfluous semicolon
Miroslav Lichvar [Tue, 23 May 2023 13:40:47 +0000 (15:40 +0200)] 
nts: remove superfluous semicolon

2 years agonts: initialize unused part of server key
Miroslav Lichvar [Tue, 23 May 2023 13:37:06 +0000 (15:37 +0200)] 
nts: initialize unused part of server key

Initialize the unused part of shorter server NTS keys (AES-128-GCM-SIV)
loaded from ntsdumpdir to avoid sending uninitialized data in requests
to the NTS-KE helper process.

Do that also for newly generated keys in case the memory will be
allocated dynamically.

Fixes: b1230efac333 ("nts: add support for encrypting cookies with AES-128-GCM-SIV")
2 years agontp: randomize address selection on all source replacements
Miroslav Lichvar [Mon, 22 May 2023 09:58:41 +0000 (11:58 +0200)] 
ntp: randomize address selection on all source replacements

If the resolver orders addresses by IP family, there is more than one
address in the preferred IP family, and they are all reachable, but
not selectable (e.g. falsetickers in a small pool which cannot remove
them from DNS), chronyd is unable to switch to addresses in the other IP
family as it follows the resolver's order.

Enable randomization of the address selection for all source
replacements and not just replacement of (unreachable) tentative
sources. If the system doesn't have connectivity in the other family,
the addresses will be skipped and no change in behavior should be
observed.

2 years agontp: set minimum polltarget
Miroslav Lichvar [Wed, 17 May 2023 14:37:55 +0000 (16:37 +0200)] 
ntp: set minimum polltarget

The polltarget value is used in a floating-point division in the
calculation of the poll adjustment. Set 1 as the minimum accepted
polltarget value to avoid working with infinite values.

2 years agontp: reset polling interval when replacing sources
Miroslav Lichvar [Tue, 16 May 2023 13:11:22 +0000 (15:11 +0200)] 
ntp: reset polling interval when replacing sources

Set the polling interval to minpoll when changing address of a source,
but only if it is reachable to avoid increasing load on server or
network in case that is the reason for the source being unreachable.

This shortens the time needed to replace a falseticker or
unsynchronized source with a selectable source.

2 years agontp: avoid unneccessary replacements on refresh command
Miroslav Lichvar [Mon, 15 May 2023 14:26:21 +0000 (16:26 +0200)] 
ntp: avoid unneccessary replacements on refresh command

When the refresh command is issued, instead of trying to replace all
NTP sources as if they were unreachable or falsetickers, keep using the
current address if it is still returned by the resolver for the name.
This avoids unnecessary loss of measurements and switching to
potentially unreachable addresses.

2 years agodoc: update NEWS 4.4-pre1
Miroslav Lichvar [Wed, 10 May 2023 09:42:01 +0000 (11:42 +0200)] 
doc: update NEWS

2 years agodoc: update list of contributors in README
Miroslav Lichvar [Wed, 10 May 2023 07:59:44 +0000 (09:59 +0200)] 
doc: update list of contributors in README

2 years agoexamples: improve chrony.nm-dispatcher.onoffline script
Rupesh Patel [Fri, 28 Apr 2023 15:31:40 +0000 (15:31 +0000)] 
examples: improve chrony.nm-dispatcher.onoffline script