struct ctdb_do_takeip_state *state =
talloc_get_type(private_data, struct ctdb_do_takeip_state);
int32_t ret;
+ TDB_DATA data;
if (status != 0) {
if (status == -ETIME) {
return;
}
+ data.dptr = (uint8_t *)ctdb_addr_to_str(&state->vnn->public_address);
+ data.dsize = strlen((char *)data.dptr) + 1;
+ DEBUG(DEBUG_INFO,(__location__ " sending TAKE_IP for '%s'\n", data.dptr));
+
+ ctdb_daemon_send_message(ctdb, ctdb->pnn, CTDB_SRVID_TAKE_IP, data);
+
+
/* the control succeeded */
ctdb_request_control_reply(ctdb, state->c, NULL, 0, NULL);
talloc_free(state);
return -1;
}
- if (vnn->iface == old) {
- DEBUG(DEBUG_ERR,("update of IP %s/%u trying to "
- "assin a same interface '%s'\n",
- ctdb_addr_to_str(&vnn->public_address),
- vnn->public_netmask_bits,
- old->name));
- return -1;
- }
-
state = talloc(vnn, struct ctdb_do_updateip_state);
CTDB_NO_MEMORY(ctdb, state);
return -1;
}
- if (vnn->pnn != ctdb->pnn && have_ip) {
+ if (vnn->pnn != ctdb->pnn && have_ip && vnn->pnn != -1) {
DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
"and we have it on iface[%s], but it was assigned to node %d"
"and we are node %d, banning ourself\n",
return -1;
}
+ if (vnn->pnn == -1 && have_ip) {
+ vnn->pnn = ctdb->pnn;
+ DEBUG(DEBUG_CRIT,(__location__ " takeoverip of IP %s is known to the kernel, "
+ "and we already have it on iface[%s], update local daemon\n",
+ ctdb_addr_to_str(&vnn->public_address),
+ ctdb_vnn_iface_string(vnn)));
+ return 0;
+ }
+
if (vnn->iface) {
if (vnn->iface->link_up) {
/* only move when the rebalance gains something */
vnn->public_address = *addr;
vnn->public_netmask_bits = mask;
vnn->pnn = -1;
+ if (ctdb_sys_have_ip(addr)) {
+ DEBUG(DEBUG_ERR,("We are already hosting public address '%s'. setting PNN to ourself:%d\n", ctdb_addr_to_str(addr), ctdb->pnn));
+ vnn->pnn = ctdb->pnn;
+ }
for (i=0; vnn->ifaces[i]; i++) {
ret = ctdb_add_local_iface(ctdb, vnn->ifaces[i]);
talloc_free(vnn);
return -1;
}
+ if (i == 0) {
+ vnn->iface = ctdb_find_iface(ctdb, vnn->ifaces[i]);
+ }
}
DLIST_ADD(ctdb->vnn, vnn);
const char *ip)
{
struct ctdb_vnn *svnn;
+ struct ctdb_iface *cur = NULL;
bool ok;
int ret;
return -1;
}
+ /* assume the single public ip interface is initially "good" */
+ cur = ctdb_find_iface(ctdb, iface);
+ if (cur == NULL) {
+ DEBUG(DEBUG_CRIT,("Can not find public interface %s used by --single-public-ip", iface));
+ return -1;
+ }
+ cur->link_up = true;
+
ret = ctdb_vnn_assign_iface(ctdb, svnn);
if (ret != 0) {
talloc_free(svnn);
static void *add_ip_callback(void *parm, void *data)
{
+ struct ctdb_public_ip_list *this_ip = parm;
+ struct ctdb_public_ip_list *prev_ip = data;
+
+ if (prev_ip == NULL) {
+ return parm;
+ }
+ if (this_ip->pnn == -1) {
+ this_ip->pnn = prev_ip->pnn;
+ }
+
return parm;
}
*/
int ctdb_takeover_run(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap)
{
- int i, num_healthy, retries, num_ips;
+ int i, num_healthy, retries;
struct ctdb_public_ip ip;
struct ctdb_public_ipv4 ipv4;
uint32_t mask, *nodes;
struct ctdb_client_control_state *state;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
+ /*
+ * ip failover is completely disabled, just send out the
+ * ipreallocated event.
+ */
+ if (ctdb->tunable.disable_ip_failover != 0) {
+ goto ipreallocated;
+ }
ZERO_STRUCT(ip);
return -1;
}
+ipreallocated:
/* tell all nodes to update natwg */
/* send the flags update natgw on all connected nodes */
data.dptr = discard_const("ipreallocated");