Browse Source

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>
Christine Caulfield 10 năm trước cách đây
mục cha
commit
165561df9b
1 tập tin đã thay đổi với 14 bổ sung12 xóa
  1. 14 12
      exec/totemudp.c

+ 14 - 12
exec/totemudp.c

@@ -760,18 +760,6 @@ static int totemudp_build_sockets_ip (
 		return (-1);
 		return (-1);
 	}
 	}
 
 
-	/*
-	 * 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
 	 * Create local multicast loop socket
 	 */
 	 */
@@ -1054,6 +1042,20 @@ static int totemudp_build_sockets_ip (
 		break;
 		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;
 	return 0;
 }
 }