From: Dave Hart Date: Thu, 11 Apr 2024 01:49:09 +0000 (+0000) Subject: [Bug 3909] Do not select multicast local address for unicast peer. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96bc02e4759b6d7ae394a7d14f7aca77ed45f40e;p=thirdparty%2Fntp.git [Bug 3909] Do not select multicast local address for unicast peer. bk: 66174195y_tEFf_0yxi3qWK5x-TzyQ --- diff --git a/ChangeLog b/ChangeLog index c5d0f5a49..7699f1db7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ --- +* [Bug 3909] Do not select multicast local address for unicast peer. + * [Bug 3903] lib/isc/win32/strerror.c NTstrerror() is not thread-safe. * [Bug 3901] LIB_GETBUF isn't thread-safe. diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 5bb357c31..274514456 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -1514,7 +1514,8 @@ refresh_interface( void interface_update( interface_receiver_t receiver, - void * data) + void * data + ) { int new_interface_found; @@ -1525,9 +1526,9 @@ interface_update( new_interface_found = update_interfaces(NTP_PORT, receiver, data); UNBLOCKIO(); - if (!new_interface_found) + if (!new_interface_found) { return; - + } #ifdef DEBUG msyslog(LOG_DEBUG, "new interface(s) found: waking up resolver"); #endif @@ -1803,14 +1804,14 @@ update_interfaces( sys_interphase ^= 0x1; for (result = isc_interfaceiter_first(iter); - ISC_R_SUCCESS == result; - result = isc_interfaceiter_next(iter)) { + ISC_R_SUCCESS == result; + result = isc_interfaceiter_next(iter)) { result = isc_interfaceiter_current(iter, &isc_if); - if (result != ISC_R_SUCCESS) + if (result != ISC_R_SUCCESS) { break; - + } /* See if we have a valid family to use */ family = isc_if.address.family; if (AF_INET != family && AF_INET6 != family) @@ -1958,8 +1959,9 @@ update_interfaces( ifi.action = IFS_EXISTS; ifi.ep = ep; - if (receiver != NULL) + if (receiver != NULL) { (*receiver)(data, &ifi); + } } else { /* * This is new or refreshing failed - add to @@ -2020,20 +2022,20 @@ update_interfaces( ifi.action = IFS_DELETED; ifi.ep = ep; - if (receiver != NULL) + if (receiver != NULL) { (*receiver)(data, &ifi); - + } /* disconnect peers from deleted endpt. */ - while (ep->peers != NULL) + while (ep->peers != NULL) { set_peerdstadr(ep->peers, NULL); - + } /* * update globals in case we lose * a loopback interface */ - if (ep == loopback_interface) + if (ep == loopback_interface) { loopback_interface = NULL; - + } delete_interface(ep); } @@ -2045,9 +2047,9 @@ update_interfaces( */ refresh_all_peerinterfaces(); - if (sys_bclient) + if (sys_bclient) { io_setbclient(); - + } #ifdef MCAST /* * Check multicast interfaces and try to join multicast groups if @@ -2056,9 +2058,9 @@ update_interfaces( for (ep = ep_list; ep != NULL; ep = ep->elink) { remaddr_t *entry; - if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags)) + if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags)) { continue; - + } /* Find remote address that was linked to this interface */ for (entry = remoteaddr_list; entry != NULL; @@ -4192,8 +4194,12 @@ findlocalinterface( iface = findclosestinterface(&saddr, flags | INT_LOOPBACK); } - /* Don't use an interface which will ignore replies */ - if (iface != NULL && iface->ignore_packets) { + /* + * Don't select an interface which will ignore replies, or one + * dedicated to multicast receive. + */ + if ( iface != NULL + && (iface->ignore_packets || (INT_MCASTIF & iface->flags))) { iface = NULL; } return iface;