return public_ips;
}
-static bool all_nodes_are_disabled(struct ctdb_node_map_old *nodemap)
+static bool all_nodes_are_disabled(struct ctdb_node_map *nodemap)
{
int i;
for (i=0;i<nodemap->num;i++) {
- if (!(nodemap->nodes[i].flags & (NODE_FLAGS_INACTIVE|NODE_FLAGS_DISABLED))) {
+ if (!(nodemap->node[i].flags &
+ (NODE_FLAGS_INACTIVE|NODE_FLAGS_DISABLED))) {
/* Found one completely healthy node */
return false;
}
* Set NOIPHOST ip flags for disabled nodes
*/
static void set_ipflags_internal(struct ipalloc_state *ipalloc_state,
- struct ctdb_node_map_old *nodemap,
+ struct ctdb_node_map *nodemap,
uint32_t *tval_noiptakeover,
uint32_t *tval_noiphostonalldisabled)
{
}
/* Can not host IPs on INACTIVE node */
- if (nodemap->nodes[i].flags & NODE_FLAGS_INACTIVE) {
+ if (nodemap->node[i].flags & NODE_FLAGS_INACTIVE) {
ipalloc_state->noiphost[i] = true;
}
}
* IPs on DISABLED node
*/
for (i=0;i<nodemap->num;i++) {
- if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) {
+ if (nodemap->node[i].flags & NODE_FLAGS_DISABLED) {
ipalloc_state->noiphost[i] = true;
}
}
}
}
+static struct ctdb_node_map *
+ctdb_node_map_old_to_new(TALLOC_CTX *mem_ctx,
+ const struct ctdb_node_map_old *old)
+{
+ struct ctdb_node_map *new;
+
+ new = talloc(mem_ctx, struct ctdb_node_map);
+ if (new == NULL) {
+ DEBUG(DEBUG_ERR, (__location__ " out of memory\n"));
+ return NULL;
+ }
+ new->num = old->num;
+ new->node = talloc_zero_array(new,
+ struct ctdb_node_and_flags, new->num);
+ memcpy(new->node, &old->nodes[0],
+ sizeof(struct ctdb_node_and_flags) * new->num);
+
+ return new;
+}
+
+
static bool set_ipflags(struct ctdb_context *ctdb,
struct ipalloc_state *ipalloc_state,
struct ctdb_node_map_old *nodemap)
{
uint32_t *tval_noiptakeover;
uint32_t *tval_noiphostonalldisabled;
+ struct ctdb_node_map *new;
tval_noiptakeover = get_tunable_from_nodes(ctdb, ipalloc_state, nodemap,
"NoIPTakeover", 0);
return false;
}
- set_ipflags_internal(ipalloc_state, nodemap,
+ new = ctdb_node_map_old_to_new(ipalloc_state, nodemap);
+ if (new == NULL) {
+ return false;
+ }
+
+ set_ipflags_internal(ipalloc_state, new,
tval_noiptakeover,
tval_noiphostonalldisabled);
talloc_free(tval_noiptakeover);
talloc_free(tval_noiphostonalldisabled);
+ talloc_free(new);
return true;
}
struct ctdb_public_ip_list *avail;
int i;
char *tok, *ns, *t;
- struct ctdb_node_map_old *nodemap;
+ struct ctdb_node_map *nodemap;
uint32_t *tval_noiptakeover;
uint32_t *tval_noiptakeoverondisabled;
ctdb_sock_addr sa_zero = { .ip = { 0 } };
/* Avoid that const */
ns = talloc_strdup(*ctdb, nodestates);
- nodemap = talloc_zero(*ctdb, struct ctdb_node_map_old);
+ nodemap = talloc_zero(*ctdb, struct ctdb_node_map);
assert(nodemap != NULL);
nodemap->num = 0;
tok = strtok(ns, ",");
while (tok != NULL) {
uint32_t n = nodemap->num;
- size_t size =
- offsetof(struct ctdb_node_map_old, nodes) +
- (n + 1) * sizeof(struct ctdb_node_and_flags);
- nodemap = talloc_realloc_size(*ctdb, nodemap, size);
- nodemap->nodes[n].pnn = n;
- nodemap->nodes[n].flags = (uint32_t) strtol(tok, NULL, 0);
- nodemap->nodes[n].addr = sa_zero;
+ nodemap->node = talloc_realloc(nodemap, nodemap->node,
+ struct ctdb_node_and_flags, n+1);
+ nodemap->node[n].pnn = n;
+ nodemap->node[n].flags = (uint32_t) strtol(tok, NULL, 0);
+ nodemap->node[n].addr = sa_zero;
nodemap->num++;
tok = strtok(NULL, ",");
}
for (i=0; i < nodemap->num; i++) {
(*ctdb)->nodes[i] = talloc(*ctdb, struct ctdb_node);
(*ctdb)->nodes[i]->pnn = i;
- (*ctdb)->nodes[i]->flags = nodemap->nodes[i].flags;
+ (*ctdb)->nodes[i]->flags = nodemap->node[i].flags;
}
if (! ipalloc_set_public_ips(*ipalloc_state, known, avail)) {