Blob Blame History Raw
From 165561df9ba1e0be2a11ff550b70da94990eb2f5 Mon Sep 17 00:00:00 2001
From: Christine Caulfield <ccaulfie@redhat.com>
Date: Mon, 16 Nov 2015 16:00:36 +0000
Subject: [PATCH] totemudp: Move udp bind() so that multicast works with IPv6

It seems that the IPv6 multicast parameters only take effect when bind()
is called, so I've moved the mcast recv socket bind() to the bottom of
totemudp_build_sockets_ip().

Signed-off-by: Christine Caulfield <ccaulfie@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
---
 exec/totemudp.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/exec/totemudp.c b/exec/totemudp.c
index 8ed87ce..31d0570 100644
--- a/exec/totemudp.c
+++ b/exec/totemudp.c
@@ -761,18 +761,6 @@ static int totemudp_build_sockets_ip (
 	}
 
 	/*
-	 * Bind to multicast socket used for multicast receives
-	 */
-	totemip_totemip_to_sockaddr_convert(mcast_address,
-		instance->totem_interface->ip_port, &sockaddr, &addrlen);
-	res = bind (sockets->mcast_recv, (struct sockaddr *)&sockaddr, addrlen);
-	if (res == -1) {
-		LOGSYS_PERROR (errno, instance->totemudp_log_level_warning,
-				"Unable to bind the socket to receive multicast packets");
-		return (-1);
-	}
-
-	/*
 	 * Create local multicast loop socket
 	 */
 	if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sockets->local_mcast_loop) == -1) {
@@ -1054,6 +1042,20 @@ static int totemudp_build_sockets_ip (
 		break;
 	}
 
+	/*
+	 * Bind to multicast socket used for multicast receives
+	 * This needs to happen after all of the multicast setsockopt() calls
+	 * as the kernel seems to only put them into effect (for IPV6) when bind()
+	 * is called.
+	 */
+	totemip_totemip_to_sockaddr_convert(mcast_address,
+		instance->totem_interface->ip_port, &sockaddr, &addrlen);
+	res = bind (sockets->mcast_recv, (struct sockaddr *)&sockaddr, addrlen);
+	if (res == -1) {
+		LOGSYS_PERROR (errno, instance->totemudp_log_level_warning,
+				"Unable to bind the socket to receive multicast packets");
+		return (-1);
+	}
 	return 0;
 }
 
-- 
1.7.1