Bladeren bron

Add option to specify ip version

Default is ipv4.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
(cherry picked from commit dd588d004e309d689482ec77505cd526a246bf49)
Jan Friesse 13 jaren geleden
bovenliggende
commit
6e74a2e89d
5 gewijzigde bestanden met toevoegingen van 43 en 9 verwijderingen
  1. 8 0
      exec/coroparse.c
  2. 7 2
      exec/main.c
  3. 20 7
      exec/totemconfig.c
  4. 2 0
      include/corosync/totem/totem.h
  5. 6 0
      man/corosync.conf.5

+ 8 - 0
exec/coroparse.c

@@ -501,6 +501,14 @@ static int main_config_parser_cb(const char *path,
 				icmap_set_uint64(path, ull);
 				add_as_string = 0;
 			}
+			if (strcmp(path, "totem.ip_version") == 0) {
+				if ((strcmp(value, "ipv4") != 0) &&
+				    (strcmp(value, "ipv6") != 0)) {
+					*error_string = "Invalid ip_version type";
+
+					return (0);
+				}
+			}
 			if (strcmp(path, "totem.crypto_type") == 0) {
 				if ((strcmp(value, "nss") != 0) &&
 				    (strcmp(value, "aes256") != 0) &&

+ 7 - 2
exec/main.c

@@ -154,6 +154,8 @@ static corosync_timer_handle_t corosync_stats_timer_handle;
 
 static const char *corosync_lock_file = LOCALSTATEDIR"/run/corosync.pid";
 
+static int ip_version = AF_INET;
+
 qb_loop_t *cs_poll_handle_get (void)
 {
 	return (corosync_poll_handle);
@@ -592,7 +594,7 @@ static void totem_dynamic_notify(
 	if (remove_old_member) {
 		log_printf(LOGSYS_LEVEL_DEBUG,
 			"removing dynamic member %s for ring %u", (char *)old_val.data, ring_no);
-		if (totemip_parse(&member, (char *)old_val.data, 0) == 0) {
+		if (totemip_parse(&member, (char *)old_val.data, ip_version) == 0) {
 			totempg_member_remove (&member, ring_no);
 		}
 	}
@@ -600,7 +602,7 @@ static void totem_dynamic_notify(
 	if (add_new_member) {
 		log_printf(LOGSYS_LEVEL_DEBUG,
 			"adding dynamic member %s for ring %u", (char *)new_val.data, ring_no);
-		if (totemip_parse(&member, (char *)new_val.data, 0) == 0) {
+		if (totemip_parse(&member, (char *)new_val.data, ip_version) == 0) {
 			totempg_member_add (&member, ring_no);
 		}
 	}
@@ -912,6 +914,7 @@ static void set_icmap_ro_keys_flag (void)
 	icmap_set_ro_access("totem.crypto_cipher", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.crypto_hash", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.secauth", CS_FALSE, CS_TRUE);
+	icmap_set_ro_access("totem.ip_version", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.rrp_mode", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.netmtu", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("qb.ipc_type", CS_FALSE, CS_TRUE);
@@ -1176,6 +1179,8 @@ int main (int argc, char **argv, char **envp)
 		corosync_exit_error (COROSYNC_DONE_MAINCONFIGREAD);
 	}
 
+	ip_version = totem_config.ip_version;
+
 	totem_config.totem_logging_configuration = totem_logging_configuration;
 	totem_config.totem_logging_configuration.log_subsys_id = _logsys_subsys_create("TOTEM", "totem");
 	totem_config.totem_logging_configuration.log_level_security = LOGSYS_LEVEL_WARNING;

+ 20 - 7
exec/totemconfig.c

@@ -196,6 +196,7 @@ static int get_cluster_mcast_addr (
 		const char *cluster_name,
 		const struct totem_ip_address *bindnet,
 		unsigned int ringnumber,
+		int ip_version,
 		struct totem_ip_address *res)
 {
 	uint16_t clusterid;
@@ -223,7 +224,7 @@ static int get_cluster_mcast_addr (
 		return (-1);
 	}
 
-	err = totemip_parse (res, addr, 0);
+	err = totemip_parse (res, addr, ip_version);
 
 	return (err);
 }
@@ -264,7 +265,7 @@ static int find_local_node_in_nodelist(struct totem_config *totem_config)
 			continue;
 		}
 
-		res = totemip_parse (&node_addr, node_addr_str, 0);
+		res = totemip_parse (&node_addr, node_addr_str, totem_config->ip_version);
 		free(node_addr_str);
 		if (res == -1) {
 			continue ;
@@ -317,7 +318,7 @@ static void put_nodelist_members_to_config(struct totem_config *totem_config)
 			member_count = totem_config->interfaces[ringnumber].member_count;
 
 			res = totemip_parse(&totem_config->interfaces[ringnumber].member_list[member_count],
-						node_addr_str, 0);
+						node_addr_str, totem_config->ip_version);
 			if (res != -1) {
 				totem_config->interfaces[ringnumber].member_count++;
 			}
@@ -365,7 +366,7 @@ static void config_convert_nodelist_to_interface(struct totem_config *totem_conf
 			continue ;
 		}
 
-		if (totemip_parse(&node_addr, node_addr_str, 0) == -1) {
+		if (totemip_parse(&node_addr, node_addr_str, totem_config->ip_version) == -1) {
 			free(node_addr_str);
 			continue ;
 		}
@@ -476,6 +477,17 @@ extern int totem_config_read (
 
 	icmap_get_string("totem.cluster_name", &cluster_name);
 
+	totem_config->ip_version = AF_INET;
+	if (icmap_get_string("totem.ip_version", &str) == CS_OK) {
+		if (strcmp(str, "ipv4") == 0) {
+			totem_config->ip_version = AF_INET;
+		}
+		if (strcmp(str, "ipv6") == 0) {
+			totem_config->ip_version = AF_INET6;
+		}
+		free(str);
+	}
+
 	/*
 	 * Get things that might change in the future
 	 */
@@ -528,7 +540,7 @@ extern int totem_config_read (
 		 */
 		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.mcastaddr", ringnumber);
 		if (icmap_get_string(tmp_key, &str) == CS_OK) {
-			res = totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr, str, 0);
+			res = totemip_parse (&totem_config->interfaces[ringnumber].mcast_addr, str, totem_config->ip_version);
 			free(str);
 		} else {
 			/*
@@ -538,6 +550,7 @@ extern int totem_config_read (
 			res = get_cluster_mcast_addr (cluster_name,
 					&totem_config->interfaces[ringnumber].bindnet,
 					ringnumber,
+					totem_config->ip_version,
 					&totem_config->interfaces[ringnumber].mcast_addr);
 		}
 
@@ -548,7 +561,7 @@ extern int totem_config_read (
 				totem_config->broadcast_use = 1;
 				totemip_parse (
 					&totem_config->interfaces[ringnumber].mcast_addr,
-					"255.255.255.255", 0);
+					"255.255.255.255", totem_config->ip_version);
 			}
 			free(str);
 		}
@@ -591,7 +604,7 @@ extern int totem_config_read (
 
 			if (icmap_get_string(member_iter_key, &str) == CS_OK) {
 				res = totemip_parse (&totem_config->interfaces[ringnumber].member_list[member_count++],
-						str, 0);
+						str, totem_config->ip_version);
 			}
 		}
 		icmap_iter_finalize(member_iter);

+ 2 - 0
include/corosync/totem/totem.h

@@ -179,6 +179,8 @@ struct totem_config {
 	totem_transport_t transport_number;
 
 	unsigned int miss_count_const;
+
+	int ip_version;
 };
 
 #define TOTEM_CONFIGURATION_TYPE

+ 6 - 0
man/corosync.conf.5

@@ -274,6 +274,12 @@ from single-node membership to multiple nodes membership, other nodes
 config_versions are collected. If current node config_version is not
 equal to highest of collected versions, corosync is terminated.
 
+.TP
+ip_version
+Specifies version of IP to use for communication. Value can be one of
+ipv4 or ipv6. Default (if unspecified) is ipv4.
+
+
 Within the
 .B totem
 directive, there are several configuration options which are used to control