return (err);
}
-static unsigned int generate_nodeid_for_duplicate_test(
+static unsigned int generate_nodeid(
struct totem_config *totem_config,
char *addr)
{
char *ring0_addr1=NULL;
unsigned int node_pos;
unsigned int node_pos1;
+ unsigned int last_node_pos = -1;
unsigned int nodeid;
unsigned int nodeid1;
int autogenerated;
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;
}
+ last_node_pos = node_pos;
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
autogenerated = 0;
}
/* 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) {
continue;
}
if (icmap_get_string(tmp_key, &ring0_addr1) != CS_OK) {
continue;
}
- nodeid1 = generate_nodeid_for_duplicate_test(totem_config, ring0_addr1);
+ nodeid1 = generate_nodeid(totem_config, ring0_addr1);
if (nodeid1 == -1) {
continue;
}
int member_count;
unsigned int linknumber = 0;
int i, j;
+ int last_node_pos = -1;
struct totem_interface *new_interfaces = NULL;
if (reload) {
if (res != 2) {
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;
}
+ last_node_pos = node_pos;
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
iter2 = icmap_iter_init(tmp_key);
while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
unsigned int nodeid;
+ char *str;
snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.nodeid", node_pos);
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);
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;
res = totemip_parse(&totem_config->interfaces[linknumber].member_list[member_count],
node_addr_str, totem_config->ip_version);
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 */
icmap_set_ro_access("nodelist.local_node_pos", 0, 1);
}