|
@@ -850,7 +850,7 @@ static int get_cluster_mcast_addr (
|
|
|
return (err);
|
|
return (err);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static unsigned int generate_nodeid_for_duplicate_test(
|
|
|
|
|
|
|
+static unsigned int generate_nodeid(
|
|
|
struct totem_config *totem_config,
|
|
struct totem_config *totem_config,
|
|
|
char *addr)
|
|
char *addr)
|
|
|
{
|
|
{
|
|
@@ -888,6 +888,7 @@ static int check_for_duplicate_nodeids(
|
|
|
char *ring0_addr1=NULL;
|
|
char *ring0_addr1=NULL;
|
|
|
unsigned int node_pos;
|
|
unsigned int node_pos;
|
|
|
unsigned int node_pos1;
|
|
unsigned int node_pos1;
|
|
|
|
|
+ unsigned int last_node_pos = -1;
|
|
|
unsigned int nodeid;
|
|
unsigned int nodeid;
|
|
|
unsigned int nodeid1;
|
|
unsigned int nodeid1;
|
|
|
int autogenerated;
|
|
int autogenerated;
|
|
@@ -899,9 +900,15 @@ static int check_for_duplicate_nodeids(
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (strcmp(tmp_key, "nodeid") != 0) {
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ * This relies on the fact the icmap keys are always returned in order
|
|
|
|
|
+ * so all of the keys for a node will be grouped together. We're basically
|
|
|
|
|
+ * just running the code below once for each node.
|
|
|
|
|
+ */
|
|
|
|
|
+ if (last_node_pos == node_pos) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ last_node_pos = node_pos;
|
|
|
|
|
|
|
|
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
|
|
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
|
|
|
autogenerated = 0;
|
|
autogenerated = 0;
|
|
@@ -915,7 +922,7 @@ static int check_for_duplicate_nodeids(
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Generate nodeid so we can check that auto-generated nodeids don't clash either */
|
|
/* Generate nodeid so we can check that auto-generated nodeids don't clash either */
|
|
|
- nodeid = generate_nodeid_for_duplicate_test(totem_config, ring0_addr);
|
|
|
|
|
|
|
+ nodeid = generate_nodeid(totem_config, ring0_addr);
|
|
|
if (nodeid == -1) {
|
|
if (nodeid == -1) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -941,7 +948,7 @@ static int check_for_duplicate_nodeids(
|
|
|
if (icmap_get_string(tmp_key, &ring0_addr1) != CS_OK) {
|
|
if (icmap_get_string(tmp_key, &ring0_addr1) != CS_OK) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- nodeid1 = generate_nodeid_for_duplicate_test(totem_config, ring0_addr1);
|
|
|
|
|
|
|
+ nodeid1 = generate_nodeid(totem_config, ring0_addr1);
|
|
|
if (nodeid1 == -1) {
|
|
if (nodeid1 == -1) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -1170,6 +1177,7 @@ static void put_nodelist_members_to_config(struct totem_config *totem_config, in
|
|
|
int member_count;
|
|
int member_count;
|
|
|
unsigned int linknumber = 0;
|
|
unsigned int linknumber = 0;
|
|
|
int i, j;
|
|
int i, j;
|
|
|
|
|
+ int last_node_pos = -1;
|
|
|
struct totem_interface *new_interfaces = NULL;
|
|
struct totem_interface *new_interfaces = NULL;
|
|
|
|
|
|
|
|
if (reload) {
|
|
if (reload) {
|
|
@@ -1196,17 +1204,21 @@ static void put_nodelist_members_to_config(struct totem_config *totem_config, in
|
|
|
if (res != 2) {
|
|
if (res != 2) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if (strcmp(tmp_key, "nodeid") != 0) {
|
|
|
|
|
|
|
+ /* If it's the same as the last node_pos then skip it */
|
|
|
|
|
+ if (node_pos == last_node_pos) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
+ last_node_pos = node_pos;
|
|
|
|
|
|
|
|
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
|
|
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
|
|
|
iter2 = icmap_iter_init(tmp_key);
|
|
iter2 = icmap_iter_init(tmp_key);
|
|
|
while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
|
|
while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
|
|
|
unsigned int nodeid;
|
|
unsigned int nodeid;
|
|
|
|
|
+ char *str;
|
|
|
|
|
|
|
|
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
|
|
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
|
|
|
if (icmap_get_uint32(tmp_key, &nodeid) != CS_OK) {
|
|
if (icmap_get_uint32(tmp_key, &nodeid) != CS_OK) {
|
|
|
|
|
+ nodeid = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
res = sscanf(iter_key2, "nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
|
|
res = sscanf(iter_key2, "nodelist.node.%u.ring%u%s", &node_pos, &linknumber, tmp_key2);
|
|
@@ -1218,6 +1230,19 @@ static void put_nodelist_members_to_config(struct totem_config *totem_config, in
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /* Generate nodeids if they are not provided and transport is UDP/U */
|
|
|
|
|
+ if (!nodeid &&
|
|
|
|
|
+ (totem_config->transport_number == TOTEM_TRANSPORT_UDP ||
|
|
|
|
|
+ totem_config->transport_number == TOTEM_TRANSPORT_UDPU)) {
|
|
|
|
|
+ snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", node_pos);
|
|
|
|
|
+ if (icmap_get_string(tmp_key, &str) == CS_OK) {
|
|
|
|
|
+ nodeid = generate_nodeid(totem_config, str);
|
|
|
|
|
+ free(str);
|
|
|
|
|
+ log_printf(LOGSYS_LEVEL_DEBUG,
|
|
|
|
|
+ "Generated nodeid = 0x%x for %s\n", nodeid, str);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
member_count = totem_config->interfaces[linknumber].member_count;
|
|
member_count = totem_config->interfaces[linknumber].member_count;
|
|
|
res = totemip_parse(&totem_config->interfaces[linknumber].member_list[member_count],
|
|
res = totemip_parse(&totem_config->interfaces[linknumber].member_list[member_count],
|
|
|
node_addr_str, totem_config->ip_version);
|
|
node_addr_str, totem_config->ip_version);
|
|
@@ -1689,6 +1714,18 @@ extern int totem_config_read (
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if ((totem_config->transport_number == TOTEM_TRANSPORT_UDP ||
|
|
|
|
|
+ totem_config->transport_number == TOTEM_TRANSPORT_UDPU) && (!totem_config->node_id)) {
|
|
|
|
|
+
|
|
|
|
|
+ snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.ring0_addr", local_node_pos);
|
|
|
|
|
+ icmap_get_string(tmp_key, &str);
|
|
|
|
|
+
|
|
|
|
|
+ totem_config->node_id = generate_nodeid(totem_config, str);
|
|
|
|
|
+ totem_config->interfaces[0].member_list[local_node_pos].nodeid = totem_config->node_id;
|
|
|
|
|
+
|
|
|
|
|
+ free(str);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/* Users must not change this */
|
|
/* Users must not change this */
|
|
|
icmap_set_ro_access("nodelist.local_node_pos", 0, 1);
|
|
icmap_set_ro_access("nodelist.local_node_pos", 0, 1);
|
|
|
}
|
|
}
|