[PATCH 1/2] Add option to specify ip version

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Default is ipv4.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/coroparse.c               |    8 ++++++++
 exec/main.c                    |    9 +++++++--
 exec/totemconfig.c             |   27 ++++++++++++++++++++-------
 include/corosync/totem/totem.h |    2 ++
 man/corosync.conf.5            |    6 ++++++
 5 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/exec/coroparse.c b/exec/coroparse.c
index fceafa8..d5a50bb 100644
--- a/exec/coroparse.c
+++ b/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) &&
diff --git a/exec/main.c b/exec/main.c
index 7d74bf3..abd8fbd 100644
--- a/exec/main.c
+++ b/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);
 		}
 	}
@@ -913,6 +915,7 @@ static void set_icmap_ro_keys_flag (void)
 	icmap_set_ro_access("totem.crypto_hash", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.crypto_compat", 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);
@@ -1177,6 +1180,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;
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index e1badad..fc833f5 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -210,6 +210,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;
@@ -237,7 +238,7 @@ static int get_cluster_mcast_addr (
 		return (-1);
 	}
 
-	err = totemip_parse (res, addr, 0);
+	err = totemip_parse (res, addr, ip_version);
 
 	return (err);
 }
@@ -278,7 +279,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 ;
@@ -331,7 +332,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++;
 			}
@@ -379,7 +380,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 ;
 		}
@@ -490,6 +491,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
 	 */
@@ -542,7 +554,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 {
 			/*
@@ -552,6 +564,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);
 		}
 
@@ -562,7 +575,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);
 		}
@@ -605,7 +618,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);
diff --git a/include/corosync/totem/totem.h b/include/corosync/totem/totem.h
index 384d5b0..7ef8652 100644
--- a/include/corosync/totem/totem.h
+++ b/include/corosync/totem/totem.h
@@ -181,6 +181,8 @@ struct totem_config {
 	totem_transport_t transport_number;
 
 	unsigned int miss_count_const;
+
+	int ip_version;
 };
 
 #define TOTEM_CONFIGURATION_TYPE
diff --git a/man/corosync.conf.5 b/man/corosync.conf.5
index 8c353ec..43a339b 100644
--- a/man/corosync.conf.5
+++ b/man/corosync.conf.5
@@ -287,6 +287,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
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss


[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux