mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-04 09:35:06 -05:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43320a1d6b | ||
|
|
8caaa0b056 | ||
|
|
e48a34392c | ||
|
|
8bc8bf9cc4 | ||
|
|
3dc9f1ff92 | ||
|
|
7bc7d00297 | ||
|
|
b5cf861cd7 | ||
|
|
25cc84d5e2 | ||
|
|
f74e4cf1fe | ||
|
|
5f66722b66 | ||
|
|
b31461af7a | ||
|
|
ae177f2742 | ||
|
|
1a736078df | ||
|
|
9b46ea7255 | ||
|
|
ff4e932f17 | ||
|
|
68c35a0072 | ||
|
|
b6c634298d | ||
|
|
010df12459 | ||
|
|
22ef2fbb0e |
@@ -33,6 +33,8 @@ CFLAGS = @CFLAGS@
|
|||||||
CPPFLAGS = @CPPFLAGS@
|
CPPFLAGS = @CPPFLAGS@
|
||||||
LDFLAGS = @LDFLAGS@
|
LDFLAGS = @LDFLAGS@
|
||||||
|
|
||||||
|
GETDATE_CFLAGS = @GETDATE_CFLAGS@
|
||||||
|
|
||||||
EXTRA_OBJS = @EXTRA_OBJS@
|
EXTRA_OBJS = @EXTRA_OBJS@
|
||||||
|
|
||||||
OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o quantiles.o \
|
OBJS = array.o cmdparse.o conf.o local.o logging.o main.o memory.o quantiles.o \
|
||||||
@@ -61,6 +63,8 @@ chronyd : $(OBJS)
|
|||||||
chronyc : $(CLI_OBJS)
|
chronyc : $(CLI_OBJS)
|
||||||
$(CC) $(CFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_CLI_LIBS)
|
$(CC) $(CFLAGS) -o chronyc $(CLI_OBJS) $(LDFLAGS) $(LIBS) $(EXTRA_CLI_LIBS)
|
||||||
|
|
||||||
|
getdate.o: CFLAGS += $(GETDATE_CFLAGS)
|
||||||
|
|
||||||
distclean : clean
|
distclean : clean
|
||||||
$(MAKE) -C doc distclean
|
$(MAKE) -C doc distclean
|
||||||
$(MAKE) -C test/unit distclean
|
$(MAKE) -C test/unit distclean
|
||||||
|
|||||||
1
NEWS
1
NEWS
@@ -14,6 +14,7 @@ Enhancements
|
|||||||
* Improve source replacement
|
* Improve source replacement
|
||||||
* Log important changes made by command requests (chronyc)
|
* Log important changes made by command requests (chronyc)
|
||||||
* Refresh address of NTP sources periodically
|
* Refresh address of NTP sources periodically
|
||||||
|
* Request nanosecond kernel RX timestamping on FreeBSD
|
||||||
* Set DSCP for IPv6 packets
|
* Set DSCP for IPv6 packets
|
||||||
* Shorten NTS-KE retry interval when network is down
|
* Shorten NTS-KE retry interval when network is down
|
||||||
* Update seccomp filter for musl
|
* Update seccomp filter for musl
|
||||||
|
|||||||
28
README
28
README
@@ -47,32 +47,7 @@ Frequently Asked Questions (FAQ).
|
|||||||
The documentation is also available on the chrony web pages, accessible
|
The documentation is also available on the chrony web pages, accessible
|
||||||
through the URL
|
through the URL
|
||||||
|
|
||||||
https://chrony.tuxfamily.org/
|
https://chrony-project.org/
|
||||||
|
|
||||||
Where are new versions announced?
|
|
||||||
=================================
|
|
||||||
|
|
||||||
There is a low volume mailing list where new versions and other
|
|
||||||
important news relating to chrony are announced. You can join this list
|
|
||||||
by sending mail with the subject "subscribe" to
|
|
||||||
|
|
||||||
chrony-announce-request@chrony.tuxfamily.org
|
|
||||||
|
|
||||||
How can I get support for chrony?
|
|
||||||
=================================
|
|
||||||
|
|
||||||
There are two other mailing lists relating to chrony. chrony-users is a
|
|
||||||
discussion list for users, e.g. for questions about chrony configuration
|
|
||||||
and bug reports. chrony-dev is a more technical list for developers,
|
|
||||||
e.g. for submitting patches and discussing how new features should be
|
|
||||||
implemented. To subscribe to either of these lists, send a message with
|
|
||||||
the subject "subscribe" to
|
|
||||||
|
|
||||||
chrony-users-request@chrony.tuxfamily.org
|
|
||||||
or
|
|
||||||
chrony-dev-request@chrony.tuxfamily.org
|
|
||||||
|
|
||||||
as applicable.
|
|
||||||
|
|
||||||
License
|
License
|
||||||
=======
|
=======
|
||||||
@@ -144,6 +119,7 @@ Gautier PHILIPPON <gautier.philippon@ensimag.grenoble-inp.fr>
|
|||||||
Andreas Piesk <apiesk@virbus.de>
|
Andreas Piesk <apiesk@virbus.de>
|
||||||
Mike Ryan <msr@hsilop.net>
|
Mike Ryan <msr@hsilop.net>
|
||||||
Baruch Siach <baruch@tkos.co.il>
|
Baruch Siach <baruch@tkos.co.il>
|
||||||
|
Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
|
||||||
Foster Snowhill <forst@forstwoof.ru>
|
Foster Snowhill <forst@forstwoof.ru>
|
||||||
Andreas Steinmetz <ast@domdv.de>
|
Andreas Steinmetz <ast@domdv.de>
|
||||||
NAKAMURA Takumi <takumi@ps.sakura.ne.jp>
|
NAKAMURA Takumi <takumi@ps.sakura.ne.jp>
|
||||||
|
|||||||
4
client.c
4
client.c
@@ -4,7 +4,7 @@
|
|||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Lonnie Abelbeck 2016, 2018
|
* Copyright (C) Lonnie Abelbeck 2016, 2018
|
||||||
* Copyright (C) Miroslav Lichvar 2009-2021
|
* Copyright (C) Miroslav Lichvar 2009-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -3380,7 +3380,7 @@ static void
|
|||||||
display_gpl(void)
|
display_gpl(void)
|
||||||
{
|
{
|
||||||
printf("chrony version %s\n"
|
printf("chrony version %s\n"
|
||||||
"Copyright (C) 1997-2003, 2007, 2009-2022 Richard P. Curnow and others\n"
|
"Copyright (C) 1997-2003, 2007, 2009-2023 Richard P. Curnow and others\n"
|
||||||
"chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and\n"
|
"chrony comes with ABSOLUTELY NO WARRANTY. This is free software, and\n"
|
||||||
"you are welcome to redistribute it under certain conditions. See the\n"
|
"you are welcome to redistribute it under certain conditions. See the\n"
|
||||||
"GNU General Public License version 2 for details.\n\n",
|
"GNU General Public License version 2 for details.\n\n",
|
||||||
|
|||||||
2
cmdmon.c
2
cmdmon.c
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Miroslav Lichvar 2009-2016, 2018-2021
|
* Copyright (C) Miroslav Lichvar 2009-2016, 2018-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
|||||||
10
configure
vendored
10
configure
vendored
@@ -5,7 +5,7 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) Richard P. Curnow 1997-2003
|
# Copyright (C) Richard P. Curnow 1997-2003
|
||||||
# Copyright (C) Bryan Christianson 2016
|
# Copyright (C) Bryan Christianson 2016
|
||||||
# Copyright (C) Miroslav Lichvar 2009, 2012-2021
|
# Copyright (C) Miroslav Lichvar 2009, 2012-2022
|
||||||
# Copyright (C) Stefan R. Filipek 2019
|
# Copyright (C) Stefan R. Filipek 2019
|
||||||
#
|
#
|
||||||
# =======================================================================
|
# =======================================================================
|
||||||
@@ -570,6 +570,13 @@ if [ "x$MYCFLAGS" = "x" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
TESTCFLAGS="-fwrapv"
|
||||||
|
if test_code '-fwrapv' '' "$TESTCFLAGS" '' ''; then
|
||||||
|
GETDATE_CFLAGS="-fwrapv"
|
||||||
|
else
|
||||||
|
GETDATE_CFLAGS=""
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "x$MYCC" = "xgcc" ] || [ "x$MYCC" = "xclang" ]; then
|
if [ "x$MYCC" = "xgcc" ] || [ "x$MYCC" = "xclang" ]; then
|
||||||
MYCFLAGS="$MYCFLAGS -Wmissing-prototypes -Wall"
|
MYCFLAGS="$MYCFLAGS -Wmissing-prototypes -Wall"
|
||||||
fi
|
fi
|
||||||
@@ -1122,6 +1129,7 @@ do
|
|||||||
s%@CFLAGS@%${MYCFLAGS}%;\
|
s%@CFLAGS@%${MYCFLAGS}%;\
|
||||||
s%@CPPFLAGS@%${MYCPPFLAGS}%;\
|
s%@CPPFLAGS@%${MYCPPFLAGS}%;\
|
||||||
s%@LDFLAGS@%${MYLDFLAGS}%;\
|
s%@LDFLAGS@%${MYLDFLAGS}%;\
|
||||||
|
s%@GETDATE_CFLAGS@%${GETDATE_CFLAGS}%;\
|
||||||
s%@LIBS@%${LIBS}%;\
|
s%@LIBS@%${LIBS}%;\
|
||||||
s%@EXTRA_LIBS@%${EXTRA_LIBS}%;\
|
s%@EXTRA_LIBS@%${EXTRA_LIBS}%;\
|
||||||
s%@EXTRA_CLI_LIBS@%${EXTRA_CLI_LIBS}%;\
|
s%@EXTRA_CLI_LIBS@%${EXTRA_CLI_LIBS}%;\
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ Support files
|
|||||||
Dates and sizes may differ
|
Dates and sizes may differ
|
||||||
-rw-r--r-- 1 yourname staff 2084 4 Aug 22:54 README.txt
|
-rw-r--r-- 1 yourname staff 2084 4 Aug 22:54 README.txt
|
||||||
-rwxr-xr-x 1 yourname staff 676 4 Aug 21:18 chronylogrotate.sh
|
-rwxr-xr-x 1 yourname staff 676 4 Aug 21:18 chronylogrotate.sh
|
||||||
-rw-r--r-- 1 yourname staff 543 18 Jul 20:10 org.tuxfamily.chronyc.plist
|
-rw-r--r-- 1 yourname staff 543 18 Jul 20:10 org.chrony-project.chronyc.plist
|
||||||
-rw-r--r-- 1 yourname staff 511 19 Jun 18:30 org.tuxfamily.chronyd.plist
|
-rw-r--r-- 1 yourname staff 511 19 Jun 18:30 org.chrony-project.chronyd.plist
|
||||||
|
|
||||||
If you have used chrony support directories other than those suggested, you
|
If you have used chrony support directories other than those suggested, you
|
||||||
will need to edit each file and make the appropriate changes.
|
will need to edit each file and make the appropriate changes.
|
||||||
@@ -83,21 +83,21 @@ sudo chmod +x /usr/local/bin/chronylogrotate.sh
|
|||||||
sudo chown root:wheel /usr/local/bin/chronylogrotate.sh
|
sudo chown root:wheel /usr/local/bin/chronylogrotate.sh
|
||||||
|
|
||||||
|
|
||||||
2. org.tuxfamily.chronyc.plist
|
2. org.chrony-project.chronyc.plist
|
||||||
This file is the launchd plist that runs logrotation each day. You may
|
This file is the launchd plist that runs logrotation each day. You may
|
||||||
wish to edit this file to change the time of day at which the rotation
|
wish to edit this file to change the time of day at which the rotation
|
||||||
will run, currently 04:05 am
|
will run, currently 04:05 am
|
||||||
|
|
||||||
sudo cp org.tuxfamily.chronyc.plist /Library/LaunchDaemons
|
sudo cp org.chrony-project.chronyc.plist /Library/LaunchDaemons
|
||||||
sudo chown root:wheel /Library/LaunchDaemons/org.tuxfamily.chronyc.plist
|
sudo chown root:wheel /Library/LaunchDaemons/org.chrony-project.chronyc.plist
|
||||||
sudo chmod 0644 /Library/LaunchDaemons/org.tuxfamily.chronyc.plist
|
sudo chmod 0644 /Library/LaunchDaemons/org.chrony-project.chronyc.plist
|
||||||
sudo launchctl load -w /Library/LaunchDaemons/org.tuxfamily.chronyc.plist
|
sudo launchctl load -w /Library/LaunchDaemons/org.chrony-project.chronyc.plist
|
||||||
|
|
||||||
|
|
||||||
3. org.tuxfamily.chronyd.plist
|
3. org.chrony-project.chronyd.plist
|
||||||
This file is the launchd plist that runs chronyd when the Macintosh starts.
|
This file is the launchd plist that runs chronyd when the Macintosh starts.
|
||||||
|
|
||||||
sudo cp org.tuxfamily.chronyd.plist /Library/LaunchDaemons
|
sudo cp org.chrony-project.chronyd.plist /Library/LaunchDaemons
|
||||||
sudo chown root:wheel /Library/LaunchDaemons/org.tuxfamily.chronyd.plist
|
sudo chown root:wheel /Library/LaunchDaemons/org.chrony-project.chronyd.plist
|
||||||
sudo chmod 0644 /Library/LaunchDaemons/org.tuxfamily.chronyd.plist
|
sudo chmod 0644 /Library/LaunchDaemons/org.chrony-project.chronyd.plist
|
||||||
sudo launchctl load -w /Library/LaunchDaemons/org.tuxfamily.chronyd.plist
|
sudo launchctl load -w /Library/LaunchDaemons/org.chrony-project.chronyd.plist
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>org.tuxfamily.logrotate</string>
|
<string>org.chrony-project.logrotate</string>
|
||||||
<key>KeepAlive</key>
|
<key>KeepAlive</key>
|
||||||
<false/>
|
<false/>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
<key>Label</key>
|
<key>Label</key>
|
||||||
<string>org.tuxfamily.chronyd</string>
|
<string>org.chrony-project.chronyd</string>
|
||||||
<key>Program</key>
|
<key>Program</key>
|
||||||
<string>/usr/local/sbin/chronyd</string>
|
<string>/usr/local/sbin/chronyd</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
// Copyright (C) Richard P. Curnow 1997-2003
|
// Copyright (C) Richard P. Curnow 1997-2003
|
||||||
// Copyright (C) Stephen Wadeley 2016
|
// Copyright (C) Stephen Wadeley 2016
|
||||||
// Copyright (C) Bryan Christianson 2017
|
// Copyright (C) Bryan Christianson 2017
|
||||||
// Copyright (C) Miroslav Lichvar 2009-2022
|
// Copyright (C) Miroslav Lichvar 2009-2023
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of version 2 of the GNU General Public License as
|
// it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -3137,7 +3137,7 @@ dumpdir @CHRONYRUNDIR@
|
|||||||
== BUGS
|
== BUGS
|
||||||
|
|
||||||
For instructions on how to report bugs, please visit
|
For instructions on how to report bugs, please visit
|
||||||
https://chrony.tuxfamily.org/.
|
https://chrony-project.org/.
|
||||||
|
|
||||||
== AUTHORS
|
== AUTHORS
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
//
|
//
|
||||||
// Copyright (C) Richard P. Curnow 1997-2003
|
// Copyright (C) Richard P. Curnow 1997-2003
|
||||||
// Copyright (C) Stephen Wadeley 2016
|
// Copyright (C) Stephen Wadeley 2016
|
||||||
// Copyright (C) Miroslav Lichvar 2009-2017, 2019-2022
|
// Copyright (C) Miroslav Lichvar 2009-2017, 2019-2023
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of version 2 of the GNU General Public License as
|
// it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -379,9 +379,9 @@ offset. This can be suffixed by _ns_ (indicating nanoseconds), _us_
|
|||||||
(indicating microseconds), _ms_ (indicating milliseconds), or _s_ (indicating
|
(indicating microseconds), _ms_ (indicating milliseconds), or _s_ (indicating
|
||||||
seconds). The number to the left of the square brackets shows the original
|
seconds). The number to the left of the square brackets shows the original
|
||||||
measurement, adjusted to allow for any slews applied to the local clock
|
measurement, adjusted to allow for any slews applied to the local clock
|
||||||
since. The number following the _+/-_ indicator shows the margin of error in
|
since. Positive offsets indicate that the local clock is ahead of the source.
|
||||||
the measurement. Positive offsets indicate that the local clock is ahead of
|
The number following the _+/-_ indicator shows the margin of error in the
|
||||||
the source.
|
measurement (NTP root distance).
|
||||||
|
|
||||||
[[sourcestats]]*sourcestats* [*-a*] [*-v*]::
|
[[sourcestats]]*sourcestats* [*-a*] [*-v*]::
|
||||||
The *sourcestats* command displays information about the drift rate and offset
|
The *sourcestats* command displays information about the drift rate and offset
|
||||||
@@ -1548,7 +1548,7 @@ The *help* command displays a summary of the commands and their arguments.
|
|||||||
== BUGS
|
== BUGS
|
||||||
|
|
||||||
For instructions on how to report bugs, please visit
|
For instructions on how to report bugs, please visit
|
||||||
https://chrony.tuxfamily.org/.
|
https://chrony-project.org/.
|
||||||
|
|
||||||
== AUTHORS
|
== AUTHORS
|
||||||
|
|
||||||
|
|||||||
@@ -217,7 +217,7 @@ _@SYSCONFDIR@/chrony.conf_
|
|||||||
== BUGS
|
== BUGS
|
||||||
|
|
||||||
For instructions on how to report bugs, please visit
|
For instructions on how to report bugs, please visit
|
||||||
https://chrony.tuxfamily.org/.
|
https://chrony-project.org/.
|
||||||
|
|
||||||
== AUTHORS
|
== AUTHORS
|
||||||
|
|
||||||
|
|||||||
51
doc/faq.adoc
51
doc/faq.adoc
@@ -1,7 +1,7 @@
|
|||||||
// This file is part of chrony
|
// This file is part of chrony
|
||||||
//
|
//
|
||||||
// Copyright (C) Richard P. Curnow 1997-2003
|
// Copyright (C) Richard P. Curnow 1997-2003
|
||||||
// Copyright (C) Miroslav Lichvar 2014-2016, 2020-2022
|
// Copyright (C) Miroslav Lichvar 2014-2016, 2020-2023
|
||||||
//
|
//
|
||||||
// This program is free software; you can redistribute it and/or modify
|
// This program is free software; you can redistribute it and/or modify
|
||||||
// it under the terms of version 2 of the GNU General Public License as
|
// it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -40,9 +40,36 @@ on an isolated network with no hardware reference clocks in sight, `chrony`
|
|||||||
will probably work better for you.
|
will probably work better for you.
|
||||||
|
|
||||||
For a more detailed comparison of features and performance, see the
|
For a more detailed comparison of features and performance, see the
|
||||||
https://chrony.tuxfamily.org/comparison.html[comparison page] on the `chrony`
|
https://chrony-project.org/comparison.html[comparison page] on the `chrony`
|
||||||
website.
|
website.
|
||||||
|
|
||||||
|
=== Should I prefer `chrony` over `timesyncd` if I do not need to run a server?
|
||||||
|
|
||||||
|
Generally, yes.
|
||||||
|
|
||||||
|
`systemd-timesyncd` is a very simple NTP client included in the `systemd`
|
||||||
|
suite. It lacks almost all features of `chrony` and other advanced client
|
||||||
|
implementations listed on the
|
||||||
|
https://chrony-project.org/comparison.html[comparison page]. One of its main
|
||||||
|
limitations is that it cannot poll multiple servers at the same time and detect
|
||||||
|
servers having incorrect time (falsetickers in the NTP terminology). It should
|
||||||
|
be used only with trusted reliable servers, ideally in local network.
|
||||||
|
|
||||||
|
Using `timesyncd` with `pool.ntp.org` is problematic. The pool is very
|
||||||
|
robust as a whole, but the individual servers run by volunteers cannot be
|
||||||
|
relied on. Occasionally, servers drift away or make a step to distant past or
|
||||||
|
future due to misconfiguration, problematic implementation, and other bugs
|
||||||
|
(e.g. in firmware of a GPS receiver). The pool monitoring system detects such
|
||||||
|
servers and quickly removes them from the pool DNS, but clients like
|
||||||
|
`timesyncd` cannot recover from that. They follow the server as long as it
|
||||||
|
claims to be synchronised. They need to be restarted in order to get a new
|
||||||
|
address from the pool DNS.
|
||||||
|
|
||||||
|
Note that the complexity of NTP and clock synchronisation is on the client
|
||||||
|
side. The amount of code in `chrony` specific to NTP server is very small and
|
||||||
|
it is disabled by default. If it was removed, it would not significantly reduce
|
||||||
|
the amount of memory or storage needed.
|
||||||
|
|
||||||
== Configuration issues
|
== Configuration issues
|
||||||
|
|
||||||
=== What is the minimum recommended configuration for an NTP client?
|
=== What is the minimum recommended configuration for an NTP client?
|
||||||
@@ -484,7 +511,7 @@ identically configured leap-smearing servers. Note that some clients can get
|
|||||||
leap seconds from other sources (e.g. with the `leapsectz` directive in
|
leap seconds from other sources (e.g. with the `leapsectz` directive in
|
||||||
`chrony`) and they will not work correctly with a leap smearing server.
|
`chrony`) and they will not work correctly with a leap smearing server.
|
||||||
|
|
||||||
=== How should `chronyd` be configuration with `gpsd`?
|
=== How should `chronyd` be configured with `gpsd`?
|
||||||
|
|
||||||
A GPS or other GNSS receiver can be used as a reference clock with `gpsd`. It
|
A GPS or other GNSS receiver can be used as a reference clock with `gpsd`. It
|
||||||
can work as one or two separate time sources for each connected receiver. The
|
can work as one or two separate time sources for each connected receiver. The
|
||||||
@@ -573,6 +600,24 @@ transport for NTP messages (NTP over PTP) to enable hardware timestamping on
|
|||||||
hardware which can timestamp PTP packets only. It can be enabled by the
|
hardware which can timestamp PTP packets only. It can be enabled by the
|
||||||
`ptpport` directive.
|
`ptpport` directive.
|
||||||
|
|
||||||
|
=== How can I avoid using wrong PHC refclock?
|
||||||
|
|
||||||
|
If your system has multiple PHC devices, normally named by `udev` as
|
||||||
|
_/dev/ptp0_, _/dev/ptp1_, and so on, their order can change randomly across
|
||||||
|
reboots depending on the order of initialisation of their drivers. If a PHC
|
||||||
|
refclock is specified by this name, `chronyd` could be using a wrong refclock
|
||||||
|
after reboot. To prevent that, you can configure `udev` to create a stable
|
||||||
|
symlink for `chronyd` with a rule like this (e.g. written to
|
||||||
|
_/etc/udev/rules.d/80-phc.rules_):
|
||||||
|
|
||||||
|
----
|
||||||
|
KERNEL=="ptp[0-9]*", DEVPATH=="/devices/pci0000:00/0000:00:01.2/0000:02:00.0/ptp/*", SYMLINK+="ptp-i350-1"
|
||||||
|
----
|
||||||
|
|
||||||
|
You can get the full _DEVPATH_ of an existing PHC device with the `udevadm
|
||||||
|
info` command. You will need to execute the `udevadm trigger` command, or
|
||||||
|
reboot the system, for these changes to take effect.
|
||||||
|
|
||||||
=== Why are client log records dropped before reaching `clientloglimit`?
|
=== Why are client log records dropped before reaching `clientloglimit`?
|
||||||
|
|
||||||
The number of dropped client log records reported by the `serverstats` command
|
The number of dropped client log records reported by the `serverstats` command
|
||||||
|
|||||||
11
ntp_core.c
11
ntp_core.c
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Miroslav Lichvar 2009-2022
|
* Copyright (C) Miroslav Lichvar 2009-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -215,9 +215,6 @@ struct NCR_Instance_Record {
|
|||||||
SPF_Instance filter;
|
SPF_Instance filter;
|
||||||
int filter_count;
|
int filter_count;
|
||||||
|
|
||||||
/* Flag indicating HW transmit timestamps are expected */
|
|
||||||
int had_hw_tx_timestamp;
|
|
||||||
|
|
||||||
/* Response waiting for a HW transmit timestamp of the request */
|
/* Response waiting for a HW transmit timestamp of the request */
|
||||||
struct SavedResponse *saved_response;
|
struct SavedResponse *saved_response;
|
||||||
|
|
||||||
@@ -794,8 +791,6 @@ NCR_ResetInstance(NCR_Instance instance)
|
|||||||
if (instance->filter)
|
if (instance->filter)
|
||||||
SPF_DropSamples(instance->filter);
|
SPF_DropSamples(instance->filter);
|
||||||
instance->filter_count = 0;
|
instance->filter_count = 0;
|
||||||
|
|
||||||
instance->had_hw_tx_timestamp = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
@@ -1966,7 +1961,7 @@ process_response(NCR_Instance inst, int saved, NTP_Local_Address *local_addr,
|
|||||||
response to the request, when at least one good response has already been
|
response to the request, when at least one good response has already been
|
||||||
accepted to avoid incorrectly confirming a tentative source. */
|
accepted to avoid incorrectly confirming a tentative source. */
|
||||||
if (valid_packet && synced_packet && !saved && !inst->valid_rx &&
|
if (valid_packet && synced_packet && !saved && !inst->valid_rx &&
|
||||||
inst->had_hw_tx_timestamp && inst->local_tx.source != NTP_TS_HARDWARE &&
|
NIO_IsHwTsEnabled() && inst->local_tx.source != NTP_TS_HARDWARE &&
|
||||||
inst->report.total_good_count > 0) {
|
inst->report.total_good_count > 0) {
|
||||||
if (save_response(inst, local_addr, rx_ts, message, info))
|
if (save_response(inst, local_addr, rx_ts, message, info))
|
||||||
return 1;
|
return 1;
|
||||||
@@ -2692,8 +2687,6 @@ NCR_ProcessTxKnown(NCR_Instance inst, NTP_Local_Address *local_addr,
|
|||||||
message);
|
message);
|
||||||
|
|
||||||
if (tx_ts->source == NTP_TS_HARDWARE) {
|
if (tx_ts->source == NTP_TS_HARDWARE) {
|
||||||
inst->had_hw_tx_timestamp = 1;
|
|
||||||
|
|
||||||
if (has_saved_response(inst))
|
if (has_saved_response(inst))
|
||||||
process_saved_response(inst);
|
process_saved_response(inst);
|
||||||
}
|
}
|
||||||
|
|||||||
12
ntp_io.c
12
ntp_io.c
@@ -278,6 +278,18 @@ NIO_Finalise(void)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NIO_IsHwTsEnabled(void)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
|
return NIO_Linux_IsHwTsEnabled();
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
int
|
int
|
||||||
NIO_OpenClientSocket(NTP_Remote_Address *remote_addr)
|
NIO_OpenClientSocket(NTP_Remote_Address *remote_addr)
|
||||||
{
|
{
|
||||||
|
|||||||
3
ntp_io.h
3
ntp_io.h
@@ -39,6 +39,9 @@ extern void NIO_Initialise(void);
|
|||||||
/* Function to finalise the module */
|
/* Function to finalise the module */
|
||||||
extern void NIO_Finalise(void);
|
extern void NIO_Finalise(void);
|
||||||
|
|
||||||
|
/* Function to check if HW timestamping is enabled on any interface */
|
||||||
|
extern int NIO_IsHwTsEnabled(void);
|
||||||
|
|
||||||
/* Function to obtain a socket for sending client packets */
|
/* Function to obtain a socket for sending client packets */
|
||||||
extern int NIO_OpenClientSocket(NTP_Remote_Address *remote_addr);
|
extern int NIO_OpenClientSocket(NTP_Remote_Address *remote_addr);
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Miroslav Lichvar 2016-2019, 2021-2022
|
* Copyright (C) Miroslav Lichvar 2016-2019, 2021-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -439,6 +439,14 @@ NIO_Linux_Finalise(void)
|
|||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
NIO_Linux_IsHwTsEnabled(void)
|
||||||
|
{
|
||||||
|
return ARR_GetSize(interfaces) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
int
|
int
|
||||||
NIO_Linux_SetTimestampSocketOptions(int sock_fd, int client_only, int *events)
|
NIO_Linux_SetTimestampSocketOptions(int sock_fd, int client_only, int *events)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ extern void NIO_Linux_Initialise(void);
|
|||||||
|
|
||||||
extern void NIO_Linux_Finalise(void);
|
extern void NIO_Linux_Finalise(void);
|
||||||
|
|
||||||
|
extern int NIO_Linux_IsHwTsEnabled(void);
|
||||||
|
|
||||||
extern int NIO_Linux_SetTimestampSocketOptions(int sock_fd, int client_only, int *events);
|
extern int NIO_Linux_SetTimestampSocketOptions(int sock_fd, int client_only, int *events);
|
||||||
|
|
||||||
extern int NIO_Linux_ProcessMessage(SCK_Message *message, NTP_Local_Address *local_addr,
|
extern int NIO_Linux_ProcessMessage(SCK_Message *message, NTP_Local_Address *local_addr,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Miroslav Lichvar 2011-2012, 2014, 2016, 2020-2021
|
* Copyright (C) Miroslav Lichvar 2011-2012, 2014, 2016, 2020-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -59,6 +59,8 @@ typedef struct {
|
|||||||
NCR_Instance data; /* Data for the protocol engine for this source */
|
NCR_Instance data; /* Data for the protocol engine for this source */
|
||||||
char *name; /* Name of the source as it was specified
|
char *name; /* Name of the source as it was specified
|
||||||
(may be an IP address) */
|
(may be an IP address) */
|
||||||
|
IPAddr resolved_addr; /* Address resolved from the name, which can be
|
||||||
|
different from remote_addr (e.g. NTS-KE) */
|
||||||
int pool_id; /* ID of the pool from which was this source
|
int pool_id; /* ID of the pool from which was this source
|
||||||
added or INVALID_POOL */
|
added or INVALID_POOL */
|
||||||
int tentative; /* Flag indicating there was no valid response
|
int tentative; /* Flag indicating there was no valid response
|
||||||
@@ -388,6 +390,7 @@ add_source(NTP_Remote_Address *remote_addr, char *name, NTP_Source_Type type,
|
|||||||
record->name = Strdup(name ? name : UTI_IPToString(&remote_addr->ip_addr));
|
record->name = Strdup(name ? name : UTI_IPToString(&remote_addr->ip_addr));
|
||||||
record->data = NCR_CreateInstance(remote_addr, type, params, record->name);
|
record->data = NCR_CreateInstance(remote_addr, type, params, record->name);
|
||||||
record->remote_addr = NCR_GetRemoteAddress(record->data);
|
record->remote_addr = NCR_GetRemoteAddress(record->data);
|
||||||
|
record->resolved_addr = remote_addr->ip_addr;
|
||||||
record->pool_id = pool_id;
|
record->pool_id = pool_id;
|
||||||
record->tentative = 1;
|
record->tentative = 1;
|
||||||
record->conf_id = conf_id;
|
record->conf_id = conf_id;
|
||||||
@@ -440,6 +443,8 @@ change_source_address(NTP_Remote_Address *old_addr, NTP_Remote_Address *new_addr
|
|||||||
|
|
||||||
record = get_record(slot1);
|
record = get_record(slot1);
|
||||||
NCR_ChangeRemoteAddress(record->data, new_addr, !replacement);
|
NCR_ChangeRemoteAddress(record->data, new_addr, !replacement);
|
||||||
|
if (replacement)
|
||||||
|
record->resolved_addr = new_addr->ip_addr;
|
||||||
|
|
||||||
if (record->remote_addr != NCR_GetRemoteAddress(record->data) ||
|
if (record->remote_addr != NCR_GetRemoteAddress(record->data) ||
|
||||||
UTI_CompareIPs(&record->remote_addr->ip_addr, &new_addr->ip_addr, NULL) != 0)
|
UTI_CompareIPs(&record->remote_addr->ip_addr, &new_addr->ip_addr, NULL) != 0)
|
||||||
@@ -523,7 +528,7 @@ process_resolved_name(struct UnresolvedSource *us, IPAddr *ip_addrs, int n_addrs
|
|||||||
NTP_Remote_Address old_addr, new_addr;
|
NTP_Remote_Address old_addr, new_addr;
|
||||||
SourceRecord *record;
|
SourceRecord *record;
|
||||||
unsigned short first = 0;
|
unsigned short first = 0;
|
||||||
int i, j;
|
int i, j, slot;
|
||||||
|
|
||||||
/* Keep using the current address if it is being refreshed and it is
|
/* Keep using the current address if it is being refreshed and it is
|
||||||
still included in the resolved addresses */
|
still included in the resolved addresses */
|
||||||
@@ -531,7 +536,8 @@ process_resolved_name(struct UnresolvedSource *us, IPAddr *ip_addrs, int n_addrs
|
|||||||
assert(us->pool_id == INVALID_POOL);
|
assert(us->pool_id == INVALID_POOL);
|
||||||
|
|
||||||
for (i = 0; i < n_addrs; i++) {
|
for (i = 0; i < n_addrs; i++) {
|
||||||
if (UTI_CompareIPs(&us->address.ip_addr, &ip_addrs[i], NULL) == 0) {
|
if (find_slot2(&us->address, &slot) == 2 &&
|
||||||
|
UTI_CompareIPs(&get_record(slot)->resolved_addr, &ip_addrs[i], NULL) == 0) {
|
||||||
DEBUG_LOG("%s still fresh", UTI_IPToString(&us->address.ip_addr));
|
DEBUG_LOG("%s still fresh", UTI_IPToString(&us->address.ip_addr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Miroslav Lichvar 2020
|
* Copyright (C) Miroslav Lichvar 2020, 2022
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -651,7 +651,7 @@ load_keys(void)
|
|||||||
|
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
LOG(LOGS_ERR, "Loaded %s", "server NTS keys");
|
LOG(LOGS_INFO, "Loaded %s", "server NTS keys");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Miroslav Lichvar 2020
|
* Copyright (C) Miroslav Lichvar 2020, 2022
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Miroslav Lichvar 2013, 2017
|
* Copyright (C) Miroslav Lichvar 2013, 2017, 2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
chronyd/chronyc - Programs for keeping computer clocks accurate.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Miroslav Lichvar 2019
|
* Copyright (C) Miroslav Lichvar 2019, 2022
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
|||||||
14
socket.c
14
socket.c
@@ -869,6 +869,11 @@ process_header(struct msghdr *msg, int msg_length, int sock_fd, int flags,
|
|||||||
memcpy(&message->timestamp.kernel, CMSG_DATA(cmsg), sizeof (message->timestamp.kernel));
|
memcpy(&message->timestamp.kernel, CMSG_DATA(cmsg), sizeof (message->timestamp.kernel));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef SCM_REALTIME
|
||||||
|
else if (match_cmsg(cmsg, SOL_SOCKET, SCM_REALTIME, sizeof (message->timestamp.kernel))) {
|
||||||
|
memcpy(&message->timestamp.kernel, CMSG_DATA(cmsg), sizeof (message->timestamp.kernel));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#ifdef HAVE_LINUX_TIMESTAMPING
|
#ifdef HAVE_LINUX_TIMESTAMPING
|
||||||
#ifdef HAVE_LINUX_TIMESTAMPING_OPT_PKTINFO
|
#ifdef HAVE_LINUX_TIMESTAMPING_OPT_PKTINFO
|
||||||
else if (match_cmsg(cmsg, SOL_SOCKET, SCM_TIMESTAMPING_PKTINFO,
|
else if (match_cmsg(cmsg, SOL_SOCKET, SCM_TIMESTAMPING_PKTINFO,
|
||||||
@@ -1386,8 +1391,15 @@ SCK_EnableKernelRxTimestamping(int sock_fd)
|
|||||||
return 1;
|
return 1;
|
||||||
#endif
|
#endif
|
||||||
#ifdef SO_TIMESTAMP
|
#ifdef SO_TIMESTAMP
|
||||||
if (SCK_SetIntOption(sock_fd, SOL_SOCKET, SO_TIMESTAMP, 1))
|
if (SCK_SetIntOption(sock_fd, SOL_SOCKET, SO_TIMESTAMP, 1)) {
|
||||||
|
#if defined(SO_TS_CLOCK) && defined(SO_TS_REALTIME)
|
||||||
|
/* We don't care about the return value - we'll get either a
|
||||||
|
SCM_REALTIME (if we succeded) or a SCM_TIMESTAMP (if we failed) */
|
||||||
|
if (!SCK_SetIntOption(sock_fd, SOL_SOCKET, SO_TS_CLOCK, SO_TS_REALTIME))
|
||||||
|
;
|
||||||
|
#endif
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
25
sources.c
25
sources.c
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Miroslav Lichvar 2011-2016, 2018, 2020-2021
|
* Copyright (C) Miroslav Lichvar 2011-2016, 2018, 2020-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -587,18 +587,17 @@ update_sel_options(void)
|
|||||||
for (i = 0; i < n_sources; i++) {
|
for (i = 0; i < n_sources; i++) {
|
||||||
options = sources[i]->conf_sel_options;
|
options = sources[i]->conf_sel_options;
|
||||||
|
|
||||||
if (options & SRC_SELECT_NOSELECT)
|
if (!(options & SRC_SELECT_NOSELECT)) {
|
||||||
continue;
|
switch (sources[i]->type) {
|
||||||
|
case SRC_NTP:
|
||||||
switch (sources[i]->type) {
|
options |= sources[i]->authenticated ? auth_ntp_options : unauth_ntp_options;
|
||||||
case SRC_NTP:
|
break;
|
||||||
options |= sources[i]->authenticated ? auth_ntp_options : unauth_ntp_options;
|
case SRC_REFCLOCK:
|
||||||
break;
|
options |= refclk_options;
|
||||||
case SRC_REFCLOCK:
|
break;
|
||||||
options |= refclk_options;
|
default:
|
||||||
break;
|
assert(0);
|
||||||
default:
|
}
|
||||||
assert(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sources[i]->sel_options != options) {
|
if (sources[i]->sel_options != options) {
|
||||||
|
|||||||
@@ -350,6 +350,8 @@ minstratum 192.168.123.1 1
|
|||||||
polltarget 192.168.123.1 10
|
polltarget 192.168.123.1 10
|
||||||
selectopts 192.168.123.1 +trust +prefer -require
|
selectopts 192.168.123.1 +trust +prefer -require
|
||||||
selectdata
|
selectdata
|
||||||
|
selectopts 192.168.123.1 +noselect -prefer -trust +require
|
||||||
|
selectdata
|
||||||
delete 192.168.123.1"
|
delete 192.168.123.1"
|
||||||
|
|
||||||
run_test || test_fail
|
run_test || test_fail
|
||||||
@@ -372,6 +374,10 @@ check_chronyc_output "^200 OK
|
|||||||
S Name/IP Address Auth COpts EOpts Last Score Interval Leap
|
S Name/IP Address Auth COpts EOpts Last Score Interval Leap
|
||||||
=======================================================================
|
=======================================================================
|
||||||
M node1\.net1\.clk N \-PT\-\- \-PT\-\- 0 1\.0 \+0ns \+0ns \?
|
M node1\.net1\.clk N \-PT\-\- \-PT\-\- 0 1\.0 \+0ns \+0ns \?
|
||||||
|
200 OK
|
||||||
|
S Name/IP Address Auth COpts EOpts Last Score Interval Leap
|
||||||
|
=======================================================================
|
||||||
|
M node1\.net1\.clk N N\-\-R\- N\-\-R\- 0 1\.0 \+0ns \+0ns \?
|
||||||
200 OK$" || test_fail
|
200 OK$" || test_fail
|
||||||
|
|
||||||
chronyc_conf="
|
chronyc_conf="
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
. ./test.common
|
. ./test.common
|
||||||
test_start "presend option"
|
test_start "presend option"
|
||||||
|
|
||||||
|
limit=9900
|
||||||
min_sync_time=136
|
min_sync_time=136
|
||||||
max_sync_time=260
|
max_sync_time=260
|
||||||
client_server_options="presend 6 maxdelay 16"
|
client_server_options="presend 6 maxdelay 16"
|
||||||
|
|||||||
@@ -16,6 +16,6 @@ check_chronyd_exit || test_fail
|
|||||||
check_source_selection || test_fail
|
check_source_selection || test_fail
|
||||||
check_packet_interval || test_fail
|
check_packet_interval || test_fail
|
||||||
check_sync || test_fail
|
check_sync || test_fail
|
||||||
check_log_messages "clock wrong by" 4 8 || test_fail
|
check_log_messages "clock wrong by" 3 8 || test_fail
|
||||||
|
|
||||||
test_pass
|
test_pass
|
||||||
|
|||||||
@@ -158,10 +158,10 @@ for dns in 1 0; do
|
|||||||
check_source_selection && test_fail
|
check_source_selection && test_fail
|
||||||
check_sync && test_fail
|
check_sync && test_fail
|
||||||
|
|
||||||
check_file_messages " 2 1 .* 4460 " 50 100 log.packets || test_fail
|
check_file_messages " 2 1 .* 4460 " 45 100 log.packets || test_fail
|
||||||
check_file_messages " 2 2 .* 4460 " 0 0 log.packets || test_fail
|
check_file_messages " 2 2 .* 4460 " 0 0 log.packets || test_fail
|
||||||
check_log_messages "Source 192.168.123.1 changed to 192.168.123.2" 4 10 || test_fail
|
check_log_messages "Source 192.168.123.1 changed to 192.168.123.2" 4 10 || test_fail
|
||||||
check_log_messages "Source 192.168.123.2 replaced with 192.168.123.1" 4 10 || test_fail
|
check_log_messages "Source 192.168.123.2 replaced with 192.168.123.1" 3 10 || test_fail
|
||||||
|
|
||||||
servers=2
|
servers=2
|
||||||
|
|
||||||
@@ -225,6 +225,8 @@ for dns in 1 0; do
|
|||||||
check_file_messages " 3 2 .* 4460 " 0 0 log.packets || test_fail
|
check_file_messages " 3 2 .* 4460 " 0 0 log.packets || test_fail
|
||||||
done
|
done
|
||||||
|
|
||||||
|
min_sync_time=$[default_min_sync_time + 200]
|
||||||
|
max_sync_time=600
|
||||||
server_conf="
|
server_conf="
|
||||||
ntsserverkey tmp/server1.key
|
ntsserverkey tmp/server1.key
|
||||||
ntsservercert tmp/server1.crt
|
ntsservercert tmp/server1.crt
|
||||||
@@ -248,6 +250,8 @@ check_file_messages " 3 2 .* 123 " 0 0 log.packets || test_fail
|
|||||||
check_file_messages " 3 2 .* 11123 " 3 3 log.packets || test_fail
|
check_file_messages " 3 2 .* 11123 " 3 3 log.packets || test_fail
|
||||||
|
|
||||||
dns=1
|
dns=1
|
||||||
|
min_sync_time=$default_min_sync_time
|
||||||
|
max_sync_time=400
|
||||||
server_conf="
|
server_conf="
|
||||||
ntsserverkey tmp/server1.key
|
ntsserverkey tmp/server1.key
|
||||||
ntsservercert tmp/server1.crt
|
ntsservercert tmp/server1.crt
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ check_sync || test_fail
|
|||||||
|
|
||||||
check_log_messages "Detected falseticker" 2 10 || test_fail
|
check_log_messages "Detected falseticker" 2 10 || test_fail
|
||||||
check_log_messages "Source 192.168.123.. replaced with" 1 3 || test_fail
|
check_log_messages "Source 192.168.123.. replaced with" 1 3 || test_fail
|
||||||
check_file_messages "20.*192.168.123.* 11.1 6 6 " 15 17 measurements.log || test_fail
|
check_file_messages "20.*192.168.123.* 11.1 6 6 " 15 18 measurements.log || test_fail
|
||||||
check_file_messages "20.*00:[1-5].:.. 192.168.123.* 11.1 6 6 " 1 4 measurements.log || test_fail
|
check_file_messages "20.*00:[1-5].:.. 192.168.123.* 11.1 6 6 " 1 4 measurements.log || test_fail
|
||||||
rm -f tmp/measurements.log
|
rm -f tmp/measurements.log
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Miroslav Lichvar 2017-2018
|
* Copyright (C) Miroslav Lichvar 2017-2018, 2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
@@ -35,6 +35,7 @@ static struct timespec current_time;
|
|||||||
static NTP_Packet req_buffer, res_buffer;
|
static NTP_Packet req_buffer, res_buffer;
|
||||||
static int req_length, res_length;
|
static int req_length, res_length;
|
||||||
|
|
||||||
|
#define NIO_IsHwTsEnabled() 1
|
||||||
#define NIO_OpenServerSocket(addr) ((addr)->ip_addr.family != IPADDR_UNSPEC ? 100 : 0)
|
#define NIO_OpenServerSocket(addr) ((addr)->ip_addr.family != IPADDR_UNSPEC ? 100 : 0)
|
||||||
#define NIO_CloseServerSocket(fd) assert(fd == 100)
|
#define NIO_CloseServerSocket(fd) assert(fd == 100)
|
||||||
#define NIO_OpenClientSocket(addr) ((addr)->ip_addr.family != IPADDR_UNSPEC ? 101 : 0)
|
#define NIO_OpenClientSocket(addr) ((addr)->ip_addr.family != IPADDR_UNSPEC ? 101 : 0)
|
||||||
@@ -106,13 +107,9 @@ send_request(NCR_Instance inst, int late_hwts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (late_hwts) {
|
if (late_hwts) {
|
||||||
inst->had_hw_tx_timestamp = 1;
|
|
||||||
inst->report.total_good_count++;
|
inst->report.total_good_count++;
|
||||||
} else {
|
} else {
|
||||||
if (random() % 2)
|
inst->report.total_good_count = 0;
|
||||||
inst->had_hw_tx_timestamp = 0;
|
|
||||||
else
|
|
||||||
inst->report.total_good_count = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include <nameserv_async.h>
|
#include <nameserv_async.h>
|
||||||
#include <ntp_core.h>
|
#include <ntp_core.h>
|
||||||
#include <ntp_io.h>
|
#include <ntp_io.h>
|
||||||
|
#include <sched.h>
|
||||||
|
|
||||||
static char *requested_name = NULL;
|
static char *requested_name = NULL;
|
||||||
static DNS_NameResolveHandler resolve_handler = NULL;
|
static DNS_NameResolveHandler resolve_handler = NULL;
|
||||||
@@ -41,9 +42,11 @@ static void *resolve_handler_arg = NULL;
|
|||||||
change_remote_address(inst, remote_addr, ntp_only)
|
change_remote_address(inst, remote_addr, ntp_only)
|
||||||
#define NCR_ProcessRxKnown(remote_addr, local_addr, ts, msg, len) (random() % 2)
|
#define NCR_ProcessRxKnown(remote_addr, local_addr, ts, msg, len) (random() % 2)
|
||||||
#define NIO_IsServerConnectable(addr) (random() % 2)
|
#define NIO_IsServerConnectable(addr) (random() % 2)
|
||||||
|
#define SCH_GetLastEventMonoTime() get_mono_time()
|
||||||
|
|
||||||
static void change_remote_address(NCR_Instance inst, NTP_Remote_Address *remote_addr,
|
static void change_remote_address(NCR_Instance inst, NTP_Remote_Address *remote_addr,
|
||||||
int ntp_only);
|
int ntp_only);
|
||||||
|
static double get_mono_time(void);
|
||||||
|
|
||||||
#include <ntp_sources.c>
|
#include <ntp_sources.c>
|
||||||
|
|
||||||
@@ -96,17 +99,26 @@ change_remote_address(NCR_Instance inst, NTP_Remote_Address *remote_addr, int nt
|
|||||||
TEST_CHECK(record_lock);
|
TEST_CHECK(record_lock);
|
||||||
|
|
||||||
if (update && update_pos == 0)
|
if (update && update_pos == 0)
|
||||||
r = update_random_address(remote_addr, 4);
|
r = update_random_address(random() % 2 ? remote_addr : NCR_GetRemoteAddress(inst), 4);
|
||||||
|
|
||||||
NCR_ChangeRemoteAddress(inst, remote_addr, ntp_only);
|
NCR_ChangeRemoteAddress(inst, remote_addr, ntp_only);
|
||||||
|
|
||||||
if (update && update_pos == 1)
|
if (update && update_pos == 1)
|
||||||
r = update_random_address(remote_addr, 4);
|
r = update_random_address(random() % 2 ? remote_addr : NCR_GetRemoteAddress(inst), 4);
|
||||||
|
|
||||||
if (r)
|
if (r)
|
||||||
TEST_CHECK(UTI_IsIPReal(&saved_address_update.old_address.ip_addr));
|
TEST_CHECK(UTI_IsIPReal(&saved_address_update.old_address.ip_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double get_mono_time(void) {
|
||||||
|
static double t = 0.0;
|
||||||
|
|
||||||
|
if (random() % 2)
|
||||||
|
t += TST_GetRandomDouble(0.0, 100.0);
|
||||||
|
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
test_unit(void)
|
test_unit(void)
|
||||||
{
|
{
|
||||||
|
|||||||
2
util.c
2
util.c
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* Copyright (C) Richard P. Curnow 1997-2003
|
* Copyright (C) Richard P. Curnow 1997-2003
|
||||||
* Copyright (C) Miroslav Lichvar 2009, 2012-2021
|
* Copyright (C) Miroslav Lichvar 2009, 2012-2023
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of version 2 of the GNU General Public License as
|
* it under the terms of version 2 of the GNU General Public License as
|
||||||
|
|||||||
Reference in New Issue
Block a user