Mark offline sources unreachable
This commit is contained in:
parent
5fb5551c36
commit
2ea87490f4
3 changed files with 22 additions and 2 deletions
|
@ -1709,6 +1709,8 @@ NCR_TakeSourceOffline(NCR_Instance inst)
|
||||||
SCH_RemoveTimeout(inst->timeout_id);
|
SCH_RemoveTimeout(inst->timeout_id);
|
||||||
inst->timer_running = 0;
|
inst->timer_running = 0;
|
||||||
inst->opmode = MD_OFFLINE;
|
inst->opmode = MD_OFFLINE;
|
||||||
|
/* Mark source unreachable */
|
||||||
|
SRC_UnsetReachable(inst->source);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MD_OFFLINE:
|
case MD_OFFLINE:
|
||||||
|
@ -1923,3 +1925,10 @@ NCR_GetRemoteAddress(NCR_Instance inst)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int NCR_IsSyncPeer(NCR_Instance inst)
|
||||||
|
{
|
||||||
|
return SRC_IsSyncPeer(inst->source);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
|
@ -104,4 +104,6 @@ extern void NCR_IncrementActivityCounters(NCR_Instance inst, int *online, int *o
|
||||||
|
|
||||||
extern NTP_Remote_Address *NCR_GetRemoteAddress(NCR_Instance instance);
|
extern NTP_Remote_Address *NCR_GetRemoteAddress(NCR_Instance instance);
|
||||||
|
|
||||||
|
extern int NCR_IsSyncPeer(NCR_Instance instance);
|
||||||
|
|
||||||
#endif /* GOT_NTP_CORE_H */
|
#endif /* GOT_NTP_CORE_H */
|
||||||
|
|
|
@ -355,20 +355,29 @@ NSR_TakeSourcesOnline(IPAddr *mask, IPAddr *address)
|
||||||
int
|
int
|
||||||
NSR_TakeSourcesOffline(IPAddr *mask, IPAddr *address)
|
NSR_TakeSourcesOffline(IPAddr *mask, IPAddr *address)
|
||||||
{
|
{
|
||||||
int i;
|
int i, any, syncpeer;
|
||||||
int any;
|
|
||||||
|
|
||||||
any = 0;
|
any = 0;
|
||||||
|
syncpeer = -1;
|
||||||
for (i=0; i<N_RECORDS; i++) {
|
for (i=0; i<N_RECORDS; i++) {
|
||||||
if (records[i].remote_addr) {
|
if (records[i].remote_addr) {
|
||||||
if (address->family == IPADDR_UNSPEC ||
|
if (address->family == IPADDR_UNSPEC ||
|
||||||
!UTI_CompareIPs(&records[i].remote_addr->ip_addr, address, mask)) {
|
!UTI_CompareIPs(&records[i].remote_addr->ip_addr, address, mask)) {
|
||||||
any = 1;
|
any = 1;
|
||||||
|
if (NCR_IsSyncPeer(records[i].data)) {
|
||||||
|
syncpeer = i;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
NCR_TakeSourceOffline(records[i].data);
|
NCR_TakeSourceOffline(records[i].data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Take sync peer offline as last to avoid reference switching */
|
||||||
|
if (syncpeer >= 0) {
|
||||||
|
NCR_TakeSourceOffline(records[syncpeer].data);
|
||||||
|
}
|
||||||
|
|
||||||
return any;
|
return any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue