ソースを参照

totemconfig: Explicitly pass IP version

If resolver was set to prefer IPv6 (almost always) and interface section
was not defined (almost all config files created by pcs), IP version was
set to mcast_addr.family. Because mcast_addr.family was unset (reset to
zero), IPv6 address was returned causing failure in totemsrp.
Solution is to pass correct IP version stored in
totem_config->ip_version.

Patch also simplifies get_cluster_mcast_addr. It was using mix of
explicitly passed IP version and bindnet IP version.

Also return value of get_cluster_mcast_addr is now properly checked.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 10 年 前
コミット
60565b7da7
1 ファイル変更6 行追加4 行削除
  1. 6 4
      exec/totemconfig.c

+ 6 - 4
exec/totemconfig.c

@@ -446,7 +446,6 @@ static uint16_t generate_cluster_id (const char *cluster_name)
 
 
 static int get_cluster_mcast_addr (
 static int get_cluster_mcast_addr (
 		const char *cluster_name,
 		const char *cluster_name,
-		const struct totem_ip_address *bindnet,
 		unsigned int ringnumber,
 		unsigned int ringnumber,
 		int ip_version,
 		int ip_version,
 		struct totem_ip_address *res)
 		struct totem_ip_address *res)
@@ -462,7 +461,7 @@ static int get_cluster_mcast_addr (
 	clusterid = generate_cluster_id(cluster_name) + ringnumber;
 	clusterid = generate_cluster_id(cluster_name) + ringnumber;
 	memset (res, 0, sizeof(*res));
 	memset (res, 0, sizeof(*res));
 
 
-	switch (bindnet->family) {
+	switch (ip_version) {
 	case AF_INET:
 	case AF_INET:
 		snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
 		snprintf(addr, sizeof(addr), "239.192.%d.%d", clusterid >> 8, clusterid % 0xFF);
 		break;
 		break;
@@ -1088,7 +1087,7 @@ extern int totem_config_read (
 		 */
 		 */
 		if (icmap_get_string(iter_key, &str) == CS_OK) {
 		if (icmap_get_string(iter_key, &str) == CS_OK) {
 			res = totemip_parse (&totem_config->interfaces[ringnumber].bindnet, str,
 			res = totemip_parse (&totem_config->interfaces[ringnumber].bindnet, str,
-						     totem_config->interfaces[ringnumber].mcast_addr.family);
+			    totem_config->ip_version);
 			free(str);
 			free(str);
 		}
 		}
 
 
@@ -1105,10 +1104,13 @@ extern int totem_config_read (
 			 * (if available)
 			 * (if available)
 			 */
 			 */
 			res = get_cluster_mcast_addr (cluster_name,
 			res = get_cluster_mcast_addr (cluster_name,
-					&totem_config->interfaces[ringnumber].bindnet,
 					ringnumber,
 					ringnumber,
 					totem_config->ip_version,
 					totem_config->ip_version,
 					&totem_config->interfaces[ringnumber].mcast_addr);
 					&totem_config->interfaces[ringnumber].mcast_addr);
+			if (res != 0) {
+				*error_string = "Can't autogenerate multicast address";
+				return -1;
+			}
 		}
 		}
 
 
 		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", ringnumber);
 		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.broadcast", ringnumber);