Exemplo n.º 1
0
/* Can the given node host the given IP: is the public IP known to the
 * node and is NOIPHOST unset?
*/
static bool can_node_host_ip(struct ipalloc_state *ipalloc_state,
			     int32_t pnn,
			     struct public_ip_list *ip)
{
	struct ctdb_public_ip_list_old *public_ips;
	int i;

	if (ipalloc_state->noiphost[pnn]) {
		return false;
	}

	public_ips = ipalloc_state->available_public_ips[pnn];

	if (public_ips == NULL) {
		return false;
	}

	for (i=0; i<public_ips->num; i++) {
		if (ctdb_same_ip(&ip->addr, &public_ips->ips[i].addr)) {
			/* yes, this node can serve this public ip */
			return true;
		}
	}

	return false;
}
Exemplo n.º 2
0
/*
  Check whether an ip is a valid node ip
  Returns the node id for this ip address or -1
*/
int ctdb_ip_to_nodeid(struct ctdb_context *ctdb, const ctdb_sock_addr *nodeip)
{
    int nodeid;

    for (nodeid=0; nodeid<ctdb->num_nodes; nodeid++) {
        if (ctdb->nodes[nodeid]->flags & NODE_FLAGS_DELETED) {
            continue;
        }
        if (ctdb_same_ip(&ctdb->nodes[nodeid]->address, nodeip)) {
            return nodeid;
        }
    }

    return -1;
}