]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
8 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.

8 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.

8 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.

8 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>
9 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

9 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.

9 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

9 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").

9 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).

9 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")
9 months 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.

9 months 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

9 months 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.

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

9 months 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

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

9 months 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

10 months 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

10 months 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

10 months 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

10 months 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.

10 months 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

10 months 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.

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

10 months 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>
10 months 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")
10 months 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.

11 months 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")
11 months 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.

11 months 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.

11 months 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.

11 months 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.

11 months 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>
11 months 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.

11 months 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.

11 months 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

11 months 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

11 months 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.

11 months 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.

11 months 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>
11 months 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.

11 months 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.

11 months 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

11 months 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.

11 months 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

11 months 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>
11 months 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

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

11 months 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")
11 months 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.

12 months 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.

12 months 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.

12 months 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.

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

12 months 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

12 months 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

13 months agotest: add 146-offline test
Miroslav Lichvar [Tue, 18 Apr 2023 09:39:27 +0000 (11:39 +0200)] 
test: add 146-offline test

13 months agomd5: fix old-style function definitions
Miroslav Lichvar [Mon, 17 Apr 2023 09:40:18 +0000 (11:40 +0200)] 
md5: fix old-style function definitions

This fixes -Wdeprecated-non-prototype clang warnings.

Reported-by: Bryan Christianson <bryan@whatroute.net>
13 months agotest: free memory in unit tests on exit
Miroslav Lichvar [Wed, 12 Apr 2023 15:24:28 +0000 (17:24 +0200)] 
test: free memory in unit tests on exit

13 months agosched: free timer blocks on exit
Miroslav Lichvar [Wed, 12 Apr 2023 14:48:36 +0000 (16:48 +0200)] 
sched: free timer blocks on exit

Save pointers to allocated timer blocks and free them on exit. This
fixes the long-standing annoying "possibly lost" leak reported by
valgrind.

13 months agotest: add 145-rtc test
Miroslav Lichvar [Wed, 12 Apr 2023 10:36:49 +0000 (12:36 +0200)] 
test: add 145-rtc test

13 months agodoc: improve description of chronyd -Q option
Miroslav Lichvar [Mon, 3 Apr 2023 13:01:19 +0000 (15:01 +0200)] 
doc: improve description of chronyd -Q option

13 months agotest: add option to dump traffic to pcaps
Miroslav Lichvar [Mon, 3 Apr 2023 12:36:30 +0000 (14:36 +0200)] 
test: add option to dump traffic to pcaps

This will be useful for debugging.

13 months agontp: save response when waiting for HW TX timestamp
Miroslav Lichvar [Tue, 28 Mar 2023 13:33:50 +0000 (15:33 +0200)] 
ntp: save response when waiting for HW TX timestamp

Rework handling of late HW TX timestamps. Instead of suspending reading
from client-only sockets that have HW TX timestamping enabled, save the
whole response if it is valid and a HW TX timestamp was received for the
source before. When the timestamp is received, or the configurable
timeout is reached, process the saved response again, but skip the
authentication test as the NTS code allows only one response per
request. Only one valid response per source can be saved. If a second
valid response is received while waiting for the timestamp, process both
responses immediately in the order they were received.

The main advantage of this approach is that it works on all sockets, i.e.
even in the symmetric mode and with NTP-over-PTP, and the kernel does
not need to buffer invalid responses.

13 months agontp: rework calculation of transmit timeout
Miroslav Lichvar [Thu, 23 Mar 2023 16:04:57 +0000 (17:04 +0100)] 
ntp: rework calculation of transmit timeout

Previously, in the calculation of the next transmission time
corresponding to the current polling interval, the reference point was
the current time in the client mode (i.e. the time when the response is
processed) and the last transmission time in the symmetric mode.

Rework the code to use the last transmission in both modes and make it
independent from the time when the response is processed to avoid extra
delays due to waiting for HW TX timestamps.

13 months agoclient: avoid casting to long
Miroslav Lichvar [Thu, 23 Mar 2023 13:07:44 +0000 (14:07 +0100)] 
client: avoid casting to long

Use the PRI*32 specifiers in printf formats to avoid casting received
values to unsigned long.

13 months agocmdmon: switch serverstats to 64-bit integers
Miroslav Lichvar [Thu, 23 Mar 2023 11:42:30 +0000 (12:42 +0100)] 
cmdmon: switch serverstats to 64-bit integers

Update the serverstats response to use the new 64-bit integers.

Don't define a new value for the response as it already had an
incompatible change since the latest release (new fields added for
timestamp counters).

13 months agoclientlog: extend serverstats counters to 64 bits
Miroslav Lichvar [Thu, 23 Mar 2023 11:32:57 +0000 (12:32 +0100)] 
clientlog: extend serverstats counters to 64 bits

On a busy server the 32-bit counters included in the serverstats report
may overflow every few hours or days. Extend them to 64 bits.

13 months agocmdmon: define 64-bit integer
Miroslav Lichvar [Thu, 23 Mar 2023 10:37:11 +0000 (11:37 +0100)] 
cmdmon: define 64-bit integer

Add a structure for 64-bit integers without requiring 64-bit alignment
to be usable in CMD_Reply without struct packing.

Add utility functions for conversion to/from network order. Avoid using
be64toh() and htobe64() as they don't seem to be available on all
supported systems.

13 months agocmdmon: add timestamp counters to serverstats report
Miroslav Lichvar [Thu, 16 Mar 2023 15:59:18 +0000 (16:59 +0100)] 
cmdmon: add timestamp counters to serverstats report

Add the new RX/TX daemon/kernel/hardware timestamp counters to the
serverstats report.

13 months agoclientlog: count RX and TX timestamps for each source
Miroslav Lichvar [Thu, 16 Mar 2023 15:56:28 +0000 (16:56 +0100)] 
clientlog: count RX and TX timestamps for each source

Count served timestamps in all combinations of RX/TX and
daemon/kernel/hardware. Repurpose CLG_LogAuthNtpRequest() to update all
NTP-specific stats in one call per accepted request and response.

13 months agoclientlog: save source of transmit timestamps
Miroslav Lichvar [Thu, 16 Mar 2023 15:51:12 +0000 (16:51 +0100)] 
clientlog: save source of transmit timestamps

Add the timestamp source to the data kept for clients using interleaved
mode to allow extending server statistics.

13 months agontp: remove unnecessary check for NULL local timestamp
Miroslav Lichvar [Thu, 16 Mar 2023 16:19:33 +0000 (17:19 +0100)] 
ntp: remove unnecessary check for NULL local timestamp

After 5f4cbaab7e0e ("ntp: optimize detection of clients using
interleaved mode") the local TX timestamp is saved for all requests
indicating interleaved mode even when no previous RX timestamp is found.

13 months agontp: add maximum PHC poll interval
Miroslav Lichvar [Tue, 14 Mar 2023 11:23:21 +0000 (12:23 +0100)] 
ntp: add maximum PHC poll interval

Specify maxpoll for HW timestamping (default minpoll + 1) to track the
PHC well even when there is little NTP traffic on the interface. After
each PHC reading schedule a timeout according to the maxpoll. Polling
between minpoll and maxpoll is still triggered by HW timestamps.

Wait for the first HW timestamp before adding the timeout to avoid
polling PHCs on interfaces that are enabled in the configuration but
not used for NTP. Add a new scheduling class to separate polling of
different PHCs to avoid too long intervals between processing I/O
events.

13 months agodoc: add missing word in serverstats description
Miroslav Lichvar [Thu, 16 Mar 2023 15:19:59 +0000 (16:19 +0100)] 
doc: add missing word in serverstats description

13 months agodoc: replace offensive words
Miroslav Lichvar [Tue, 21 Mar 2023 15:38:10 +0000 (16:38 +0100)] 
doc: replace offensive words

13 months agodoc: mention NTP port number in FAQ
Miroslav Lichvar [Mon, 13 Mar 2023 15:03:11 +0000 (16:03 +0100)] 
doc: mention NTP port number in FAQ

14 months agontp: make socket resume timeout configurable
Miroslav Lichvar [Thu, 9 Mar 2023 10:09:33 +0000 (11:09 +0100)] 
ntp: make socket resume timeout configurable

In some cases even the new timeout of 1 millisecond is not sufficient to
get all HW TX timestamps. Add a new directive to allow users to
specify longer timeouts.

14 months agontp: increase socket resume timeout to 1 millisecond
Miroslav Lichvar [Thu, 9 Mar 2023 10:37:45 +0000 (11:37 +0100)] 
ntp: increase socket resume timeout to 1 millisecond

This seems to work significantly better on some hardware and is still
shorter than burst interval at the minimum configurable poll.

14 months agontp: add support for multiple suspended sockets
Miroslav Lichvar [Wed, 8 Mar 2023 16:07:38 +0000 (17:07 +0100)] 
ntp: add support for multiple suspended sockets

With some hardware it takes milliseconds to get the HW TX timestamp.

Rework the code to handle multiple suspended client-only sockets at the
same time in order to allow longer timeouts, which may overlap for
different sources. Instead of waiting for the first read event simply
suspend the socket and create timeout when the HW TX timestamp is
requested.

14 months agontp: increment sequence id in PTP messages
Dan Drown [Tue, 7 Mar 2023 15:29:19 +0000 (16:29 +0100)] 
ntp: increment sequence id in PTP messages

14 months agotest: update description of 106-refclock
Miroslav Lichvar [Thu, 2 Mar 2023 10:29:49 +0000 (11:29 +0100)] 
test: update description of 106-refclock

14 months agorefclock_phc: support multiple extpps refclocks on one PHC
Miroslav Lichvar [Wed, 1 Mar 2023 15:39:35 +0000 (16:39 +0100)] 
refclock_phc: support multiple extpps refclocks on one PHC

The Linux kernel (as of 6.2) has a shared queue of external timestamps
for all descriptors of the same PHC. If multiple refclocks using the
same PHC and the same or different channels were specified, some
refclocks didn't receive any or most of their timestamps, depending on
the rate and timing of the events (with the previous commit avoiding
blocking reads).

Track extpps-enabled refclocks in an array. Add PHC index to the PHC
instance. When a timestamp is read from the descriptor, provide it to
all refclocks that have the same PHC index and a channel matching the
event.

Make sure the timestamp is different from the previous one in case the
kernel will be improved to duplicate the timestamps for different
descriptors.

Reported-by: Matt Corallo <ntp-lists@mattcorallo.com>
14 months agosys_linux: avoid blocking in reading of external PHC timestamp
Miroslav Lichvar [Wed, 1 Mar 2023 13:41:34 +0000 (14:41 +0100)] 
sys_linux: avoid blocking in reading of external PHC timestamp

The kernel has a common queue for all readers of a PHC device. With
multiple PHC refclocks using the same device some reads blocked. PHC
devices don't seem to support non-blocking reads. Use poll() to check if
a timestamp is available before reading from the descriptor.

14 months agotest: add array unit test
Miroslav Lichvar [Wed, 1 Mar 2023 15:02:50 +0000 (16:02 +0100)] 
test: add array unit test

14 months agoarray: add function for removing elements
Miroslav Lichvar [Wed, 1 Mar 2023 15:02:16 +0000 (16:02 +0100)] 
array: add function for removing elements

14 months agontp: count missing samples when waiting for NTS-KE
Miroslav Lichvar [Mon, 27 Feb 2023 14:29:44 +0000 (15:29 +0100)] 
ntp: count missing samples when waiting for NTS-KE

Count missing samples for the median filter when
NAU_PrepareRequestAuth() is failing.

Fixes: 4234732b0883 ("ntp: rework filter option to count missing samples")
14 months agontp: don't adjust poll interval when waiting for NTS-KE
Miroslav Lichvar [Mon, 27 Feb 2023 14:00:50 +0000 (15:00 +0100)] 
ntp: don't adjust poll interval when waiting for NTS-KE

Don't adjust the NTP polling interval and decrement the burst count when
NAU_PrepareRequestAuth() fails (e.g. no NTS-KE response received yet,
network being down, or the server refusing connections), same as if an
NTP request could not be sent. Rely on the rate limiting implemented in
the NTS code.

14 months agonts: use shorter NTS-KE retry interval when network is down
Miroslav Lichvar [Thu, 23 Feb 2023 12:10:11 +0000 (13:10 +0100)] 
nts: use shorter NTS-KE retry interval when network is down

When chronyd configured with an NTS source not specified as offline and
resolvable without network was started before the network was up, it was
using an unnecessarily long NTS-KE retry interval, same as if the server
was refusing the connections.

When the network is down, the connect() call made from NKC_Start() on
the non-blocking TCP socket should fail with a different error than
EINPROGRESS and cause NKC_Start() to return with failure. Add a constant
2-second retry interval (matching default iburst) for this case.

14 months agonts: destroy NTS-KE client right after failed start
Miroslav Lichvar [Thu, 23 Feb 2023 13:58:29 +0000 (14:58 +0100)] 
nts: destroy NTS-KE client right after failed start

When NKC_Start() fails (e.g. due to unreachable network), don't wait for
the next poll to destroy the client and another poll to create and start
it again.

15 months agoclient: add -e option to indicate end of response
Miroslav Lichvar [Thu, 2 Feb 2023 15:38:11 +0000 (16:38 +0100)] 
client: add -e option to indicate end of response

In a non-tty session with chronyc it is not possible to detect the
end of the response without relying on timeouts, or separate responses
to a repeated command if using the -c option.

Add -e option to end each response with a line containing a single dot.

15 months agodoc: improve description of refclock filter option
Miroslav Lichvar [Thu, 2 Feb 2023 14:05:05 +0000 (15:05 +0100)] 
doc: improve description of refclock filter option

15 months agodoc: describe minimum useful ntsrefresh
Miroslav Lichvar [Thu, 2 Feb 2023 13:43:19 +0000 (14:43 +0100)] 
doc: describe minimum useful ntsrefresh

15 months agosourcestats: don't fudge refclock LastRx in sources report
Miroslav Lichvar [Thu, 2 Feb 2023 10:12:31 +0000 (11:12 +0100)] 
sourcestats: don't fudge refclock LastRx in sources report

The sample time used in calculation of the last_meas_ago (LastRx) value
in the sources report is aligned to the second to minimize the leak
of the NTP receive timestamp, which could be useful in some attacks.

There is no need to do that with reference clocks, which are often used
with very short polling intervals and an extra second in the LastRx
value can be misinterpreted as a missed sample.

15 months agosources: warn about detected falsetickers
Miroslav Lichvar [Thu, 26 Jan 2023 15:21:11 +0000 (16:21 +0100)] 
sources: warn about detected falsetickers

Log a warning message for each detected falseticker, but only once
between changes in the selection of the best source. Don't print all
sources when no majority is reached as that case has its own warning
message.

15 months agosources: enable no majority message before first selection
Miroslav Lichvar [Thu, 26 Jan 2023 15:12:26 +0000 (16:12 +0100)] 
sources: enable no majority message before first selection

Add a separate flag to allow the "no majority" message to be logged even
before the first successful selection.

15 months agosources: increase log level of no majority message
Miroslav Lichvar [Thu, 26 Jan 2023 15:05:57 +0000 (16:05 +0100)] 
sources: increase log level of no majority message

When the selection fails due to no majority, log the message as a
warning to get the admin's attention.

15 months agodoc: add missing description of selection log field
Miroslav Lichvar [Thu, 26 Jan 2023 11:03:48 +0000 (12:03 +0100)] 
doc: add missing description of selection log field

15 months agoexamples: add AES keys to chrony.keys.example
Miroslav Lichvar [Wed, 25 Jan 2023 14:58:37 +0000 (15:58 +0100)] 
examples: add AES keys to chrony.keys.example

15 months agoconf: warn if not having read-only access to keys
Miroslav Lichvar [Wed, 25 Jan 2023 13:29:06 +0000 (14:29 +0100)] 
conf: warn if not having read-only access to keys

After dropping root privileges, log a warning message if chronyd
doesn't have read access or has (unnecessary) write access to the
files containing symmetric and server NTS keys.