]> git.ipfire.org Git - thirdparty/chrony.git/commitdiff
ntp: change NSR_RemoveSource() to accept IP address only
authorMiroslav Lichvar <mlichvar@redhat.com>
Wed, 20 May 2020 16:06:43 +0000 (18:06 +0200)
committerMiroslav Lichvar <mlichvar@redhat.com>
Thu, 21 May 2020 10:42:18 +0000 (12:42 +0200)
Change the function to accept IP address alone to make it clear that the
port is ignored.

cmdmon.c
ntp_sources.c
ntp_sources.h
stubs.c
test/unit/ntp_sources.c

index 5dac63683215f2ade096c85f0a648553ee62556f..20b1c2cf3df528a38712e3087404bb155ec33556 100644 (file)
--- a/cmdmon.c
+++ b/cmdmon.c
@@ -782,13 +782,12 @@ handle_add_source(CMD_Request *rx_message, CMD_Reply *tx_message)
 static void
 handle_del_source(CMD_Request *rx_message, CMD_Reply *tx_message)
 {
-  NTP_Remote_Address rem_addr;
   NSR_Status status;
+  IPAddr ip_addr;
   
-  UTI_IPNetworkToHost(&rx_message->data.del_source.ip_addr, &rem_addr.ip_addr);
-  rem_addr.port = 0;
+  UTI_IPNetworkToHost(&rx_message->data.del_source.ip_addr, &ip_addr);
   
-  status = NSR_RemoveSource(&rem_addr);
+  status = NSR_RemoveSource(&ip_addr);
   switch (status) {
     case NSR_Success:
       break;
index 579c01de8d187af7183f61428653d2c1215a5767..db6cbc8139a3a036e88cc3f5e68e78e3559c39f2 100644 (file)
@@ -749,16 +749,15 @@ clean_source_record(SourceRecord *record)
 
 /* Procedure to remove a source.  We don't bother whether the port
    address is matched - we're only interested in removing a record for
-   the right IP address.  Thus the caller can specify the port number
-   as zero if it wishes. */
+   the right IP address. */
 NSR_Status
-NSR_RemoveSource(NTP_Remote_Address *remote_addr)
+NSR_RemoveSource(IPAddr *address)
 {
   int slot;
 
   assert(initialised);
 
-  if (find_slot2(remote_addr, &slot) == 0)
+  if (find_slot(address, &slot) == 0)
     return NSR_NoSuchSource;
 
   clean_source_record(get_record(slot));
index adb241effdc438ad20a018f046fd00df0d8a53fa..5fbbe5142c5ab515fc382bc210d25935efd11601 100644 (file)
@@ -76,7 +76,7 @@ extern void NSR_StartSources(void);
 extern void NSR_AutoStartSources(void);
 
 /* Procedure to remove a source */
-extern NSR_Status NSR_RemoveSource(NTP_Remote_Address *remote_addr);
+extern NSR_Status NSR_RemoveSource(IPAddr *address);
 
 /* Procedure to remove all sources */
 extern void NSR_RemoveAllSources(void);
diff --git a/stubs.c b/stubs.c
index a337307742a78c22303f4c311c17c764950d4edf..e011995808ea2a36da5b6ef3eb27bc40a6250740 100644 (file)
--- a/stubs.c
+++ b/stubs.c
@@ -206,7 +206,7 @@ NSR_AddSourceByName(char *name, int port, int pool, NTP_Source_Type type, Source
 }
 
 NSR_Status
-NSR_RemoveSource(NTP_Remote_Address *remote_addr)
+NSR_RemoveSource(IPAddr *address)
 {
   return NSR_NoSuchSource;
 }
index fdde8de51150e65213b449fbed3cc31dbf2fb48d..132b96263a5a8eb7811c8d37dcc2aa397d2b34e4 100644 (file)
@@ -84,7 +84,7 @@ test_unit(void)
 
     for (j = 0; j < sizeof (addrs) / sizeof (addrs[0]); j++) {
       DEBUG_LOG("removing source %s", UTI_IPToString(&addrs[j].ip_addr));
-      NSR_RemoveSource(&addrs[j]);
+      NSR_RemoveSource(&addrs[j].ip_addr);
 
       for (k = 0; k < sizeof (addrs) / sizeof (addrs[0]); k++) {
         found = find_slot2(&addrs[k], &slot);