]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
4 years agosource: don't print duplicated address in selection message
Miroslav Lichvar [Tue, 4 May 2021 09:49:54 +0000 (11:49 +0200)] 
source: don't print duplicated address in selection message

Don't print the original IP address in parentheses in the "Selected
source ..." message if it is identical to the current address. That is
expected to be the usual case for sources specified by IP address.

4 years agoconf: log error when source cannot be added
Miroslav Lichvar [Tue, 4 May 2021 09:08:59 +0000 (11:08 +0200)] 
conf: log error when source cannot be added

Log an error message when adding of a source fails, e.g. due to the new
limit on number of sources, or when the same address is specified
multiple times.

4 years agonts: close file after loading cookies
Miroslav Lichvar [Mon, 3 May 2021 12:15:28 +0000 (14:15 +0200)] 
nts: close file after loading cookies

Don't forget to close the file with cookies in ntsdumpdir if
successfully loaded.

Fixes: 2fa83b541c36 ("nts: save and load cookies on client")
4 years agonts: ignore long non-critical records
Miroslav Lichvar [Mon, 3 May 2021 10:48:23 +0000 (12:48 +0200)] 
nts: ignore long non-critical records

In the NTS-KE client don't reject the response if it has non-critical
records that are too long for the processing buffer. This is not
expected to happen with the current specification, but it might be
needed with future extensions.

Fixes: 7925ed39b81f ("nts: fix handling of long server negotiation record")
4 years agotest: fix date use in 010-nts system test
Miroslav Lichvar [Thu, 29 Apr 2021 12:45:30 +0000 (14:45 +0200)] 
test: fix date use in 010-nts system test

Avoid using nonportable -d option of date.

4 years agotest: remove logs before chronyd start in system tests
Miroslav Lichvar [Thu, 29 Apr 2021 11:15:03 +0000 (13:15 +0200)] 
test: remove logs before chronyd start in system tests

4 years agotest: extend configuration in system tests
Miroslav Lichvar [Thu, 29 Apr 2021 11:14:11 +0000 (13:14 +0200)] 
test: extend configuration in system tests

4 years agotest: rework seccomp testing
Miroslav Lichvar [Thu, 29 Apr 2021 11:18:39 +0000 (13:18 +0200)] 
test: rework seccomp testing

Instead of a single test with enabled seccomp, rerun all other
non-destructive and destructive tests for each seccomp level.

4 years agosys_linux: allow BINDTODEVICE option in seccomp filter
Miroslav Lichvar [Thu, 29 Apr 2021 10:35:49 +0000 (12:35 +0200)] 
sys_linux: allow BINDTODEVICE option in seccomp filter

Fixes: 4ef944b73436 ("socket: add support for binding sockets to device")
4 years agodoc: warn about -F and mailonchange in chronyd man page
Miroslav Lichvar [Thu, 29 Apr 2021 07:18:49 +0000 (09:18 +0200)] 
doc: warn about -F and mailonchange in chronyd man page

4 years agonts: avoid assumption about cookie record
Miroslav Lichvar [Tue, 27 Apr 2021 13:39:59 +0000 (15:39 +0200)] 
nts: avoid assumption about cookie record

The cookie record is currently assumed to be the longest record that
needs to be accepted by the client, but that does not have to be always
the case. Define the processing buffer using the maximum body record
constant instead and add an assertion to make sure it's not smaller than
the maximum accepted cookie length.

4 years agonts: fix handling of long server negotiation record
Miroslav Lichvar [Tue, 27 Apr 2021 09:18:04 +0000 (11:18 +0200)] 
nts: fix handling of long server negotiation record

Recent change in handling of the NTPv4 server negotiation record (commit
754097944be2) increased the length of the instance name buffer to make
room for the trailing dot. This allowed a record with body truncated in
the processing buffer to be accepted and caused an over-read of 1 byte
in the memcpy() call saving the name to the instance buffer.

Modify the client to accept only records that fit in the processing
buffer.

Fixes: 754097944be2 ("nts: handle negotiated server as FQDN")
4 years agodoc: update NEWS 4.1-pre1
Miroslav Lichvar [Tue, 20 Apr 2021 12:16:11 +0000 (14:16 +0200)] 
doc: update NEWS

4 years agodoc: update README
Miroslav Lichvar [Tue, 20 Apr 2021 10:37:40 +0000 (12:37 +0200)] 
doc: update README

4 years agontp: fix address in error message
Miroslav Lichvar [Wed, 21 Apr 2021 13:56:51 +0000 (15:56 +0200)] 
ntp: fix address in error message

4 years agonameserv: avoid sockaddr_in6 with disabled IPv6 support
Miroslav Lichvar [Wed, 21 Apr 2021 12:40:12 +0000 (14:40 +0200)] 
nameserv: avoid sockaddr_in6 with disabled IPv6 support

Fixes: 10c760a80c15 ("nameserv: require getaddrinfo() and getnameinfo()")
4 years agotest: extend 129-reload test
Miroslav Lichvar [Wed, 21 Apr 2021 10:50:47 +0000 (12:50 +0200)] 
test: extend 129-reload test

4 years agosources: fix loading of refclock dump files
Miroslav Lichvar [Wed, 21 Apr 2021 10:52:17 +0000 (12:52 +0200)] 
sources: fix loading of refclock dump files

Allow zero stratum in loaded dump files.

Fixes: f8610d69f08f ("sources: improve handling of dump files and their format")
4 years agosources: don't print NULL string to dump file
Miroslav Lichvar [Wed, 21 Apr 2021 10:51:07 +0000 (12:51 +0200)] 
sources: don't print NULL string to dump file

For reference clocks, which don't have a name, print "." instead of
NULL.

Fixes: f8610d69f08f ("sources: improve handling of dump files and their format")
4 years agonts: handle negotiated server as FQDN
Miroslav Lichvar [Wed, 21 Apr 2021 07:37:40 +0000 (09:37 +0200)] 
nts: handle negotiated server as FQDN

The NTS RFC requires the recipient of the Server Negotiation NTS-KE
record to handle the name as a fully qualified domain name. Add a
trailing dot if not present to force the name to be resolved as one.

4 years agotest: extend 106-refclock test
Miroslav Lichvar [Tue, 20 Apr 2021 15:43:20 +0000 (17:43 +0200)] 
test: extend 106-refclock test

4 years agodoc: improve description of allow directive
Miroslav Lichvar [Tue, 20 Apr 2021 07:54:52 +0000 (09:54 +0200)] 
doc: improve description of allow directive

Prefer CIDR notation, clarify use of hostnames and order of allow/deny
directives, refer to the accheck command.

4 years agosys_timex: remove workaround for broken ntp_adjtime on macOS
Bryan Christianson [Mon, 19 Apr 2021 21:32:52 +0000 (09:32 +1200)] 
sys_timex: remove workaround for broken ntp_adjtime on macOS

Early beta releases of macOS Big Sur had a signed/unsigned error in
Apple's implementation of ntp_adjtime. Apple have since fixed this error
and the workaround is no longer required.

4 years agodoc: improve FAQ
Miroslav Lichvar [Tue, 13 Apr 2021 10:07:38 +0000 (12:07 +0200)] 
doc: improve FAQ

4 years agoconf: require sourcedir files to be terminated by newline
Miroslav Lichvar [Thu, 15 Apr 2021 07:43:01 +0000 (09:43 +0200)] 
conf: require sourcedir files to be terminated by newline

When reading a *.sources file require that each line is termined by the
newline character to avoid processing an unfinished line, e.g. due to an
unexpected call of the reload command when the file is being written in
place.

4 years agotest: make system tests more reliable
Miroslav Lichvar [Thu, 15 Apr 2021 09:26:29 +0000 (11:26 +0200)] 
test: make system tests more reliable

4 years agotest: update and extend 110-chronyc test
Miroslav Lichvar [Tue, 13 Apr 2021 14:34:34 +0000 (16:34 +0200)] 
test: update and extend 110-chronyc test

4 years agontp: add copy option
Miroslav Lichvar [Wed, 14 Apr 2021 13:58:51 +0000 (15:58 +0200)] 
ntp: add copy option

When separate client and server instances of chronyd are running on one
computer (e.g. for security or performance reasons) and are synchronized
to each other, the server instance provides a reference ID based on the
local address used for synchronization of its NTP clock, which breaks
detection of synchronization loops for its own clients.

Add a "copy" option to specify that the server and client are closely
related, no loop can form between them, and the client should assume the
reference ID and stratum of the server to fix detection of loops between
the server and clients of the client.

4 years agontp: clamp remote stratum
Miroslav Lichvar [Wed, 14 Apr 2021 10:36:28 +0000 (12:36 +0200)] 
ntp: clamp remote stratum

Don't set the remote stratum (used for polling adjustments) to values
larger than 16.

4 years agontp: don't update source status with unsynchronized data
Miroslav Lichvar [Wed, 14 Apr 2021 10:17:22 +0000 (12:17 +0200)] 
ntp: don't update source status with unsynchronized data

Don't update the leap and stratum used in source selection if they
indicate an unsynchronized source.

Fixes: 2582be8754ab ("sources: separate update of leap status")
4 years agorefclock: drop return after LOG_FATAL
Uwe Kleine-König [Fri, 9 Apr 2021 06:12:27 +0000 (08:12 +0200)] 
refclock: drop return after LOG_FATAL

The LOG_FATAL macro expands to (emitting the message and then) exit(1).
So a return after LOG_FATAL isn't reached. Drop all those to simplify
the code a bit.

4 years agontp: fix loop test for special reference modes
Miroslav Lichvar [Tue, 6 Apr 2021 16:05:54 +0000 (18:05 +0200)] 
ntp: fix loop test for special reference modes

It is not sufficient to check for disabled server sockets as they are
not open only after the special reference modes end (e.g. initstepslew).

Fixes: 004986310d2a ("ntp: skip loop test if no server socket is open")
4 years agosys_linux: allow setsockopt(SOL_IP, IP_TOS) in seccomp
Foster Snowhill [Sun, 4 Apr 2021 13:12:17 +0000 (15:12 +0200)] 
sys_linux: allow setsockopt(SOL_IP, IP_TOS) in seccomp

This system call is required by the DSCP marking feature introduced in commit
6a5665ca5877 ("conf: add dscp directive").

Before this change, enabling seccomp filtering (chronyd -F 1) and specifying a
custom DSCP value in the configuration (for example "dscp 46") caused the
process to be killed by seccomp due to IP_TOS not being allowed by the filter.

Tested before and after the change on Ubuntu 21.04, kernel 5.11.0-13-generic.
IP_TOS is available since Linux 1.0, so I didn't add any ifdefs for it.

Signed-off-by: Foster Snowhill <forst@forstwoof.ru>
4 years agodoc: improve chrony.conf man page
Miroslav Lichvar [Wed, 7 Apr 2021 14:37:11 +0000 (16:37 +0200)] 
doc: improve chrony.conf man page

4 years agodoc: improve FAQ
Miroslav Lichvar [Tue, 6 Apr 2021 14:28:56 +0000 (16:28 +0200)] 
doc: improve FAQ

Add new questions, fix typos and version-specific information.

4 years agotest: extend 103-initstepslew test
Miroslav Lichvar [Tue, 6 Apr 2021 14:38:34 +0000 (16:38 +0200)] 
test: extend 103-initstepslew test

4 years agotest: enable valgrind in more tests
Miroslav Lichvar [Wed, 24 Mar 2021 16:50:33 +0000 (17:50 +0100)] 
test: enable valgrind in more tests

4 years agotest: extend 106-refclock test
Miroslav Lichvar [Thu, 18 Mar 2021 16:37:13 +0000 (17:37 +0100)] 
test: extend 106-refclock test

4 years agorefclock: increase PPS lock limit
Miroslav Lichvar [Thu, 18 Mar 2021 10:49:08 +0000 (11:49 +0100)] 
refclock: increase PPS lock limit

Increase the maximum acceptable offset of the PPS lock reference from
20% to 40% of the PPS interval to not require the refclock offset to be
specified in configuration so accurately, or enable operation with a
highly unstable reference clock.

4 years agodeclare variables set from signal handlers as volatile
Miroslav Lichvar [Wed, 17 Mar 2021 08:21:42 +0000 (09:21 +0100)] 
declare variables set from signal handlers as volatile

Make sure variables set from signal handlers are not cached in
registers.

4 years agoconfigure: use well-known file name conftest.c
Kamil Dudka [Mon, 15 Mar 2021 09:27:40 +0000 (10:27 +0100)] 
configure: use well-known file name conftest.c

... for configuration checks.  Compiler wrappers check for this name
in order to skip any instrumentation of the build that is intended
for regular source files only.

4 years agotest: extend ntp_sources unit test
Miroslav Lichvar [Tue, 9 Mar 2021 13:10:48 +0000 (14:10 +0100)] 
test: extend ntp_sources unit test

4 years agotest: drop logging suspension
Miroslav Lichvar [Tue, 9 Mar 2021 11:34:41 +0000 (12:34 +0100)] 
test: drop logging suspension

Instead of selectively suspending logging by redirecting messages to
/dev/null, increase the default minimum log severity to FATAL. In the
debug mode, all messages are printed.

4 years agocmdmon: return error if doffset command fails
Miroslav Lichvar [Thu, 4 Mar 2021 09:06:22 +0000 (10:06 +0100)] 
cmdmon: return error if doffset command fails

4 years agocmdmon: convert doffset request to float
Miroslav Lichvar [Wed, 3 Mar 2021 17:18:54 +0000 (18:18 +0100)] 
cmdmon: convert doffset request to float

4 years agolocal: return status from offset accumulation
Miroslav Lichvar [Thu, 4 Mar 2021 08:59:25 +0000 (09:59 +0100)] 
local: return status from offset accumulation

Change the functions accumulating offset to return success or failure.

4 years agoclient: report invalid values in doffset and dfreq commands
Miroslav Lichvar [Wed, 3 Mar 2021 17:06:50 +0000 (18:06 +0100)] 
client: report invalid values in doffset and dfreq commands

4 years agotest: extend util unit test
Miroslav Lichvar [Wed, 3 Mar 2021 16:22:26 +0000 (17:22 +0100)] 
test: extend util unit test

4 years agotest: use env shebang in all bash scripts
Miroslav Lichvar [Wed, 3 Mar 2021 11:09:38 +0000 (12:09 +0100)] 
test: use env shebang in all bash scripts

This allows the scripts to be executed on systems that don't have bash
in /bin. This fixes "make check".

4 years agotest: extend 007-cmdmon system test
Miroslav Lichvar [Wed, 3 Mar 2021 10:31:53 +0000 (11:31 +0100)] 
test: extend 007-cmdmon system test

4 years agoutil: require inet_pton()
Miroslav Lichvar [Tue, 2 Mar 2021 16:28:02 +0000 (17:28 +0100)] 
util: require inet_pton()

Always use inet_pton() for converting IP addresses. It should be
available on all currently supported systems.

4 years agonameserv: avoid unnecessary getaddrinfo() calls
Miroslav Lichvar [Tue, 2 Mar 2021 16:24:09 +0000 (17:24 +0100)] 
nameserv: avoid unnecessary getaddrinfo() calls

Check if the name passed to DNS_Name2IPAddress() is an IP address
before calling getaddrinfo(), which can be much slower and work
differently on different systems.

4 years agonameserv: require getaddrinfo() and getnameinfo()
Miroslav Lichvar [Tue, 2 Mar 2021 15:55:37 +0000 (16:55 +0100)] 
nameserv: require getaddrinfo() and getnameinfo()

Remove support for the long-deprecated gethostbyname() and
gethostbyaddr() functions.

4 years agocmdmon: fix responding to IPv4 addresses on FreeBSD
Miroslav Lichvar [Tue, 2 Mar 2021 12:10:13 +0000 (13:10 +0100)] 
cmdmon: fix responding to IPv4 addresses on FreeBSD

On FreeBSD, the source address cannot be specified when sending a
message on a socket bound to a non-any IPv4 address, e.g. in default
configuration 127.0.0.1. In this case, make the address unspecified.

This is similar to commit 6af39d63aa93 ("ntp: don't use IP_SENDSRCADDR
on bound socket").

Fixes: f06c1cfa97f8 ("cmdmon: respond from same address")
4 years agomain: suppress info messages with -p option
Miroslav Lichvar [Tue, 2 Mar 2021 11:21:52 +0000 (12:21 +0100)] 
main: suppress info messages with -p option

Log (to stderr) only warnings and higher when printing the
configuration to suppress the "chronyd starting" message.

4 years agosys_linux: check if statx syscall is defined
Miroslav Lichvar [Mon, 1 Mar 2021 09:13:19 +0000 (10:13 +0100)] 
sys_linux: check if statx syscall is defined

statx seems to be missing in older kernel and libseccomp headers, still
used on some supported systems.

4 years agomain: warn if running with root privileges
Miroslav Lichvar [Thu, 25 Feb 2021 16:04:01 +0000 (17:04 +0100)] 
main: warn if running with root privileges

Log a warning message if the main process has not dropped the root
privileges, i.e. when the compiled-in user or user specified by the user
directive or -u option is root.

4 years agorefclock: warn if lock refid is invalid
Miroslav Lichvar [Thu, 25 Feb 2021 15:59:27 +0000 (16:59 +0100)] 
refclock: warn if lock refid is invalid

Log a warning message if the specified lock refid doesn't match any
existing refclock or it matches the refclock which has the lock option
itself.

4 years agorefclock: warn if maxlockage is too small
Miroslav Lichvar [Thu, 25 Feb 2021 15:51:23 +0000 (16:51 +0100)] 
refclock: warn if maxlockage is too small

Log a warning message if the interval covered by the maxlockage at the
PPS rate of a refclock is shorter than driver poll of the locked
refclock.

Reported-by: Matt Corallo <ntp-lists@mattcorallo.com>
4 years agontp: restart resolving on online command
Miroslav Lichvar [Wed, 24 Feb 2021 12:04:27 +0000 (13:04 +0100)] 
ntp: restart resolving on online command

If the online command is received when the resolver is running, start
it again as soon as it finishes instead of waiting for the timer.

This should reduce the time needed to get all sources resolved on boot
if chronyd is started before the network is online and the chronyc
online command is issued before the first round of resolving can finish,
e.g. due to an unreachable DNS server in resolv.conf.

4 years agotest: extend 139-nts test
Miroslav Lichvar [Thu, 18 Feb 2021 16:31:29 +0000 (17:31 +0100)] 
test: extend 139-nts test

4 years agocmdmon: set certset for new sources
Miroslav Lichvar [Thu, 18 Feb 2021 16:22:23 +0000 (17:22 +0100)] 
cmdmon: set certset for new sources

Add the new certset option to the cmdmon protocol.

4 years agoconf: add certset option to NTP sources
Miroslav Lichvar [Thu, 18 Feb 2021 16:18:15 +0000 (17:18 +0100)] 
conf: add certset option to NTP sources

Allow the set of trusted certificates to be selected for each NTP
source individually.

4 years agoconf: add set selection to ntstrustedcerts
Miroslav Lichvar [Thu, 18 Feb 2021 16:15:10 +0000 (17:15 +0100)] 
conf: add set selection to ntstrustedcerts

Add an optional set-ID argument to the ntstrustedcerts directive to
enable multiple sets of trusted certificates to be specified.

4 years agonts: add support for multiple sets of trusted certificates
Miroslav Lichvar [Thu, 18 Feb 2021 15:53:36 +0000 (16:53 +0100)] 
nts: add support for multiple sets of trusted certificates

Modify the session, NTS-KE, and NTS-NTP code to support multiple sets of
trusted certificates and identify the sets by a 32-bit ID.

4 years agoconfigure: check for O_NOFOLLOW flag
Miroslav Lichvar [Tue, 16 Feb 2021 12:54:42 +0000 (13:54 +0100)] 
configure: check for O_NOFOLLOW flag

If the O_NOFOLLOW flag used by open() is not defined, try it with
_GNU_SOURCE. This is needed with glibc-2.11 and earlier.

Reported-by: Marius Rohde <marius.rohde@meinberg.de>
4 years agosys_linux: allow statx and fstatat64 in seccomp filter
Christian Ehrhardt [Fri, 12 Feb 2021 09:19:55 +0000 (10:19 +0100)] 
sys_linux: allow statx and fstatat64 in seccomp filter

With glibc 2.33 on armhf statx and fstatat64 are triggered.
Allow this call to un-break chrony on such platforms.

Without this e.g. test 005-scfilter fails and with ltrace -rTS reports:
a)
  0.001684 SYS_397(11, 0xf75def08, 6144, 2047 <no return ...>
  0.759239 +++ killed by SIGSYS +++
b)
  0.003749 SYS_327(-100, 0xffdbcc3c, 0xffdbcb50, 0)
  0.000821 --- SIGSYS (Bad system call) ---

Current armhf syscalls from:
https://github.com/torvalds/linux/blob/v5.10/arch/arm/tools/syscall.tbl

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agonts: allow ntstrustedcerts to specify directory
Miroslav Lichvar [Thu, 11 Feb 2021 14:43:49 +0000 (15:43 +0100)] 
nts: allow ntstrustedcerts to specify directory

If the specified path is a directory, load all certificates in the
directory.

4 years agonts: allow multiple files with trusted certificates
Miroslav Lichvar [Thu, 11 Feb 2021 11:20:59 +0000 (12:20 +0100)] 
nts: allow multiple files with trusted certificates

Allow the ntstrustedcerts directive to be specified multiple times.

4 years agonts: allow multiple server keys and certificates
Miroslav Lichvar [Thu, 11 Feb 2021 11:26:35 +0000 (12:26 +0100)] 
nts: allow multiple server keys and certificates

Allow the ntsservercert and ntsserverkey directives to be specified
multiple times to enable the NTS-KE server to operate under multiple
names.

4 years agonts: define type for credentials
Miroslav Lichvar [Thu, 11 Feb 2021 10:05:25 +0000 (11:05 +0100)] 
nts: define type for credentials

Add a NKSN_Credentials type to avoid referring to it as void *.

4 years agonts: split creating server and client credentials
Miroslav Lichvar [Thu, 11 Feb 2021 09:52:06 +0000 (10:52 +0100)] 
nts: split creating server and client credentials

4 years agoclient: fix sourcename command to accept ID addresses
Miroslav Lichvar [Wed, 10 Feb 2021 11:16:18 +0000 (12:16 +0100)] 
client: fix sourcename command to accept ID addresses

Fix the command to print the name corresponding to an unresolved
address.

4 years agontp: simplify NSR_Finalise()
Miroslav Lichvar [Wed, 10 Feb 2021 12:35:51 +0000 (13:35 +0100)] 
ntp: simplify NSR_Finalise()

4 years agontp: limit number of sources
Miroslav Lichvar [Wed, 10 Feb 2021 12:21:37 +0000 (13:21 +0100)] 
ntp: limit number of sources

Don't rely on assertions and running out of memory to terminate if
an extremely large number of sources is added. Set the maximum number
to 65536 to have a practical limit where chronyd still has a chance to
appear functional with some operations having a quadratic time
complexity.

4 years agonts: reset NTP address/port if removed in NTS-KE
Miroslav Lichvar [Wed, 10 Feb 2021 15:15:15 +0000 (16:15 +0100)] 
nts: reset NTP address/port if removed in NTS-KE

When an NTS-KE server stops providing the NTP address or port, change
them to the original values to avoid the client getting stuck
with a non-responding address/port.

4 years agonts: load cookies early
Miroslav Lichvar [Wed, 10 Feb 2021 11:23:13 +0000 (12:23 +0100)] 
nts: load cookies early

Instead of waiting for the first request, try to load the cookies as
soon as the instance is created, or the NTS address is changed.

This enables loading of dump files for servers that are negotiated in
NTS-KE.

4 years agonts: rework update of NTP server address
Miroslav Lichvar [Tue, 9 Feb 2021 16:40:17 +0000 (17:40 +0100)] 
nts: rework update of NTP server address

In the NTS-NTP client instance, maintain a local copy of the NTP address
instead of using a pointer to the NCR's address, which may change at
unexpected times.

Also, change the NNC_CreateInstance() to accept only the NTP port to
make it clear the initial NTP address is the same as the NTS-KE address
and to make it consistent with NNC_ChangeAddress(), which accepts only
one address.

4 years agontp: avoid recursive update of address
Miroslav Lichvar [Tue, 9 Feb 2021 15:06:36 +0000 (16:06 +0100)] 
ntp: avoid recursive update of address

Allow NSR_UpdateSourceNtpAddress() to be (indirectly) called from
NCR_CreateInstance() and NCR_ChangeRemoteAddress(). In these cases, save
the addresses and make the update later when the function calls return.

4 years agontp: require port match in address update
Miroslav Lichvar [Tue, 9 Feb 2021 12:07:37 +0000 (13:07 +0100)] 
ntp: require port match in address update

In NSR_UpdateSourceNtpAddress() and other updates of the address require
that the old port matches the current source's port.

4 years agotest: extend 129-reload test
Miroslav Lichvar [Thu, 4 Feb 2021 11:32:32 +0000 (12:32 +0100)] 
test: extend 129-reload test

4 years agosources: set reference after loading dump files
Miroslav Lichvar [Wed, 3 Feb 2021 16:41:39 +0000 (17:41 +0100)] 
sources: set reference after loading dump files

After loading the dump files with the -r option, immediately perform a
source selection with forced setting of the reference. This shortens the
interval when a restarted server doesn't respond with synchronized time.
It no longer needs to wait for the first measurement from the best
source (which had to pass all the filters).

4 years agosources: improve handling of dump files and their format
Miroslav Lichvar [Wed, 3 Feb 2021 16:13:39 +0000 (17:13 +0100)] 
sources: improve handling of dump files and their format

Check for write errors when saving dump files. Don't save files with no
samples. Add more sanity checks for loaded data.

Extend the file format to include an identifier, the reachability
register, leap status, name, and authentication flag. Avoid loading
unauthenticated data after switching authentication on. Change format
and order of some fields to simplify parsing. Drop fields that were kept
only for compatibility.

The dump files now contain all information needed to perform the source
selection and update the reference.

There is no support kept for the old file format. Loading of old dump
files will fail after upgrading to new version.

4 years agosources: update stratum with leap status
Miroslav Lichvar [Wed, 3 Feb 2021 12:29:14 +0000 (13:29 +0100)] 
sources: update stratum with leap status

Remove stratum from the NTP sample and update it together with the leap
status. This enables a faster update when samples are dropped by the NTP
filters.

4 years agosourcestats: move stratum to sources
Miroslav Lichvar [Wed, 3 Feb 2021 11:54:08 +0000 (12:54 +0100)] 
sourcestats: move stratum to sources

The stratum value is not needed in sourcestats. Keep it in the source
itself.

4 years agomain: fix typo in comment
Miroslav Lichvar [Wed, 3 Feb 2021 16:36:19 +0000 (17:36 +0100)] 
main: fix typo in comment

4 years agomain: cancel clock correction before dumping sources
Miroslav Lichvar [Wed, 3 Feb 2021 09:25:41 +0000 (10:25 +0100)] 
main: cancel clock correction before dumping sources

On exit, cancel the remaining clock correction before measurements are
saved to dumpdir to fix them for the state in which chronyd will start
again.

4 years agosys_linux: fix build with older kernel headers
Baruch Siach [Thu, 28 Jan 2021 13:11:31 +0000 (15:11 +0200)] 
sys_linux: fix build with older kernel headers

The renameat2 system call was introduced in kernel version 3.15. Fix
build against older headers.

4 years agotest: improve NTS tests
Miroslav Lichvar [Thu, 14 Jan 2021 15:54:04 +0000 (16:54 +0100)] 
test: improve NTS tests

4 years agonts: support servers specified by IP address
Miroslav Lichvar [Thu, 14 Jan 2021 15:31:07 +0000 (16:31 +0100)] 
nts: support servers specified by IP address

Certificates can include IP addresses as alternative names to enable
clients to verify such certificates without knowing the hostname.

Accept an IP address as a name in the NTS-NTP client and modify the
session code to not set the SNI in this case.

4 years agontp: allow replacement of sources specified by IP address
Miroslav Lichvar [Thu, 14 Jan 2021 13:12:54 +0000 (14:12 +0100)] 
ntp: allow replacement of sources specified by IP address

For sources specified by an IP address, keep the original address as the
source's name and pass it to the NCR instance. Allow the sources to go
through the replacement process if their address has changed.

This will be useful with NTS-KE negotiation.

The IP-based source names are now provided via cmdmon. This means
chronyc -n and -N can show two different addresses for a source.

4 years agontp: fix NULL pointer
Miroslav Lichvar [Thu, 14 Jan 2021 16:31:40 +0000 (17:31 +0100)] 
ntp: fix NULL pointer

4 years agotest: support ss as netstat replacement
Miroslav Lichvar [Wed, 13 Jan 2021 16:01:01 +0000 (17:01 +0100)] 
test: support ss as netstat replacement

netstat is considered obsolete on Linux. It is replaced by ss from
iproute. Support both tools for the test port selection.

4 years agotest: fix port selection to disable grep output
Miroslav Lichvar [Wed, 13 Jan 2021 15:59:17 +0000 (16:59 +0100)] 
test: fix port selection to disable grep output

4 years agotest: make 120-selectoptions more reliable
Miroslav Lichvar [Wed, 13 Jan 2021 15:25:08 +0000 (16:25 +0100)] 
test: make 120-selectoptions more reliable

Remove packet interval checks with long delays as the tests are much
more likely to end when the client is waiting for a response. Increase
the base delay to make selection with two sources more reliable.

Reported-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agosocket: add debug message for unexpected control message
Miroslav Lichvar [Wed, 13 Jan 2021 12:57:37 +0000 (13:57 +0100)] 
socket: add debug message for unexpected control message

4 years agosocket: check length of received control messages
Miroslav Lichvar [Wed, 13 Jan 2021 12:36:13 +0000 (13:36 +0100)] 
socket: check length of received control messages

Make sure each processed control messages has the expected length.
Beside improved safety, this should prevent potential issues with broken
timestamps on systems that support both 64-bit and 32-bit time_t.

4 years agosched: stop dispatching timeouts on exit
Miroslav Lichvar [Wed, 13 Jan 2021 11:51:57 +0000 (12:51 +0100)] 
sched: stop dispatching timeouts on exit

Check in the dispatch loop whether the need_to_exit flag was set.

4 years agosched: improve infinite loop detection
Miroslav Lichvar [Wed, 13 Jan 2021 11:32:38 +0000 (12:32 +0100)] 
sched: improve infinite loop detection

The "infinite loop in scheduling" fatal error was observed on a system
running out of memory. Presumably, the execution of the process slowed
down due to memory thrashing so much that the dispatching loop wasn't
able to break with a single server polled at a 16-second interval.

To allow recovery in such a case, require for the error more than
20 handled timeouts and a rate higher than 100 per second.

Reported-by: Jamie Gruener <jamie.gruener@biospatial.io>
4 years agortc: log error message when driver initialisation fails
Michael Witten [Tue, 15 Dec 2020 09:44:19 +0000 (10:44 +0100)] 
rtc: log error message when driver initialisation fails