From: Miroslav Lichvar Date: Wed, 20 May 2020 16:06:43 +0000 (+0200) Subject: ntp: change NSR_RemoveSource() to accept IP address only X-Git-Tag: 4.0-pre3~118 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=145423068b7510edff3232ffdcf582d669a13af8;p=thirdparty%2Fchrony.git ntp: change NSR_RemoveSource() to accept IP address only Change the function to accept IP address alone to make it clear that the port is ignored. --- diff --git a/cmdmon.c b/cmdmon.c index 5dac6368..20b1c2cf 100644 --- 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; diff --git a/ntp_sources.c b/ntp_sources.c index 579c01de..db6cbc81 100644 --- a/ntp_sources.c +++ b/ntp_sources.c @@ -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)); diff --git a/ntp_sources.h b/ntp_sources.h index adb241ef..5fbbe514 100644 --- a/ntp_sources.h +++ b/ntp_sources.h @@ -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 a3373077..e0119958 100644 --- 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; } diff --git a/test/unit/ntp_sources.c b/test/unit/ntp_sources.c index fdde8de5..132b9626 100644 --- a/test/unit/ntp_sources.c +++ b/test/unit/ntp_sources.c @@ -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);