diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index e6f24e50336..a2b187cf162 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -961,6 +961,8 @@ int ctdb_set_public_addresses(struct ctdb_context *ctdb, bool check_addresses); int ctdb_set_single_public_ip(struct ctdb_context *ctdb, const char *iface, const char *ip); +int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb, + struct ctdb_node_map_old *nodemap); int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap, uint32_t *force_rebalance_nodes, client_async_callback fail_callback, void *callback_data); @@ -1007,9 +1009,6 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, struct ctdb_req_control_old *c, TDB_DATA recdata, bool *async_reply); -int verify_remote_ip_allocation(struct ctdb_context *ctdb, - struct ctdb_public_ip_list_old *ips, - uint32_t pnn); int update_ip_assignment_tree(struct ctdb_context *ctdb, struct ctdb_public_ip *ip); void clear_ip_assignment_tree(struct ctdb_context *ctdb); diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 759b74a14a1..87c77950de6 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -1564,68 +1564,6 @@ static int recover_database(struct ctdb_recoverd *rec, return 0; } -static int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb, - struct ctdb_node_map_old *nodemap) -{ - int j; - int ret; - - if (ctdb->num_nodes != nodemap->num) { - DEBUG(DEBUG_ERR, (__location__ " ctdb->num_nodes (%d) != nodemap->num (%d) invalid param\n", - ctdb->num_nodes, nodemap->num)); - return -1; - } - - for (j=0; jnum; j++) { - /* For readability */ - struct ctdb_node *node = ctdb->nodes[j]; - - /* release any existing data */ - TALLOC_FREE(node->known_public_ips); - TALLOC_FREE(node->available_public_ips); - - if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) { - continue; - } - - /* Retrieve the list of known public IPs from the node */ - ret = ctdb_ctrl_get_public_ips_flags(ctdb, - CONTROL_TIMEOUT(), - node->pnn, - ctdb->nodes, - 0, - &node->known_public_ips); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Failed to read known public IPs from node: %u\n", - node->pnn)); - return -1; - } - - if (ctdb->do_checkpublicip) { - verify_remote_ip_allocation(ctdb, - node->known_public_ips, - node->pnn); - } - - /* Retrieve the list of available public IPs from the node */ - ret = ctdb_ctrl_get_public_ips_flags(ctdb, - CONTROL_TIMEOUT(), - node->pnn, - ctdb->nodes, - CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE, - &node->available_public_ips); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Failed to read available public IPs from node: %u\n", - node->pnn)); - return -1; - } - } - - return 0; -} - /* when we start a recovery, make sure all nodes use the same reclock file setting */ diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 6462de8aa43..27fb01aaf11 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -1388,6 +1388,72 @@ static int getips_count_callback(void *param, void *data) return 0; } +static int verify_remote_ip_allocation(struct ctdb_context *ctdb, + struct ctdb_public_ip_list_old *ips, + uint32_t pnn); + +int ctdb_reload_remote_public_ips(struct ctdb_context *ctdb, + struct ctdb_node_map_old *nodemap) +{ + int j; + int ret; + + if (ctdb->num_nodes != nodemap->num) { + DEBUG(DEBUG_ERR, (__location__ " ctdb->num_nodes (%d) != nodemap->num (%d) invalid param\n", + ctdb->num_nodes, nodemap->num)); + return -1; + } + + for (j=0; jnum; j++) { + /* For readability */ + struct ctdb_node *node = ctdb->nodes[j]; + + /* release any existing data */ + TALLOC_FREE(node->known_public_ips); + TALLOC_FREE(node->available_public_ips); + + if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) { + continue; + } + + /* Retrieve the list of known public IPs from the node */ + ret = ctdb_ctrl_get_public_ips_flags(ctdb, + TAKEOVER_TIMEOUT(), + node->pnn, + ctdb->nodes, + 0, + &node->known_public_ips); + if (ret != 0) { + DEBUG(DEBUG_ERR, + ("Failed to read known public IPs from node: %u\n", + node->pnn)); + return -1; + } + + if (ctdb->do_checkpublicip) { + verify_remote_ip_allocation(ctdb, + node->known_public_ips, + node->pnn); + } + + /* Retrieve the list of available public IPs from the node */ + ret = ctdb_ctrl_get_public_ips_flags(ctdb, + TAKEOVER_TIMEOUT(), + node->pnn, + ctdb->nodes, + CTDB_PUBLIC_IP_FLAGS_ONLY_AVAILABLE, + &node->available_public_ips); + if (ret != 0) { + DEBUG(DEBUG_ERR, + ("Failed to read available public IPs from node: %u\n", + node->pnn)); + return -1; + } + } + + return 0; +} + static struct public_ip_list * create_merged_ip_list(struct ctdb_context *ctdb) { @@ -4219,9 +4285,9 @@ int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb, node has the expected ip allocation. This is verified against ctdb->ip_tree */ -int verify_remote_ip_allocation(struct ctdb_context *ctdb, - struct ctdb_public_ip_list_old *ips, - uint32_t pnn) +static int verify_remote_ip_allocation(struct ctdb_context *ctdb, + struct ctdb_public_ip_list_old *ips, + uint32_t pnn) { struct public_ip_list *tmp_ip; int i;