mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:35:06 -05:00
cmdmon: add ipv4/ipv6 options to add source command
This commit is contained in:
2
candm.h
2
candm.h
@@ -279,6 +279,8 @@ typedef struct {
|
||||
#define REQ_ADDSRC_COPY 0x400
|
||||
#define REQ_ADDSRC_EF_EXP_MONO_ROOT 0x800
|
||||
#define REQ_ADDSRC_EF_EXP_NET_CORRECTION 0x1000
|
||||
#define REQ_ADDSRC_IPV4 0x2000
|
||||
#define REQ_ADDSRC_IPV6 0x4000
|
||||
|
||||
typedef struct {
|
||||
uint32_t type;
|
||||
|
||||
2
client.c
2
client.c
@@ -962,6 +962,8 @@ process_cmd_add_source(CMD_Request *msg, char *line)
|
||||
REQ_ADDSRC_EF_EXP_MONO_ROOT : 0) |
|
||||
(data.params.ext_fields & NTP_EF_FLAG_EXP_NET_CORRECTION ?
|
||||
REQ_ADDSRC_EF_EXP_NET_CORRECTION : 0) |
|
||||
(data.family == IPADDR_INET4 ? REQ_ADDSRC_IPV4 : 0) |
|
||||
(data.family == IPADDR_INET6 ? REQ_ADDSRC_IPV6 : 0) |
|
||||
convert_addsrc_sel_options(data.params.sel_options));
|
||||
msg->data.ntp_source.filter_length = htonl(data.params.filter_length);
|
||||
msg->data.ntp_source.cert_set = htonl(data.params.cert_set);
|
||||
|
||||
8
cmdmon.c
8
cmdmon.c
@@ -720,10 +720,10 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
{
|
||||
NTP_Source_Type type;
|
||||
SourceParameters params;
|
||||
int family, pool, port;
|
||||
NSR_Status status;
|
||||
uint32_t flags;
|
||||
char *name;
|
||||
int pool, port;
|
||||
|
||||
switch (ntohl(rx_message->data.ntp_source.type)) {
|
||||
case REQ_ADDSRC_SERVER:
|
||||
@@ -753,6 +753,8 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
|
||||
flags = ntohl(rx_message->data.ntp_source.flags);
|
||||
|
||||
family = flags & REQ_ADDSRC_IPV4 ? IPADDR_INET4 :
|
||||
flags & REQ_ADDSRC_IPV6 ? IPADDR_INET6 : IPADDR_UNSPEC;
|
||||
port = ntohl(rx_message->data.ntp_source.port);
|
||||
params.minpoll = ntohl(rx_message->data.ntp_source.minpoll);
|
||||
params.maxpoll = ntohl(rx_message->data.ntp_source.maxpoll);
|
||||
@@ -790,7 +792,7 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
NTP_EF_FLAG_EXP_NET_CORRECTION : 0);
|
||||
params.sel_options = convert_addsrc_select_options(ntohl(rx_message->data.ntp_source.flags));
|
||||
|
||||
status = NSR_AddSourceByName(name, IPADDR_UNSPEC, port, pool, type, ¶ms, NULL);
|
||||
status = NSR_AddSourceByName(name, family, port, pool, type, ¶ms, NULL);
|
||||
switch (status) {
|
||||
case NSR_Success:
|
||||
break;
|
||||
@@ -808,6 +810,8 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
|
||||
tx_message->status = htons(STT_INVALIDNAME);
|
||||
break;
|
||||
case NSR_InvalidAF:
|
||||
tx_message->status = htons(STT_INVALIDAF);
|
||||
break;
|
||||
case NSR_NoSuchSource:
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
@@ -114,7 +114,7 @@ limit=1
|
||||
for chronyc_conf in \
|
||||
"accheck 1.2.3.4" \
|
||||
"add peer 10.0.0.0 minpoll 2 maxpoll 6" \
|
||||
"add server 10.0.0.0 minpoll 6 maxpoll 10 iburst burst key 1 certset 2 maxdelay 1e-3 maxdelayratio 10.0 maxdelaydevratio 10.0 maxdelayquant 0.5 mindelay 1e-4 asymmetry 0.5 offset 1e-5 minsamples 6 maxsamples 6 filter 3 offline auto_offline prefer noselect trust require xleave polltarget 20 port 123 presend 7 minstratum 3 version 4 nts ntsport 4460 copy extfield F323 extfield F324" \
|
||||
"add server 10.0.0.0 minpoll 6 maxpoll 10 iburst burst key 1 certset 2 maxdelay 1e-3 maxdelayratio 10.0 maxdelaydevratio 10.0 maxdelayquant 0.5 mindelay 1e-4 asymmetry 0.5 offset 1e-5 minsamples 6 maxsamples 6 filter 3 offline auto_offline prefer noselect trust require xleave polltarget 20 port 123 presend 7 minstratum 3 version 4 nts ntsport 4460 copy extfield F323 extfield F324 ipv6 ipv4" \
|
||||
"add server node1.net1.clk" \
|
||||
"allow 1.2.3.4" \
|
||||
"allow 1.2" \
|
||||
@@ -433,7 +433,12 @@ server_conf="
|
||||
server 192.168.123.1
|
||||
noclientlog"
|
||||
|
||||
commands=(
|
||||
check_config_h 'FEAT_IPV6 1' && commands=(
|
||||
"add server ::1 ipv4" "^515 Invalid address family$"
|
||||
) || commands=()
|
||||
|
||||
commands+=(
|
||||
"add server 192.168.123.1 ipv6" "^515 Invalid address family$"
|
||||
"add server nosuchnode.net1.clk" "^Invalid host/IP address$"
|
||||
"allow nosuchnode.net1.clk" "^Could not read address$"
|
||||
"allow 192.168.123.0/2 4" "^Could not read address$"
|
||||
|
||||
Reference in New Issue
Block a user