ntp: fix accepting requests from configured sources
When using server socket to send client requests (acquisitionport 123) and currently not waiting for a reply, the socket check will fail for client requests from the source. The check needs to be moved to correctly handle the requests as from an unknown source.
This commit is contained in:
parent
93aeecefeb
commit
dccd61966a
1 changed files with 15 additions and 14 deletions
29
ntp_core.c
29
ntp_core.c
|
@ -1420,19 +1420,6 @@ NCR_ProcessKnown
|
||||||
{
|
{
|
||||||
int pkt_mode, proc_packet, proc_as_unknown, log_peer_access;
|
int pkt_mode, proc_packet, proc_as_unknown, log_peer_access;
|
||||||
|
|
||||||
/* Make sure the packet was received by the sending socket */
|
|
||||||
if (local_addr->sock_fd != inst->local_addr.sock_fd) {
|
|
||||||
DEBUG_LOG(LOGF_NtpCore,
|
|
||||||
"Packet received by wrong socket %d (expected %d)",
|
|
||||||
local_addr->sock_fd, inst->local_addr.sock_fd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Ignore packets from offline sources */
|
|
||||||
if (inst->opmode == MD_OFFLINE || inst->tx_suspended) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!check_packet_format(message, length))
|
if (!check_packet_format(message, length))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1528,10 +1515,24 @@ NCR_ProcessKnown
|
||||||
CLG_LogNTPPeerAccess(&inst->remote_addr.ip_addr, now->tv_sec);
|
CLG_LogNTPPeerAccess(&inst->remote_addr.ip_addr, now->tv_sec);
|
||||||
|
|
||||||
if (proc_packet) {
|
if (proc_packet) {
|
||||||
|
/* Check if the reply was received by the socket that sent the request */
|
||||||
|
if (local_addr->sock_fd != inst->local_addr.sock_fd) {
|
||||||
|
DEBUG_LOG(LOGF_NtpCore,
|
||||||
|
"Packet received by wrong socket %d (expected %d)",
|
||||||
|
local_addr->sock_fd, inst->local_addr.sock_fd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore packets from offline sources */
|
||||||
|
if (inst->opmode == MD_OFFLINE || inst->tx_suspended) {
|
||||||
|
DEBUG_LOG(LOGF_NtpCore, "Packet from offline source");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
receive_packet(message, now, now_err, inst, local_addr, length);
|
receive_packet(message, now, now_err, inst, local_addr, length);
|
||||||
} else if (proc_as_unknown) {
|
} else if (proc_as_unknown) {
|
||||||
NCR_ProcessUnknown(message, now, now_err, &inst->remote_addr,
|
NCR_ProcessUnknown(message, now, now_err, &inst->remote_addr,
|
||||||
&inst->local_addr, length);
|
local_addr, length);
|
||||||
} else {
|
} else {
|
||||||
DEBUG_LOG(LOGF_NtpCore, "NTP packet discarded pkt_mode=%d our_mode=%d",
|
DEBUG_LOG(LOGF_NtpCore, "NTP packet discarded pkt_mode=%d our_mode=%d",
|
||||||
pkt_mode, inst->mode);
|
pkt_mode, inst->mode);
|
||||||
|
|
Loading…
Reference in a new issue