]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
[Bug 2805] ntpd fails to join multicast group
authorHarlan Stenn <stenn@ntp.org>
Wed, 29 Apr 2015 07:03:32 +0000 (07:03 +0000)
committerHarlan Stenn <stenn@ntp.org>
Wed, 29 Apr 2015 07:03:32 +0000 (07:03 +0000)
bk: 55408244USR-8-SgdNLmtp0tN6xNmQ

ChangeLog
ntpd/ntp_io.c

index 5ddb578ed81b121af248a68d3dae13c04beafc5d..bab8c456677b131c3cf9a0efdd07f3e801928d99 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
 * [Bug 2800] refclock_true.c true_debug() can't open debug log because
   of incompatible open/fdopen parameters.
 * [Bug 2804] install-local-data assumes GNU 'find' semantics.
+* [Bug 2805] ntpd fails to join multicast group.
 * [Bug 2808] GPSD_JSON driver enhancements, step 1.
   Various improvements, see http://bugs.ntp.org/2808 for details.
   Changed libjsmn to a more recent version.
index 1ee7098ae16438423f1e4b3d2044fbfaf2baf173..bf146283ec161ac573bb71faceef66be059f5bee 100644 (file)
@@ -2009,6 +2009,32 @@ update_interfaces(
        if (sys_bclient)
                io_setbclient();
 
+       /*
+        * Check multicast interfaces and try to join multicast groups if
+         * not joined yet.
+         */
+       for (ep = ep_list; ep != NULL; ep = ep->elink) {
+               remaddr_t *entry;
+
+               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;
+                    entry = entry->link) {
+                       if (entry->ep == ep) {
+                               if (socket_multicast_enable(ep, &entry->addr)) {
+                                       msyslog(LOG_INFO, 
+                                               "Joined %s socket to multicast group %s",
+                                               stoa(&ep->sin),
+                                               stoa(&entry->addr));
+                               }
+                               break;
+                       }
+               }
+       }
+
        return new_interface_found;
 }
 
@@ -2432,12 +2458,12 @@ socket_multicast_enable(
                               IP_ADD_MEMBERSHIP,
                               (char *)&mreq,
                               sizeof(mreq))) {
-                       msyslog(LOG_ERR,
+                       DPRINTF(2, (
                                "setsockopt IP_ADD_MEMBERSHIP failed: %m on socket %d, addr %s for %x / %x (%s)",
                                iface->fd, stoa(&iface->sin),
                                mreq.imr_multiaddr.s_addr,
                                mreq.imr_interface.s_addr,
-                               stoa(maddr));
+                               stoa(maddr)));
                        return ISC_FALSE;
                }
                DPRINTF(4, ("Added IPv4 multicast membership on socket %d, addr %s for %x / %x (%s)\n",
@@ -2462,10 +2488,10 @@ socket_multicast_enable(
                if (setsockopt(iface->fd, IPPROTO_IPV6,
                               IPV6_JOIN_GROUP, (char *)&mreq6,
                               sizeof(mreq6))) {
-                       msyslog(LOG_ERR,
+                       DPRINTF(2, (
                                "setsockopt IPV6_JOIN_GROUP failed: %m on socket %d, addr %s for interface %u (%s)",
                                iface->fd, stoa(&iface->sin),
-                               mreq6.ipv6mr_interface, stoa(maddr));
+                               mreq6.ipv6mr_interface, stoa(maddr)));
                        return ISC_FALSE;
                }
                DPRINTF(4, ("Added IPv6 multicast group on socket %d, addr %s for interface %u (%s)\n",
@@ -2767,11 +2793,6 @@ io_multicast_add(
                                "Joined %s socket to multicast group %s",
                                stoa(&ep->sin),
                                stoa(addr));
-               else
-                       msyslog(LOG_ERR,
-                               "Failed to join %s socket to multicast group %s",
-                               stoa(&ep->sin),
-                               stoa(addr));
        }
 
        add_addr_to_list(addr, one_ep);