Miroslav Lichvar
f93f2a15af
ntp: check also reference timestamp in test3
...
Zero reference timestamp doesn't pass test7, but only before we reach
the next NTP era.
2015-03-27 10:37:54 +01:00
Miroslav Lichvar
fad97e12da
ntp: fix maxdelayratio test
...
This was broken in commit 8fbfe55e
.
2015-01-29 12:49:02 +01:00
Miroslav Lichvar
547272e66c
ntp: use different value for invalid socket in ntp_core
...
This should make it easier to see invalid sockets leaking from ntp_core
to ntp_io.
2015-01-07 16:14:29 +01:00
Miroslav Lichvar
35e11ffe60
ntp: fix length check of NTPv4 extension fields
...
Don't allow extension fields shorter than 16 bytes.
2015-01-07 14:12:29 +01:00
Miroslav Lichvar
52e12e42e5
ntp: open server socket only when access is allowed
...
When changing access configuration, check if any address is allowed and
open/close the server socket as needed.
2015-01-06 16:35:12 +01:00
Miroslav Lichvar
5214d42c07
ntp: count references to NTP server sockets
...
Server sockets are now explicitly opened and closed for normal NTP
server, NTP broadcast and NTP peering. This will allow closing the
NTP port when not needed.
2015-01-06 16:33:49 +01:00
Miroslav Lichvar
6d1dda0fad
ntp: rename NIO_Get*Socket functions
2015-01-05 14:17:21 +01:00
Miroslav Lichvar
6688f40325
sources: allow setting minsamples and maxsamples for each source
...
The minsamples and maxsamples directives now set the default value,
which can be overriden for individual sources in the server/peer/pool
and refclock directives.
2014-12-03 16:27:51 +01:00
Miroslav Lichvar
42dd5caa1b
ntp: don't replace source instance when changing address
...
Add new functions to change source's reference ID/address and reset the
instance. Use that instead of destroying and creating a new instance
when the NTP address is changed.
2014-12-01 18:40:47 +01:00
Miroslav Lichvar
aaf744dfab
ntp: return status from NCR_ProcessKnown()
2014-11-24 16:14:04 +01:00
Miroslav Lichvar
dccd61966a
ntp: fix accepting requests from configured sources
...
When using server socket to send client requests (acquisitionport 123)
and currently not waiting for a reply, the socket check will fail for
client requests from the source.
The check needs to be moved to correctly handle the requests as from an
unknown source.
2014-11-21 11:43:47 +01:00
Miroslav Lichvar
29c1df4610
ntp: allow changing address of core instance
2014-11-03 11:15:20 +01:00
Miroslav Lichvar
ccaf0874e1
ntp: take auto_offline sources offline before sending new request
2014-10-23 15:06:00 +02:00
Miroslav Lichvar
1aecc51c70
ntp: add version option to server/peer directive
2014-10-20 16:14:17 +02:00
Miroslav Lichvar
7958b1764e
ntp: remove debug messages in slew handler
2014-10-20 12:22:17 +02:00
Miroslav Lichvar
63af4889f6
sources: drop selectable flag
...
This is no longer needed with new NTP packet processing as the sources
are always selectable after first sample is accumulated.
2014-10-20 11:02:07 +02:00
Miroslav Lichvar
819b8eb73d
ntp: fix Clang warning
2014-10-15 12:40:12 +02:00
Miroslav Lichvar
a78bf0c34e
ntp: merge broadcast code with ntp_core
2014-10-15 12:27:46 +02:00
Miroslav Lichvar
e0059bcc6b
ntp: define NTP_MAX_STRATUM for other modules
2014-10-14 17:25:55 +02:00
Miroslav Lichvar
8fbfe55e92
ntp: update packet processing to NTPv4 (RFC 5905)
2014-10-14 16:52:22 +02:00
Miroslav Lichvar
740e8130dd
ntp: clamp value set by minstratum option
2014-10-13 15:10:15 +02:00
Miroslav Lichvar
361726b3ae
keys: store IDs in uint32_t
2014-09-26 14:14:54 +02:00
Miroslav Lichvar
e1accce498
ntp: print warning 10 years before supported time ends
2014-09-09 17:08:30 +02:00
Miroslav Lichvar
4e66b5ce8a
ntp: don't stop online burst when sending fails
...
Don't stop online burst for unreachable sources until sending succeeds.
This is mainly useful with iburst when chronyd is started before the
network is configured.
2014-08-20 16:54:26 +02:00
Miroslav Lichvar
d446950c6a
ntp: don't adjust polling interval when sending fails
2014-08-20 16:54:26 +02:00
Miroslav Lichvar
e3c77f9b4b
ntp: return with status from functions sending packets
2014-08-20 16:54:26 +02:00
Miroslav Lichvar
badf97d4ba
ntp: restart timer when poll interval changes on reset
2014-08-20 16:54:26 +02:00
Miroslav Lichvar
ba283e6b6e
ntp: add function to restart transmit timer
2014-08-20 16:54:26 +02:00
Miroslav Lichvar
cd5105b1db
ntp: use NTP instead of echo for presend
...
Switch to NTP for presend as the echo service (RFC 862) is rarely
enabled. When presend is active, send an NTP client packet to the
server/peer and ignore the reply.
This also fixes presend with separate client sockets. The destination
port can't be changed on connected sockets, so the echo packet was sent
to the NTP port instead of the echo port.
2014-08-15 16:49:45 +02:00
Miroslav Lichvar
474b2af1a6
util: add support for other NTP eras
...
NTP timestamps use only 32 bits to count seconds and the current NTP era
ends in 2036. Add support for converting NTP timestamps from other NTP
eras on systems with 64-bit time_t.
The earliest assumed NTP time is set by the configure script (by default
to 50 years before the date of the build) and earlier NTP timestamps
underflow to the following NTP era.
2014-08-15 11:18:40 +02:00
Miroslav Lichvar
cb88cea3c4
ntp: move packet size asserts to ntp_core
2014-08-15 10:58:52 +02:00
Miroslav Lichvar
a9b9e7befe
ntp: create new socket for each client request
...
Create a new connected client socket before each request and close it
when a valid reply is received.
This is useful when the network configuration is changed and the client
socket should be reconnected, but the old bound address remains valid
and sendmsg() doesn't return with an error.
2014-08-15 10:58:43 +02:00
Miroslav Lichvar
cb74f3e7ad
Update copyright years
2014-06-05 18:06:56 +02:00
Miroslav Lichvar
a646cf7923
logging: convert rate limited messages to debug messages
2014-06-04 12:26:27 +02:00
Miroslav Lichvar
3f3ebd3b3b
ntp: update comment in get_transmit_delay()
2014-06-03 18:10:27 +02:00
Miroslav Lichvar
3ebebac695
ntp: reset NCR instance thoroughly when switching to offline
2014-06-02 16:46:53 +02:00
Miroslav Lichvar
779e40ed66
ntp: delay initial transmission until first resolving ends
...
This will be needed to prevent loading of dump files after sources have
already accumulated samples and possibly reference was already updated
when async resolving of sources is implemented.
2014-04-29 12:42:45 +02:00
Miroslav Lichvar
08faca03b7
ntp: close client socket when offline
2014-04-10 18:02:29 +02:00
Miroslav Lichvar
3217421797
ntp: close only client socket when destroying NCR instance
2014-04-10 17:50:24 +02:00
Miroslav Lichvar
8671002bd7
sources: add flag that source is active
...
When source is set as active, it's receiving reachability updates (e.g.
offline NTP sources are not active).
Also add function to count active sources.
2014-04-10 17:48:58 +02:00
Miroslav Lichvar
bc6b40568d
ntp: reduce burst timeout to 2.0
...
With the new special mode ending it can be now equal to the burst
polling interval.
2014-04-10 17:16:30 +02:00
Miroslav Lichvar
60d8586b6d
ntp: reduce burst timeout to 2.5 seconds
...
This reduces the maximum time initstepslew can take.
2014-04-09 09:59:58 +02:00
Miroslav Lichvar
70928dba52
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.
2014-04-09 09:59:57 +02:00
Miroslav Lichvar
0094128ca6
sources: split source selection from sample accumulation
...
This will allow postponing source selection and reference update, which
could be useful in burst modes.
2014-04-08 17:00:47 +02:00
Miroslav Lichvar
73e4986866
ntp: fix comment on NCR_ProcessUnknown
2014-03-26 11:24:25 +01:00
Miroslav Lichvar
91e74c704b
ntp: accept packets from unknown sources only from server sockets
2014-03-26 11:18:18 +01:00
Miroslav Lichvar
cf12d72f21
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.
2014-03-25 15:27:18 +01:00
Miroslav Lichvar
f2c4ab09a8
ntp: check if packet was received by right socket
2014-03-25 15:24:38 +01:00
Miroslav Lichvar
9a657cd4a3
ntp: store socket in NTP instance
...
This is preparation for separate client sockets.
2014-03-25 15:22:59 +01:00
Miroslav Lichvar
308de81221
ntp: split local_ip_addr from NTP_Remote_Address struct
2014-03-25 11:34:35 +01:00
Miroslav Lichvar
7aa4bbf621
ntp: set minpoll from received KoD RATE at most to 10
...
Limit changing minpoll to a reasonable maximum in case the server is
broken or temporarily misconfigured.
2014-03-21 15:32:14 +01:00
Miroslav Lichvar
5afddad0d2
ntp: print warning when source is added with unknown key
2014-03-21 14:36:51 +01:00
Miroslav Lichvar
0380cf0c76
ntp: reset negative minpoll or maxpoll to default values
2014-03-21 13:25:14 +01:00
Miroslav Lichvar
8d02e5f680
ntp: make use of NCR_ProcessUnknown in NCR_ProcessKnown
...
After recent changes the code in NCR_ProcessKnown is now identical and
can be replaced with NCR_ProcessUnknown call.
2014-03-21 13:20:34 +01:00
Miroslav Lichvar
f9e2213afd
ntp: don't store tx time stamp when replying to known source
2014-03-21 13:20:31 +01:00
Miroslav Lichvar
8b362ba3e7
ntp: don't reply to known source if missing key or invalid auth
...
This is now similar to replying to unknown sources.
2014-03-21 13:20:29 +01:00
Miroslav Lichvar
a26058d425
ntp: don't send requests with unknown key
...
There is no point in sending a request if the configured key is missing.
A reply would be ignored anyway.
2014-03-21 13:20:27 +01:00
Miroslav Lichvar
c14b81f3a9
ntp: remove unnecessary KEY_KeyKnown calls
2014-03-21 13:20:25 +01:00
Miroslav Lichvar
54211f0f6e
Update comment on setting poll in reply packet
2014-01-17 18:10:32 +01:00
Miroslav Lichvar
4b5f465026
Don't allow maxpoll to be set shorter than minpoll
2014-01-17 17:37:07 +01:00
Miroslav Lichvar
8df1bedb1b
Remove forgotten macros
2013-11-27 16:11:19 +01:00
Miroslav Lichvar
1c3aff37de
Convert TRACEON LOG messages to DEBUG_LOG
2013-11-27 14:35:41 +01:00
Miroslav Lichvar
0731cd6950
Fix log messages
2013-11-26 18:41:51 +01:00
Miroslav Lichvar
922e2fe23b
Fix Clang static analyzer warnings about never read values
2013-10-07 17:50:27 +02:00
Miroslav Lichvar
d5b737cce8
Update copyright years
2013-06-19 12:50:26 +02:00
Miroslav Lichvar
9666831818
Use UTI_DiffTimevalsToDouble to calculate theta
2013-06-12 15:30:28 +02:00
Miroslav Lichvar
ff8e04f9ba
Fix fabs use on delay
2013-06-12 15:30:28 +02:00
Miroslav Lichvar
8aa9eb19c8
Remove unnecessary adjtimex calls
2013-06-06 19:38:36 +02:00
Miroslav Lichvar
2ceb3c89ca
Move NTP_int32 conversion functions to util.c
2013-06-05 12:49:47 +02:00
Miroslav Lichvar
32bf32e7d5
Don't use uninitialized value in receive_packet()
2013-06-05 09:56:37 +02:00
Miroslav Lichvar
cce7a5f15e
Improve peer polling in symmetric mode
...
If the remote stratum is higher than ours, try to lock on the peer's
polling to minimize our response time by slightly extending our delay or
waiting for the peer to catch up with us as the random part in the
actual interval is reduced. If the remote stratum is equal to ours, try
to interleave evenly with the peer.
2013-06-05 09:32:20 +02:00
Miroslav Lichvar
288043c13b
Save remote poll only with valid packets
2013-06-04 15:43:59 +02:00
Miroslav Lichvar
78ae4ebfaa
Fix peer polling with shorter remote poll
...
If the remote peer uses a polling interval shorter than the local
minimum, the local peer will be unable to send any packets as the
timeout will be updated on every received valid packet and will never
expire.
Modify the delay calculation to aim at poll interval away since the last
transmit.
Also, share the delay calculation code with transmit_timeout().
2013-06-04 12:52:49 +02:00
Miroslav Lichvar
cf700a0084
Requeue transmit timeout only with valid packets
2013-06-04 12:45:47 +02:00
Miroslav Lichvar
60a25f6e71
Ignore packets from offline sources
...
Rework the logic in transmit_timeout() to change the online status on
the following timeout to allow ignoring packets from offline sources.
2013-06-03 18:57:55 +02:00
Miroslav Lichvar
030e3b2dab
Make receive_packet() more readable
2013-06-03 16:03:07 +02:00
Miroslav Lichvar
5079f6bbff
In burst count only accumulated samples as good
2013-06-03 16:03:07 +02:00
Miroslav Lichvar
afceb9d24e
Slew only non-zero local timestamps in ntp core
2013-06-03 16:03:07 +02:00
Miroslav Lichvar
a2656a20bc
Fix poll timeout with symmetric peer and poll 0
2013-06-03 16:03:05 +02:00
Miroslav Lichvar
359d444343
Remove unncessary return statements
2013-05-21 15:08:34 +02:00
Miroslav Lichvar
ebae435398
Log online/offline status change for burst sources too.
2013-05-15 11:03:18 +02:00
Miroslav Lichvar
73d4eaafbb
Reply to NTPv1 and NTPv2 packets with same version
2013-05-02 11:10:48 +02:00
Miroslav Lichvar
cf00179964
Reply to NTPv1 packets
2013-05-02 11:10:25 +02:00
Miroslav Lichvar
0bb772c575
Fix delta calculation with extreme frequency offsets
...
This should prevent chronyd from getting stuck and refusing new samples
due to failing test4 when the current measured frequency offset is close
to 1.0. That can happen when the system clock is stepped forward behind
chronyd's back.
2013-03-08 14:39:13 +01:00
Miroslav Lichvar
df6c2a432f
Fuzz transmit timestamp
...
Add random bits below clock precision to the timestamp to make
it less predictable.
2012-05-23 12:06:16 +02:00
Miroslav Lichvar
0c738d84af
Update copyright years
2012-02-28 13:11:56 +01:00
Miroslav Lichvar
777303f130
Add support for different authentication hashes
...
Allow different hash functions to be used in the NTP and cmdmon
protocols. This breaks the cmdmon protocol compatibility. Extended key
file format is used to specify the hash functions for chronyd and new
authhash command is added to chronyc. MD5 is the default and the only
function included in the chrony source code, other functions will be
available from libraries.
2011-11-02 13:53:00 +01:00
Miroslav Lichvar
cc3f5962b8
Merge NCR_Process functions
2011-09-01 16:25:13 +02:00
Miroslav Lichvar
5c36342958
Use initial delay also for burst samples
2011-08-26 18:34:00 +02:00
Miroslav Lichvar
27b0b5824a
Disable maxdelayratio test by default
...
Change default maxdelayratio from 16384.0 to 0.0. A value larger
than 1.0 is required to enable the test.
2011-08-12 15:38:05 +02:00
Miroslav Lichvar
1d72d22bc5
Match skew in ntp_core to sourcestats skew
2011-08-12 15:38:05 +02:00
Miroslav Lichvar
1b8547059a
Set leap status by enum
2011-06-13 17:02:42 +02:00
Miroslav Lichvar
91279a0f28
Store reference IDs in uint32_t
2011-06-13 15:34:16 +02:00
Miroslav Lichvar
8cc7ebffa9
Accept packets with compatible NTP versions
...
All incoming NTP packets are now required to have version 2, 3 or 4.
2011-05-25 16:59:40 +02:00
Miroslav Lichvar
da2c8d9076
Use config.h
2011-05-24 18:07:06 +02:00
Miroslav Lichvar
896dad9224
Fix warnings produced by latest gcc
2011-02-15 18:55:34 +01:00
Miroslav Lichvar
e8c5d15690
Remove CVS headers
2011-01-28 12:56:09 +01:00
Miroslav Lichvar
e63cba05b2
Update copyright
2011-01-27 13:05:26 +01:00
Miroslav Lichvar
930a41b845
Don't send packet in last auto_offline transmit timeout
2010-12-17 18:09:10 +01:00
Miroslav Lichvar
323f0d187e
Fix switching offline auto_offline source to online
2010-12-17 18:09:10 +01:00