Blame SOURCES/ntp-4.2.6p5-mcastjoin.patch

6d3098
diff -up ntp-4.2.6p5/ntpd/ntp_io.c.mcastjoin ntp-4.2.6p5/ntpd/ntp_io.c
6d3098
--- ntp-4.2.6p5/ntpd/ntp_io.c.mcastjoin	2015-04-13 14:41:59.108323479 +0200
6d3098
+++ ntp-4.2.6p5/ntpd/ntp_io.c	2015-04-13 14:43:46.468637433 +0200
6d3098
@@ -2038,6 +2038,32 @@ update_interfaces(
6d3098
 	if (sys_bclient)
6d3098
 		io_setbclient();
6d3098
 
6d3098
+	/*
6d3098
+	 * Check multicast interfaces and try to join multicast groups if
6d3098
+	 * not joined yet.
6d3098
+	 */
6d3098
+	for (ep = ep_list; ep != NULL; ep = ep->elink) {
6d3098
+		remaddr_t *entry;
6d3098
+
6d3098
+		if (!(INT_MCASTIF & ep->flags) || (INT_MCASTOPEN & ep->flags))
6d3098
+			continue;
6d3098
+
6d3098
+		/* Find remote address that was linked to this interface */
6d3098
+		for (entry = remoteaddr_list;
6d3098
+		     entry != NULL;
6d3098
+		     entry = entry->link) {
6d3098
+			if (entry->ep == ep) {
6d3098
+				if (socket_multicast_enable(ep, &entry->addr)) {
6d3098
+					msyslog(LOG_INFO,
6d3098
+						"Joined %s socket to multicast group %s",
6d3098
+						stoa(&ep->sin),
6d3098
+						stoa(&entry->addr));
6d3098
+				}
6d3098
+				break;
6d3098
+			}
6d3098
+		}
6d3098
+	}
6d3098
+
6d3098
 	return new_interface_found;
6d3098
 }
6d3098
 
6d3098
@@ -2467,12 +2493,12 @@ socket_multicast_enable(
6d3098
 			       IP_ADD_MEMBERSHIP,
6d3098
 			       (char *)&mreq, 
6d3098
 			       sizeof(mreq))) {
6d3098
-			msyslog(LOG_ERR,
6d3098
+			DPRINTF(2, (
6d3098
 				"setsockopt IP_ADD_MEMBERSHIP failed: %m on socket %d, addr %s for %x / %x (%s)",
6d3098
 				iface->fd, stoa(&iface->sin),
6d3098
 				mreq.imr_multiaddr.s_addr,
6d3098
 				mreq.imr_interface.s_addr,
6d3098
-				stoa(maddr));
6d3098
+				stoa(maddr)));
6d3098
 			return ISC_FALSE;
6d3098
 		}
6d3098
 		DPRINTF(4, ("Added IPv4 multicast membership on socket %d, addr %s for %x / %x (%s)\n",
6d3098
@@ -2497,10 +2523,10 @@ socket_multicast_enable(
6d3098
 		if (setsockopt(iface->fd, IPPROTO_IPV6,
6d3098
 			       IPV6_JOIN_GROUP, (char *)&mreq6, 
6d3098
 			       sizeof(mreq6))) {
6d3098
-			msyslog(LOG_ERR,
6d3098
+			DPRINTF(2, (
6d3098
 				"setsockopt IPV6_JOIN_GROUP failed: %m on socket %d, addr %s for interface %u (%s)",
6d3098
 				iface->fd, stoa(&iface->sin),
6d3098
-				mreq6.ipv6mr_interface, stoa(maddr));
6d3098
+				mreq6.ipv6mr_interface, stoa(maddr)));
6d3098
 			return ISC_FALSE;
6d3098
 		}
6d3098
 		DPRINTF(4, ("Added IPv6 multicast group on socket %d, addr %s for interface %u (%s)\n",
6d3098
@@ -2793,11 +2819,6 @@ io_multicast_add(
6d3098
 				"Joined %s socket to multicast group %s",
6d3098
 				stoa(&ep->sin),
6d3098
 				stoa(addr));
6d3098
-		else
6d3098
-			msyslog(LOG_ERR,
6d3098
-				"Failed to join %s socket to multicast group %s",
6d3098
-				stoa(&ep->sin),
6d3098
-				stoa(addr));
6d3098
 	}
6d3098
 
6d3098
 	add_addr_to_list(addr, one_ep);