]> git.ipfire.org Git - thirdparty/chrony.git/log
thirdparty/chrony.git
7 years agomain: create directories before writing pidfile
Miroslav Lichvar [Thu, 7 Jun 2018 14:43:59 +0000 (16:43 +0200)] 
main: create directories before writing pidfile

This makes it possible to save pidfile in /var/run/chrony.

7 years agontp: change auto_offline to trigger on failed transmissions
Miroslav Lichvar [Thu, 24 May 2018 15:29:15 +0000 (17:29 +0200)] 
ntp: change auto_offline to trigger on failed transmissions

Instead of counting missing responses, switch to the offline state
immediately when sendmsg() fails.

This makes the option usable with servers and networks that may drop
packets, and the effect will be consistent with the onoffline command.

7 years agoexamples: update NetworkManager dispatcher script
Miroslav Lichvar [Thu, 24 May 2018 15:03:31 +0000 (17:03 +0200)] 
examples: update NetworkManager dispatcher script

Replace most of the code with the new onoffline command.

7 years agocmdmon: add onoffline command
Miroslav Lichvar [Thu, 24 May 2018 14:56:56 +0000 (16:56 +0200)] 
cmdmon: add onoffline command

The onoffline command tells chronyd to switch all sources to the online
or offline status according to the current network configuration. A
source is considered online if it is possible to send requests to it,
i.e. a route to the network is present.

7 years agontp: allow online/offline state to be selected by connectability
Miroslav Lichvar [Thu, 24 May 2018 13:17:53 +0000 (15:17 +0200)] 
ntp: allow online/offline state to be selected by connectability

Allow SRC_MAYBE_ONLINE to be specified for new NTP sources and
connectivity setting to select between SRC_ONLINE and SRC_OFFLINE
according to the result of the connect() system call, i.e. check whether
the client has a route to send its requests.

7 years agontp: refactor switching between online and offline state
Miroslav Lichvar [Thu, 24 May 2018 11:42:52 +0000 (13:42 +0200)] 
ntp: refactor switching between online and offline state

Use an enum to describe connectivity of a source and merge
the NCR and NSR TakeSourceOnline/Offline() functions into
SetConnectivity() functions.

7 years agontp: check PHC index before opening device
Miroslav Lichvar [Mon, 21 May 2018 14:49:26 +0000 (16:49 +0200)] 
ntp: check PHC index before opening device

Apparently, it is possible for an interface to report all necessary
flags for HW timestamping without having a PHC. Check the PHC index to
avoid an error message in the system log saying that /dev/ptp-1 cannot
be opened.

7 years agontp: enable non-blocking mode on server sockets
Miroslav Lichvar [Mon, 21 May 2018 14:27:43 +0000 (16:27 +0200)] 
ntp: enable non-blocking mode on server sockets

Avoid blocking in sendmsg() due to a full send buffer.

7 years agodoc: add new questions to FAQ
Miroslav Lichvar [Mon, 21 May 2018 12:49:53 +0000 (14:49 +0200)] 
doc: add new questions to FAQ

7 years agoutil: fall back to reading /dev/urandom when getrandom() blocks
Miroslav Lichvar [Thu, 17 May 2018 12:16:58 +0000 (14:16 +0200)] 
util: fall back to reading /dev/urandom when getrandom() blocks

With recent changes in the Linux kernel, the getrandom() system call may
block for a long time after boot on machines that don't have enough
entropy. It blocks the chronyd's initialization before it can detach
from the terminal and may cause a chronyd service to fail to start due
to a timeout.

At least for now, enable the GRND_NONBLOCK flag to make the system call
non-blocking and let the code fall back to reading /dev/urandom (which
never blocks) if the system call failed with EAGAIN or any other error.

This makes the start of chronyd non-deterministic with respect to files
that it needs to open and possibly also makes it slightly easier to
guess the transmit/receive timestamp in client requests until the
urandom source is fully initialized.

7 years agoexamples: make nm-dispatcher script usable for networkd-dispatcher
Christian Ehrhardt [Wed, 18 Apr 2018 13:44:21 +0000 (15:44 +0200)] 
examples: make nm-dispatcher script usable for networkd-dispatcher

Historically there were plenty of callback based implementations around
ifupdown via /etc/network/if-up and similar. NetworkManager added the
dispatcher [1] feature for such a kind of functionality.

But so far a systemd-networkd (only) systemd had no means to handle those
cases. This is solved by networkd-dispatcher which is currently available
at least in ArchLinux and Ubuntu.
It takes away the responsibility to listen on netlink events in each
application and provides a more classic script-drop-in interface to respond
to networkd events [3].

This commit makes the NM example compatible to be used by NetworkManager
dispatcher as well as by networkd-dispatcher. That way we avoid too much
code duplication and can from now on handle special cases in the
beginning so that the tail can stay commonly used.

After discussion on IRC the current check differs by checking the
argument count (only in NetworkManager), if ever needed we could extend
that to check for known custom environment vars (NetworkManager =>
CONNECTION_UUID; networkd-dispatcher => OperationalState).

[1]: https://developer.gnome.org/NetworkManager/stable/NetworkManager.html
[2]: https://github.com/craftyguy/networkd-dispatcher
[3]: https://github.com/systemd/systemd/blob/master/src/systemd/sd-network.h#L86

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agosys_linux: fix building with old libcap versions
Miroslav Lichvar [Thu, 5 Apr 2018 14:18:23 +0000 (16:18 +0200)] 
sys_linux: fix building with old libcap versions

The cap_get_bound() function and CAP_IS_SUPPORTED macro were added in
libcap-2.21. Check if the macro is defined before use.

The sys/capability.h header from libcap-2.16 and earlier disables the
linux/types.h header, which breaks the linux/ptp_clock.h header. Change
the order to include sys/capability.h as the last system header.

7 years agodoc: update NEWS 3.3
Miroslav Lichvar [Wed, 4 Apr 2018 07:17:08 +0000 (09:17 +0200)] 
doc: update NEWS

7 years agoclient: update copyright years
Miroslav Lichvar [Wed, 4 Apr 2018 07:14:16 +0000 (09:14 +0200)] 
client: update copyright years

7 years agontp: fix handling of socket errors with error queue
Miroslav Lichvar [Wed, 4 Apr 2018 07:07:10 +0000 (09:07 +0200)] 
ntp: fix handling of socket errors with error queue

In the next Linux version the recvmmsg() system call will be probably
fixed to not return socket errors (e.g. due to ICMP) when reading from
the error queue.

The NTP I/O code assumed this was the correct behavior. When the system
call is fixed, a socket error on a client socket will cause chronyd to
enter a busy loop consuming the CPU until the receive timeout is reached
(8 seconds by default).

Use getsockopt(SO_ERROR) to clear the socket error when reading from the
error queue failed.

7 years agoprivops: allow binding to acquisition port
Miroslav Lichvar [Tue, 3 Apr 2018 09:05:33 +0000 (11:05 +0200)] 
privops: allow binding to acquisition port

Fix the privileged helper process to allow binding of client sockets to
a non-zero acquisition port which is not equal to the server port.

7 years agodoc: improve FAQ
Miroslav Lichvar [Tue, 27 Mar 2018 15:57:17 +0000 (17:57 +0200)] 
doc: improve FAQ

7 years agodoc: improve description of fallbackdrift directive
Miroslav Lichvar [Tue, 27 Mar 2018 11:08:01 +0000 (13:08 +0200)] 
doc: improve description of fallbackdrift directive

7 years agodoc: improve description of key option in chrony.conf man page
Miroslav Lichvar [Mon, 26 Mar 2018 17:00:50 +0000 (19:00 +0200)] 
doc: improve description of key option in chrony.conf man page

7 years agodoc: update installation document
Miroslav Lichvar [Mon, 26 Mar 2018 11:21:54 +0000 (13:21 +0200)] 
doc: update installation document

7 years agoupdate copyright years
Miroslav Lichvar [Thu, 22 Mar 2018 17:05:00 +0000 (18:05 +0100)] 
update copyright years

7 years agontp: fix compiler warnings
Miroslav Lichvar [Tue, 20 Mar 2018 09:16:39 +0000 (10:16 +0100)] 
ntp: fix compiler warnings

Warnings about using uninitialized variables were seen with gcc-7.3.1
and -O3 in CFLAGS.

7 years agoconfigure: include SECHASH in chronyc features
Miroslav Lichvar [Tue, 20 Mar 2018 08:41:53 +0000 (09:41 +0100)] 
configure: include SECHASH in chronyc features

chronyc is linked with the crypto library and the keygen command checks
if the specified hash function is known.

7 years agotest: extend 126-burst
Miroslav Lichvar [Mon, 19 Mar 2018 16:21:32 +0000 (17:21 +0100)] 
test: extend 126-burst

7 years agotest: fix hash unit test for NSS
Miroslav Lichvar [Mon, 19 Mar 2018 12:07:58 +0000 (13:07 +0100)] 
test: fix hash unit test for NSS

Some hash functions in the freebl3 library ignore the length of the
output buffer and always return the length of the digest.

7 years agohash: initialize return value before calling NSS hash functions
Miroslav Lichvar [Mon, 19 Mar 2018 12:02:47 +0000 (13:02 +0100)] 
hash: initialize return value before calling NSS hash functions

Some hash functions in the freebl3 library don't support truncated
digests and either return immediately with no update of the output
length, or ignore the length of the output buffer and always write whole
digest.

Initialize the return value to zero to get correct result with the
former.

This is triggered only in the hash unit test. chronyd always provides a
sufficient buffer for the digest.

7 years agodoc: update NEWS 3.3-pre1
Miroslav Lichvar [Thu, 15 Mar 2018 07:36:38 +0000 (08:36 +0100)] 
doc: update NEWS

7 years agohash: add support for older nettle versions
Miroslav Lichvar [Thu, 15 Mar 2018 07:18:29 +0000 (08:18 +0100)] 
hash: add support for older nettle versions

Use nettle_hashes[] instead of nettle_get_hashes(), which is available
only in nettle >= 3.4. nettle_hashes[] is a symbol available in older
versions and may be renamed in future. In nettle >= 3.4 it is a macro
using nettle_get_hashes() for compatibility.

7 years agodoc: update README
Miroslav Lichvar [Wed, 14 Mar 2018 15:14:38 +0000 (16:14 +0100)] 
doc: update README

7 years agosys_linux: report if CAP_SYS_TIME is not present
Christian Ehrhardt [Wed, 14 Mar 2018 14:05:29 +0000 (15:05 +0100)] 
sys_linux: report if CAP_SYS_TIME is not present

Instead of having adjtimex just fail with a permission issue
improve the error messaging by warning for the lack of
CAP_SYS_TIME on SYS_Linux_Initialise.

Message will look like (instead of only the latter message):
 CAP_SYS_TIME not present
 adjtimex(0x8001) failed : Operation not permitted

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
7 years agodoc: improve description of -x in chronyd man page
Miroslav Lichvar [Wed, 14 Mar 2018 12:27:03 +0000 (13:27 +0100)] 
doc: improve description of -x in chronyd man page

7 years agontp: fix adjustment of init_local_rx timestamp
Miroslav Lichvar [Wed, 14 Mar 2018 13:56:57 +0000 (14:56 +0100)] 
ntp: fix adjustment of init_local_rx timestamp

This fixes commit f0f18a02a7d97a3cfb4cd9977f5ec12c6b1f1028.

7 years agontp: add debug message to update of link speed
Miroslav Lichvar [Wed, 14 Mar 2018 12:25:18 +0000 (13:25 +0100)] 
ntp: add debug message to update of link speed

7 years agotest: update compilation test to disable nettle
Miroslav Lichvar [Tue, 13 Mar 2018 09:19:15 +0000 (10:19 +0100)] 
test: update compilation test to disable nettle

7 years agodoc: update supported hash functions in chrony.conf man apge
Miroslav Lichvar [Tue, 13 Mar 2018 09:01:59 +0000 (10:01 +0100)] 
doc: update supported hash functions in chrony.conf man apge

7 years agohash: add support for nettle
Miroslav Lichvar [Tue, 13 Mar 2018 09:01:44 +0000 (10:01 +0100)] 
hash: add support for nettle

7 years agohash: add support for SHA-3 with libtomcrypt
Miroslav Lichvar [Mon, 12 Mar 2018 18:06:21 +0000 (19:06 +0100)] 
hash: add support for SHA-3 with libtomcrypt

7 years agotest: add hash unit test
Miroslav Lichvar [Mon, 12 Mar 2018 11:42:07 +0000 (12:42 +0100)] 
test: add hash unit test

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This reverts commit 2343e7a89c0bacdfccf892f881c4b89b2990c512.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

This improves protection against replay attacks in the symmetric mode.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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