Miroslav Lichvar [Thu, 10 Apr 2014 13:45:11 +0000 (15:45 +0200)]
sources: rework special mode ending with unreachable sources
Instead of giving up when a source has 7 reach updates, continue as long
as at least one source has fewer than 7 updates and can still have 3
samples to be selectable in that number of updates.
When no sources are responding, it will give up sooner.
Miroslav Lichvar [Thu, 10 Apr 2014 09:42:47 +0000 (11:42 +0200)]
sched: fix main loop to allow timeout handlers modify fd set or quit
With special reference update modes, the timeout handlers may add or
remove file descriptors from the read fd set, so it needs to be copied
for select() call after they are dispatched. Also, they can now request
quit, so the exit flag needs to be checked before select() to avoid
hanging.
main: support configuration commands on command line
If there are extra arguments on the chronyd command line, they will be
parsed as lines in a configuration file and the normal configuration file
will be ignored.
ntp: set maximum number of iburst samples to size of reach register
Explicitly set the number of iburst samples to the size of the register
to make sure there are at least 7 reachability updates and the
initstepslew mode can be ended.
The initstepslew code has its own minimal NTP implementation. Drop the
code, add a new initstepslew mode to the reference updating code and
use regular NTP sources with iburst flag for initstepslew addresses
instead. When an update is made or a source is found unreachable, log a
message, remove the initstepslew sources and switch to normal mode.
This reduces code duplication and makes initstepslew use features
implemented only in the main code like source combining or SO_TIMESTAMP
support.
Miroslav Lichvar [Tue, 25 Mar 2014 16:33:55 +0000 (17:33 +0100)]
test: update for latest clknetsim
Latest clknetsim now allows source and destination port numbers to
differ. This fixes the tests to work with the recent changes that added
client NTP sockets.
Miroslav Lichvar [Tue, 25 Mar 2014 13:26:50 +0000 (14:26 +0100)]
ntp: use separate connected sockets for each server
If acquisitionport is set to 0 (default), create and connect a new
socket for each server instead of using one socket per address family
for all servers.
Miroslav Lichvar [Tue, 25 Mar 2014 11:13:36 +0000 (12:13 +0100)]
ntp: use separate client sockets
Use separate sockets for NTP server or peer and client packets. The port
number is configured by the acquisitionport directive. With the default
value of 0 the port is assigned randomly by the kernel. It can be equal
to the value configured by the port directive to use the server sockets
for all packets as before.
Miroslav Lichvar [Fri, 24 Jan 2014 15:06:38 +0000 (16:06 +0100)]
Send cmdmon error replies only to allowed hosts
The status codes STT_BADPKTVERSION, STT_BADPKTLENGTH, STT_NOHOSTACCESS
were sent even to hosts that were not allowed by cmdallow. Deprecate
STT_NOHOSTACCESS and ignore packets from hosts not allowed by cmdallow
completely.
Miroslav Lichvar [Fri, 24 Jan 2014 12:55:15 +0000 (13:55 +0100)]
Add padding to cmdmon requests to prevent amplification attack
To prevent an attacker using chronyd in an amplification attack, change
the protocol to include padding in request packets so that the largest
possible reply is not larger than the request. Request packets that
don't include this padding are ignored as invalid.
This is an incompatible change in the protocol. Clients from chrony
1.27, 1.28 and 1.29 will receive NULL reply with STT_BADPKTVERSION and
print "Protocol version mismatch". Clients from 1.26 and older will not
receive a reply as it would be larger than the request if it was padded
to be compatible with their protocol.
Miroslav Lichvar [Thu, 23 Jan 2014 09:55:12 +0000 (10:55 +0100)]
Set maximum number of samples in manual list reply to 16
In chronyd the maximum number of manual samples is 16, so there is no
need to keep room for 32 samples in the command reply. This limits the
maximum assumed size of the reply packet.
Miroslav Lichvar [Tue, 21 Jan 2014 17:45:56 +0000 (18:45 +0100)]
Don't read uninitialized memory in client packet length check
Before calling PKL_ReplyLength() check that the packet has full header.
This didn't change the outcome of the test if the packet was shorter as
the invalid result from PKL_ReplyLength() was either larger than length
of the packet or smaller than header length, failing the length check in
both cases.
Miroslav Lichvar [Tue, 21 Jan 2014 16:18:48 +0000 (17:18 +0100)]
Fix selecting of sources with prefer option
List of selectable sources that is used in combining was trimmed to
sources with prefer option, but scoring algorithm considered all
selectable sources. When a source without prefer was selected and
no source was combined, it caused assertion failure.
This is a revert of commit 99d18abf updated for later changes. It seems
in that commit the calculation was changed to match the reversed dfreq
added in 1a7415a6, which itself was calculated incorrectly. Fix the
calculation of updated frequency and matching dfreq.