Compare commits

..

11 Commits

Author SHA1 Message Date
Miroslav Lichvar
2ac2247756 doc: update NEWS 2021-12-16 13:17:42 +01:00
Miroslav Lichvar
55f48b14b7 update copyright years 2021-12-16 13:17:42 +01:00
Miroslav Lichvar
3dfac33858 ntp: set local address on PTP socket on FreeBSD
Fix the FreeBSD-specific code checking for a bound IPv4 socket to
include the new PTP port. This should fix a multihomed server to respond
to NTP-over-PTP requests from the address which received the request.

Fixes: be3158c4e5 ("ntp: add support for NTP over PTP")
2021-12-16 13:17:42 +01:00
Miroslav Lichvar
d5f2401421 cmdmon: fix transmit_reply() to not read uninitialized data
In the FreeBSD-specific code checking for a bound IPv4 socket, make
sure it is not a Unix domain address to avoid reading uninitialized
IP-specific fields.

This fixes an error reported by valgrind.
2021-12-16 11:49:15 +01:00
Miroslav Lichvar
fb0570cc73 socket: zero sockaddr_un to initialize sa_len
Zero the whole sockaddr struct before calling bind() and connect() to
initialize the FreeBSD-specific sa_len field.

This fixes errors reported by valgrind.
2021-12-16 10:48:31 +01:00
Miroslav Lichvar
43936ba0d1 clientlog: remove unnecessary operation in timestamp conversion 2021-12-14 10:47:26 +01:00
Miroslav Lichvar
f2ba20f293 ntp: avoid unnecessary source lookups
Avoid searching the hash table of sources when a packet in the client
mode is received. It cannot be a response from our source. Analogously,
avoid source lookups for transmitted packets in the server mode. This
doesn't change anything for packets in symmetric modes, which can be
requests and responses at the same time.

This slightly improves the maximum packet rate handled as a server.
2021-12-14 10:47:10 +01:00
Miroslav Lichvar
fcd384523b ntp: fix typo in comment 2021-12-14 10:34:19 +01:00
Miroslav Lichvar
48bce351bf doc: describe use case for leapsecmode ignore option 2021-12-09 17:13:09 +01:00
Miroslav Lichvar
25f93875d9 doc: switch Solaris support to illumos
For a long time, the Solaris support in chrony wasn't tested on a real
Solaris system, but on illumos/OpenIndiana, which was forked from
OpenSolaris when it was discontinued in 2010.

While Solaris and illumos might have not diverged enough to make a
difference for chrony, replace Solaris in the documentation with illumos
to make it clear which system is actually supported by the chrony
project.
2021-12-09 17:03:56 +01:00
Miroslav Lichvar
ebc610fcb3 sys_solaris: disable kernel dosynctodr
The dosynctodr kernel variable needs to be set to 0 to block automatic
synchronization of the system clock to the hardware clock. chronyd used
to disable dosynctodr on Solaris versions before 2.6, but it seems it is
now needed even on current versions as the clock driver sets frequency
only without calling adjtime() or setting the ntp_adjtime() PLL offset.

This issue was reproduced and fix tested on current OpenIndiana.

Fixes: 8feb37df2b ("sys_solaris: use timex driver")
2021-12-07 12:18:56 +01:00
17 changed files with 84 additions and 32 deletions

5
NEWS
View File

@@ -16,6 +16,11 @@ Bug fixes
--------- ---------
* Fix RTC support with 64-bit time_t on 32-bit Linux * Fix RTC support with 64-bit time_t on 32-bit Linux
* Fix seccomp filter to work correctly with bind*device directives * Fix seccomp filter to work correctly with bind*device directives
* Suppress kernel adjustments of system clock (dosynctodr) on illumos
Other changes
-------------
* Switch Solaris support to illumos
New in version 4.1 New in version 4.1
================== ==================

2
README
View File

@@ -28,7 +28,7 @@ What will chrony run on?
======================== ========================
The software is known to work on Linux, FreeBSD, NetBSD, macOS and The software is known to work on Linux, FreeBSD, NetBSD, macOS and
Solaris. Closely related systems may work too. Any other system will illumos. Closely related systems may work too. Any other system will
likely require a porting exercise. likely require a porting exercise.
How do I set it up? How do I set it up?

View File

@@ -3,7 +3,7 @@
********************************************************************** **********************************************************************
* Copyright (C) Richard P. Curnow 1997-2003 * Copyright (C) Richard P. Curnow 1997-2003
* Copyright (C) Miroslav Lichvar 2009, 2015-2017 * Copyright (C) Miroslav Lichvar 2009, 2015-2017, 2021
* *
* 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
@@ -751,7 +751,7 @@ static void
int64_to_ntp64(uint64_t ts, NTP_int64 *ntp_ts) int64_to_ntp64(uint64_t ts, NTP_int64 *ntp_ts)
{ {
ntp_ts->hi = htonl(ts >> 32); ntp_ts->hi = htonl(ts >> 32);
ntp_ts->lo = htonl(ts & ((1ULL << 32) - 1)); ntp_ts->lo = htonl(ts);
} }
/* ================================================== */ /* ================================================== */

View File

@@ -321,7 +321,8 @@ transmit_reply(int sock_fd, int request_length, SCK_Message *message)
#if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR) #if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR)
/* On FreeBSD a local IPv4 address cannot be specified on bound socket */ /* On FreeBSD a local IPv4 address cannot be specified on bound socket */
if (message->local_addr.ip.family == IPADDR_INET4 && (sock_fd != sock_fd4 || bound_sock_fd4)) if (message->addr_type == SCK_ADDR_IP && message->local_addr.ip.family == IPADDR_INET4 &&
(sock_fd != sock_fd4 || bound_sock_fd4))
message->local_addr.ip.family = IPADDR_UNSPEC; message->local_addr.ip.family = IPADDR_UNSPEC;
#endif #endif

View File

@@ -3,7 +3,7 @@
********************************************************************** **********************************************************************
* Copyright (C) Richard P. Curnow 1997-2003 * Copyright (C) Richard P. Curnow 1997-2003
* Copyright (C) Miroslav Lichvar 2013-2014, 2016 * Copyright (C) Miroslav Lichvar 2013-2014, 2016, 2021
* *
* 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

4
configure vendored
View File

@@ -467,7 +467,7 @@ case $OPERATINGSYSTEM in
;; ;;
SunOS) SunOS)
EXTRA_OBJECTS="sys_generic.o sys_solaris.o sys_timex.o sys_posix.o" EXTRA_OBJECTS="sys_generic.o sys_solaris.o sys_timex.o sys_posix.o"
LIBS="$LIBS -lsocket -lnsl -lresolv" LIBS="$LIBS -lsocket -lnsl -lkvm -lelf -lresolv"
try_setsched=1 try_setsched=1
try_lockmem=1 try_lockmem=1
add_def SOLARIS add_def SOLARIS
@@ -479,7 +479,7 @@ case $OPERATINGSYSTEM in
add_def FEAT_PRIVDROP add_def FEAT_PRIVDROP
priv_ops="ADJUSTTIMEX SETTIME BINDSOCKET" priv_ops="ADJUSTTIMEX SETTIME BINDSOCKET"
fi fi
echo "Configuring for Solaris (" $SYSTEM "SunOS version" $VERSION ")" echo "Configuring for illumos (" $SYSTEM "SunOS version" $VERSION ")"
;; ;;
* ) * )
echo "error: $SYSTEM is not supported (yet?)" echo "error: $SYSTEM is not supported (yet?)"

View File

@@ -1099,7 +1099,11 @@ clock will be off for a longer time. On Linux with the default
*ignore*::: *ignore*:::
No correction is applied to the clock for the leap second. The clock will be No correction is applied to the clock for the leap second. The clock will be
corrected later in normal operation when new measurements are made and the corrected later in normal operation when new measurements are made and the
estimated offset includes the one second error. estimated offset includes the one second error. This option is particularly
useful when multiple *chronyd* instances are running on the system, one
controlling the system clock and others started with the *-x* option, which
should rely on the first instance to correct the system clock and ignore it for
the correction of their own NTP clock running on top of the system clock.
{blank}:: {blank}::
+ +
When serving time to NTP clients that cannot be configured to correct their When serving time to NTP clients that cannot be configured to correct their
@@ -1238,7 +1242,7 @@ This directive specifies the maximum assumed drift (frequency error) of the
system clock. It limits the frequency adjustment that *chronyd* is allowed to system clock. It limits the frequency adjustment that *chronyd* is allowed to
use to correct the measured drift. It is an additional limit to the maximum use to correct the measured drift. It is an additional limit to the maximum
adjustment that can be set by the system driver (100000 ppm on Linux, 500 ppm adjustment that can be set by the system driver (100000 ppm on Linux, 500 ppm
on FreeBSD, NetBSD, and macOS 10.13+, 32500 ppm on Solaris). on FreeBSD, NetBSD, and macOS 10.13+, 32500 ppm on illumos).
+ +
By default, the maximum assumed drift is 500000 ppm, i.e. the adjustment is By default, the maximum assumed drift is 500000 ppm, i.e. the adjustment is
limited by the system driver rather than this directive. limited by the system driver rather than this directive.
@@ -1277,7 +1281,7 @@ all supported systems with the exception of macOS 12 or earlier).
+ +
For each system there is a maximum frequency offset of the clock that can be set For each system there is a maximum frequency offset of the clock that can be set
by the driver. On Linux it is 100000 ppm, on FreeBSD, NetBSD and macOS 10.13+ it by the driver. On Linux it is 100000 ppm, on FreeBSD, NetBSD and macOS 10.13+ it
is 5000 ppm, and on Solaris it is 32500 ppm. Also, due to a kernel limitation, is 5000 ppm, and on illumos it is 32500 ppm. Also, due to a kernel limitation,
setting *maxslewrate* on FreeBSD, NetBSD, macOS 10.13+ to a value between 500 setting *maxslewrate* on FreeBSD, NetBSD, macOS 10.13+ to a value between 500
ppm and 5000 ppm will effectively set it to 500 ppm. ppm and 5000 ppm will effectively set it to 500 ppm.
+ +
@@ -2524,7 +2528,7 @@ file when the <<chronyc.adoc#rekey,*rekey*>> command is issued by *chronyc*).
[[lock_all]]*lock_all*:: [[lock_all]]*lock_all*::
The *lock_all* directive will lock the *chronyd* process into RAM so that it The *lock_all* directive will lock the *chronyd* process into RAM so that it
will never be paged out. This can result in lower and more consistent latency. will never be paged out. This can result in lower and more consistent latency.
The directive is supported on Linux, FreeBSD, NetBSD, and Solaris. The directive is supported on Linux, FreeBSD, NetBSD, and illumos.
[[pidfile]]*pidfile* _file_:: [[pidfile]]*pidfile* _file_::
Unless *chronyd* is started with the *-Q* option, it writes its process ID Unless *chronyd* is started with the *-Q* option, it writes its process ID
@@ -2564,7 +2568,7 @@ ptpport 319
---- ----
[[sched_priority]]*sched_priority* _priority_:: [[sched_priority]]*sched_priority* _priority_::
On Linux, FreeBSD, NetBSD, and Solaris, the *sched_priority* directive will On Linux, FreeBSD, NetBSD, and illumos, the *sched_priority* directive will
select the SCHED_FIFO real-time scheduler at the specified priority (which must select the SCHED_FIFO real-time scheduler at the specified priority (which must
be between 0 and 100). On macOS, this option must have either a value of 0 (the be between 0 and 100). On macOS, this option must have either a value of 0 (the
default) to disable the thread time constraint policy or 1 for the policy to be default) to disable the thread time constraint policy or 1 for the policy to be
@@ -2590,7 +2594,7 @@ The *user* directive sets the name of the system user to which *chronyd* will
switch after start in order to drop root privileges. switch after start in order to drop root privileges.
+ +
On Linux, *chronyd* needs to be compiled with support for the *libcap* library. On Linux, *chronyd* needs to be compiled with support for the *libcap* library.
On macOS, FreeBSD, NetBSD and Solaris *chronyd* forks into two processes. On macOS, FreeBSD, NetBSD and illumos *chronyd* forks into two processes.
The child process retains root privileges, but can only perform a very limited The child process retains root privileges, but can only perform a very limited
range of privileged system calls on behalf of the parent. range of privileged system calls on behalf of the parent.
+ +

View File

@@ -100,7 +100,7 @@ directive in the configuration file. This option is useful if you want to stop
and restart *chronyd* briefly for any reason, e.g. to install a new version. and restart *chronyd* briefly for any reason, e.g. to install a new version.
However, it should be used only on systems where the kernel can maintain clock However, it should be used only on systems where the kernel can maintain clock
compensation whilst not under *chronyd*'s control (i.e. Linux, FreeBSD, NetBSD, compensation whilst not under *chronyd*'s control (i.e. Linux, FreeBSD, NetBSD,
Solaris, and macOS 10.13 or later). illumos, and macOS 10.13 or later).
*-R*:: *-R*::
When this option is used, the <<chrony.conf.adoc#initstepslew,*initstepslew*>> When this option is used, the <<chrony.conf.adoc#initstepslew,*initstepslew*>>
@@ -141,7 +141,7 @@ after start in order to drop root privileges. It overrides the
_@DEFAULT_USER@_. _@DEFAULT_USER@_.
+ +
On Linux, *chronyd* needs to be compiled with support for the *libcap* library. On Linux, *chronyd* needs to be compiled with support for the *libcap* library.
On macOS, FreeBSD, NetBSD and Solaris *chronyd* forks into two processes. On macOS, FreeBSD, NetBSD, and illumos *chronyd* forks into two processes.
The child process retains root privileges, but can only perform a very limited The child process retains root privileges, but can only perform a very limited
range of privileged system calls on behalf of the parent. range of privileged system calls on behalf of the parent.
@@ -181,7 +181,7 @@ limited.
The filters cannot be enabled with the *mailonchange* directive. The filters cannot be enabled with the *mailonchange* directive.
*-P* _priority_:: *-P* _priority_::
On Linux, FreeBSD, NetBSD, and Solaris, this option will select the SCHED_FIFO On Linux, FreeBSD, NetBSD, and illumos this option will select the SCHED_FIFO
real-time scheduler at the specified priority (which must be between 0 and real-time scheduler at the specified priority (which must be between 0 and
100). On macOS, this option must have either a value of 0 to disable the thread 100). On macOS, this option must have either a value of 0 to disable the thread
time constraint policy or 1 for the policy to be enabled. Other systems do not time constraint policy or 1 for the policy to be enabled. Other systems do not
@@ -189,7 +189,7 @@ support this option. The default value is 0.
*-m*:: *-m*::
This option will lock *chronyd* into RAM so that it will never be paged out. This option will lock *chronyd* into RAM so that it will never be paged out.
This mode is only supported on Linux, FreeBSD, NetBSD, and Solaris. This mode is only supported on Linux, FreeBSD, NetBSD, and illumos.
*-x*:: *-x*::
This option disables the control of the system clock. *chronyd* will not try to This option disables the control of the system clock. *chronyd* will not try to

View File

@@ -3,7 +3,7 @@
********************************************************************** **********************************************************************
* Copyright (C) Richard P. Curnow 1997-2003 * Copyright (C) Richard P. Curnow 1997-2003
* Copyright (C) Miroslav Lichvar 2009-2020 * Copyright (C) Miroslav Lichvar 2009-2021
* *
* 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
@@ -1972,7 +1972,7 @@ process_response(NCR_Instance inst, NTP_Local_Address *local_addr,
updated_timestamps = 2; updated_timestamps = 2;
/* If available, update the monotonic timestamp and accumulate the offset. /* If available, update the monotonic timestamp and accumulate the offset.
This needs to be done here to no lose changes in remote_ntp_rx in This needs to be done here to not lose changes in remote_ntp_rx in
symmetric mode when there are multiple responses per request. */ symmetric mode when there are multiple responses per request. */
if (ef_exp1 && !UTI_IsZeroNtp64(&ef_exp1->mono_receive_ts)) { if (ef_exp1 && !UTI_IsZeroNtp64(&ef_exp1->mono_receive_ts)) {
inst->remote_mono_epoch = ntohl(ef_exp1->mono_epoch); inst->remote_mono_epoch = ntohl(ef_exp1->mono_epoch);

View File

@@ -4,7 +4,7 @@
********************************************************************** **********************************************************************
* Copyright (C) Richard P. Curnow 1997-2003 * Copyright (C) Richard P. Curnow 1997-2003
* Copyright (C) Timo Teras 2009 * Copyright (C) Timo Teras 2009
* Copyright (C) Miroslav Lichvar 2009, 2013-2016, 2018-2020 * Copyright (C) Miroslav Lichvar 2009, 2013-2016, 2018-2021
* *
* 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
@@ -594,7 +594,7 @@ NIO_SendPacket(NTP_Packet *packet, NTP_Remote_Address *remote_addr,
#if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR) #if !defined(HAVE_IN_PKTINFO) && defined(IP_SENDSRCADDR)
/* On FreeBSD a local IPv4 address cannot be specified on bound socket */ /* On FreeBSD a local IPv4 address cannot be specified on bound socket */
if (message.local_addr.ip.family == IPADDR_INET4 && if (message.local_addr.ip.family == IPADDR_INET4 &&
(local_addr->sock_fd != server_sock_fd4 || bound_server_sock_fd4)) (bound_server_sock_fd4 || !NIO_IsServerSocket(local_addr->sock_fd)))
message.local_addr.ip.family = IPADDR_UNSPEC; message.local_addr.ip.family = IPADDR_UNSPEC;
#endif #endif

View File

@@ -1100,8 +1100,10 @@ NSR_ProcessRx(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
assert(initialised); assert(initialised);
/* Must match IP address AND port number */ /* Avoid unnecessary lookup if the packet cannot be a response from our
if (find_slot2(remote_addr, &slot) == 2) { source. Otherwise, it must match both IP address and port number. */
if (NTP_LVM_TO_MODE(message->lvm) != MODE_CLIENT &&
find_slot2(remote_addr, &slot) == 2) {
record = get_record(slot); record = get_record(slot);
if (!NCR_ProcessRxKnown(record->data, local_addr, rx_ts, message, length)) if (!NCR_ProcessRxKnown(record->data, local_addr, rx_ts, message, length))
@@ -1137,8 +1139,10 @@ NSR_ProcessTx(NTP_Remote_Address *remote_addr, NTP_Local_Address *local_addr,
SourceRecord *record; SourceRecord *record;
int slot; int slot;
/* Must match IP address AND port number */ /* Avoid unnecessary lookup if the packet cannot be a request to our
if (find_slot2(remote_addr, &slot) == 2) { source. Otherwise, it must match both IP address and port number. */
if (NTP_LVM_TO_MODE(message->lvm) != MODE_SERVER &&
find_slot2(remote_addr, &slot) == 2) {
record = get_record(slot); record = get_record(slot);
NCR_ProcessTxKnown(record->data, local_addr, tx_ts, message, length); NCR_ProcessTxKnown(record->data, local_addr, tx_ts, message, length);
} else { } else {

View File

@@ -505,6 +505,8 @@ bind_unix_address(int sock_fd, const char *addr, int flags)
{ {
union sockaddr_all saddr; union sockaddr_all saddr;
memset(&saddr, 0, sizeof (saddr));
if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >= if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >=
sizeof (saddr.un.sun_path)) { sizeof (saddr.un.sun_path)) {
DEBUG_LOG("Unix socket path %s too long", addr); DEBUG_LOG("Unix socket path %s too long", addr);
@@ -537,6 +539,8 @@ connect_unix_address(int sock_fd, const char *addr)
{ {
union sockaddr_all saddr; union sockaddr_all saddr;
memset(&saddr, 0, sizeof (saddr));
if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >= if (snprintf(saddr.un.sun_path, sizeof (saddr.un.sun_path), "%s", addr) >=
sizeof (saddr.un.sun_path)) { sizeof (saddr.un.sun_path)) {
DEBUG_LOG("Unix socket path %s too long", addr); DEBUG_LOG("Unix socket path %s too long", addr);

View File

@@ -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 * Copyright (C) Miroslav Lichvar 2011-2016, 2018, 2020-2021
* *
* 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

View File

@@ -21,23 +21,54 @@
======================================================================= =======================================================================
Driver file for Solaris operating system Driver file for illumos operating system (previously Solaris)
*/ */
#include "config.h" #include "config.h"
#include "sysincl.h" #include "sysincl.h"
#include "logging.h"
#include "privops.h" #include "privops.h"
#include "sys_solaris.h" #include "sys_solaris.h"
#include "sys_timex.h" #include "sys_timex.h"
#include "util.h" #include "util.h"
#include <kvm.h>
#include <nlist.h>
/* ================================================== */
static void
set_dosynctodr(int on_off)
{
struct nlist nl[] = { {"dosynctodr"}, {NULL} };
kvm_t *kt;
kt = kvm_open(NULL, NULL, NULL, O_RDWR, NULL);
if (!kt)
LOG_FATAL("Could not open kvm");
if (kvm_nlist(kt, nl) < 0 || !nl[0].n_value)
LOG_FATAL("Could not get dosynctodr address");
if (kvm_kwrite(kt, nl[0].n_value, &on_off, sizeof (on_off)) < 0)
LOG_FATAL("Could not write to dosynctodr");
kvm_close(kt);
}
/* ================================================== */ /* ================================================== */
void void
SYS_Solaris_Initialise(void) SYS_Solaris_Initialise(void)
{ {
/* The kernel keeps the system clock and hardware clock synchronised to each
other. The dosynctodr variable needs to be set to zero to prevent the
the system clock from following the hardware clock when the system clock
is not adjusted by adjtime() or ntp_adjtime(modes=MOD_OFFSET). */
set_dosynctodr(0);
/* The kernel allows the frequency to be set in the full range off int32_t */ /* The kernel allows the frequency to be set in the full range off int32_t */
SYS_Timex_InitialiseWithFunctions(32500, 1.0 / 100, NULL, NULL, NULL, SYS_Timex_InitialiseWithFunctions(32500, 1.0 / 100, NULL, NULL, NULL,
0.0, 0.0, NULL, NULL); 0.0, 0.0, NULL, NULL);

View File

@@ -1,6 +1,6 @@
/* /*
********************************************************************** **********************************************************************
* Copyright (C) Miroslav Lichvar 2016 * Copyright (C) Miroslav Lichvar 2016, 2021
* *
* 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

View File

@@ -110,7 +110,7 @@ change_remote_address(NCR_Instance inst, NTP_Remote_Address *remote_addr, int nt
void void
test_unit(void) test_unit(void)
{ {
char source_line[] = "127.0.0.1 offline", conf[] = "port 0", name[64], msg[1]; char source_line[] = "127.0.0.1 offline", conf[] = "port 0", name[64];
int i, j, k, slot, found, pool, prev_n; int i, j, k, slot, found, pool, prev_n;
uint32_t hash = 0, conf_id; uint32_t hash = 0, conf_id;
NTP_Remote_Address addrs[256], addr; NTP_Remote_Address addrs[256], addr;
@@ -120,6 +120,7 @@ test_unit(void)
RPT_ActivityReport report; RPT_ActivityReport report;
CPS_NTP_Source source; CPS_NTP_Source source;
NSR_Status status; NSR_Status status;
NTP_Packet msg;
CNF_Initialise(0, 0); CNF_Initialise(0, 0);
CNF_ParseLine(NULL, 1, conf); CNF_ParseLine(NULL, 1, conf);
@@ -272,12 +273,14 @@ test_unit(void)
switch (random() % 5) { switch (random() % 5) {
case 0: case 0:
msg.lvm = NTP_LVM(0, NTP_VERSION, random() % 2 ? MODE_CLIENT : MODE_SERVER);
NSR_ProcessTx(get_record(slot)->remote_addr, &local_addr, NSR_ProcessTx(get_record(slot)->remote_addr, &local_addr,
&local_ts, (NTP_Packet *)msg, 0); &local_ts, &msg, 0);
break; break;
case 1: case 1:
msg.lvm = NTP_LVM(0, NTP_VERSION, random() % 2 ? MODE_CLIENT : MODE_SERVER);
NSR_ProcessRx(get_record(slot)->remote_addr, &local_addr, NSR_ProcessRx(get_record(slot)->remote_addr, &local_addr,
&local_ts, (NTP_Packet *)msg, 0); &local_ts, &msg, 0);
break; break;
case 2: case 2:
NSR_HandleBadSource(&get_record(slot)->remote_addr->ip_addr); NSR_HandleBadSource(&get_record(slot)->remote_addr->ip_addr);

2
util.c
View File

@@ -3,7 +3,7 @@
********************************************************************** **********************************************************************
* Copyright (C) Richard P. Curnow 1997-2003 * Copyright (C) Richard P. Curnow 1997-2003
* Copyright (C) Miroslav Lichvar 2009, 2012-2020 * Copyright (C) Miroslav Lichvar 2009, 2012-2021
* *
* 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