]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: return status from NCR_ProcessKnown()
authorMiroslav Lichvar <mlichvar@redhat.com>
Mon, 24 Nov 2014 15:14:04 +0000 (16:14 +0100)
committerMiroslav Lichvar <mlichvar@redhat.com>
Mon, 24 Nov 2014 15:14:04 +0000 (16:14 +0100)
ntp_core.c
ntp_core.h

index 8de4e4582c1f33c52e54a6ef50cb40ec69d9cd52..68d929f54ddffa714bd0d831da4efc018744399f 100644 (file)
@@ -1038,7 +1038,7 @@ check_packet_auth(NTP_Packet *pkt, int length, int *has_auth, uint32_t *key_id)
 
 /* ================================================== */
 
-static void
+static int
 receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Instance inst, NTP_Local_Address *local_addr, int length)
 {
   int pkt_leap;
@@ -1377,6 +1377,8 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
             offset, delay, dispersion,
             pkt_root_delay, pkt_root_dispersion);
   }            
+
+  return valid_packet;
 }
 
 /* ================================================== */
@@ -1408,7 +1410,7 @@ receive_packet(NTP_Packet *message, struct timeval *now, double now_err, NCR_Ins
 /* This routine is called when a new packet arrives off the network,
    and it relates to a source we have an ongoing protocol exchange with */
 
-void
+int
 NCR_ProcessKnown
 (NTP_Packet *message,           /* the received message */
  struct timeval *now,           /* timestamp at time of receipt */
@@ -1421,7 +1423,7 @@ NCR_ProcessKnown
   int pkt_mode, proc_packet, proc_as_unknown, log_peer_access;
 
   if (!check_packet_format(message, length))
-    return;
+    return 0;
 
   pkt_mode = NTP_LVM_TO_MODE(message->lvm);
   proc_packet = 0;
@@ -1520,22 +1522,25 @@ NCR_ProcessKnown
       DEBUG_LOG(LOGF_NtpCore,
                 "Packet received by wrong socket %d (expected %d)",
                 local_addr->sock_fd, inst->local_addr.sock_fd);
-      return;
+      return 0;
     }
 
     /* Ignore packets from offline sources */
     if (inst->opmode == MD_OFFLINE || inst->tx_suspended) {
       DEBUG_LOG(LOGF_NtpCore, "Packet from offline source");
-      return;
+      return 0;
     }
 
-    receive_packet(message, now, now_err, inst, local_addr, length);
+    return receive_packet(message, now, now_err, inst, local_addr, length);
   } else if (proc_as_unknown) {
     NCR_ProcessUnknown(message, now, now_err, &inst->remote_addr,
                        local_addr, length);
+    /* It's not a reply to our request, don't return success */
+    return 0;
   } else {
     DEBUG_LOG(LOGF_NtpCore, "NTP packet discarded pkt_mode=%d our_mode=%d",
               pkt_mode, inst->mode);
+    return 0;
   }
 }
 
index 4f5fc79bbe1f9d9f652bdd3aa736248ae91e9692..db624e19bf8951a759c5428d62669b01a07b24f9 100644 (file)
@@ -63,7 +63,7 @@ extern void NCR_ChangeRemoteAddress(NCR_Instance inst, NTP_Remote_Address *remot
 
 /* This routine is called when a new packet arrives off the network,
    and it relates to a source we have an ongoing protocol exchange with */
-extern void NCR_ProcessKnown(NTP_Packet *message, struct timeval *now, double now_err, NCR_Instance data, NTP_Local_Address *local_addr, int length);
+extern int NCR_ProcessKnown(NTP_Packet *message, struct timeval *now, double now_err, NCR_Instance data, NTP_Local_Address *local_addr, int length);
 
 /* This routine is called when a new packet arrives off the network,
    and we do not recognize its source */