mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-05 00:25:06 -05:00
ntp: allow online/offline state to be selected by connectability
Allow SRC_MAYBE_ONLINE to be specified for new NTP sources and connectivity setting to select between SRC_ONLINE and SRC_OFFLINE according to the result of the connect() system call, i.e. check whether the client has a route to send its requests.
This commit is contained in:
@@ -603,7 +603,9 @@ NCR_GetInstance(NTP_Remote_Address *remote_addr, NTP_Source_Type type, SourcePar
|
||||
result->rx_timeout_id = 0;
|
||||
result->tx_timeout_id = 0;
|
||||
result->tx_suspended = 1;
|
||||
result->opmode = params->connectivity == SRC_ONLINE ? MD_ONLINE : MD_OFFLINE;
|
||||
result->opmode = params->connectivity == SRC_ONLINE ||
|
||||
(params->connectivity == SRC_MAYBE_ONLINE &&
|
||||
NIO_IsServerConnectable(remote_addr)) ? MD_ONLINE : MD_OFFLINE;
|
||||
result->local_poll = result->minpoll;
|
||||
result->poll_score = 0.0;
|
||||
zero_local_timestamp(&result->local_tx);
|
||||
@@ -2281,6 +2283,9 @@ NCR_SetConnectivity(NCR_Instance inst, SRC_Connectivity connectivity)
|
||||
|
||||
s = UTI_IPToString(&inst->remote_addr.ip_addr);
|
||||
|
||||
if (connectivity == SRC_MAYBE_ONLINE)
|
||||
connectivity = NIO_IsServerConnectable(&inst->remote_addr) ? SRC_ONLINE : SRC_OFFLINE;
|
||||
|
||||
switch (connectivity) {
|
||||
case SRC_ONLINE:
|
||||
switch (inst->opmode) {
|
||||
|
||||
Reference in New Issue
Block a user