CTDB_CONTROL_GET_DBMAP, 0, tdb_null,
mem_ctx, &outdata, &res, &timeout, NULL);
if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getdbmap failed\n"));
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getdbmap failed ret:%d res:%d\n", ret, res));
return -1;
}
ret = ctdb_control(ctdb, destnode, 0,
CTDB_CONTROL_GET_NODEMAP, 0, tdb_null,
mem_ctx, &outdata, &res, &timeout, NULL);
+ if (ret == 0 && res == -1 && outdata.dsize == 0) {
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getnodes failed, falling back to ipv4-only control\n"));
+ return ctdb_ctrl_getnodemapv4(ctdb, timeout, destnode, mem_ctx, nodemap);
+ }
if (ret != 0 || res != 0 || outdata.dsize == 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getnodes failed\n"));
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getnodes failed ret:%d res:%d\n", ret, res));
return -1;
}
return 0;
}
+/*
+ old style ipv4-only get a list of nodes (vnn and flags ) from a remote node
+ */
+int ctdb_ctrl_getnodemapv4(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap)
+{
+ int ret, i, len;
+ TDB_DATA outdata;
+ struct ctdb_node_mapv4 *nodemapv4;
+ int32_t res;
+
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_GET_NODEMAPv4, 0, tdb_null,
+ mem_ctx, &outdata, &res, &timeout, NULL);
+ if (ret != 0 || res != 0 || outdata.dsize == 0) {
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getnodesv4 failed ret:%d res:%d\n", ret, res));
+ return -1;
+ }
+
+ nodemapv4 = (struct ctdb_node_mapv4 *)outdata.dptr;
+
+ len = offsetof(struct ctdb_node_map, nodes) + nodemapv4->num*sizeof(struct ctdb_node_and_flags);
+ (*nodemap) = talloc_zero_size(mem_ctx, len);
+ CTDB_NO_MEMORY(ctdb, (*nodemap));
+
+ (*nodemap)->num = nodemapv4->num;
+ for (i=0; i<nodemapv4->num; i++) {
+ (*nodemap)->nodes[i].pnn = nodemapv4->nodes[i].pnn;
+ (*nodemap)->nodes[i].flags = nodemapv4->nodes[i].flags;
+ (*nodemap)->nodes[i].addr.ip = nodemapv4->nodes[i].sin;
+ (*nodemap)->nodes[i].addr.sa.sa_family = AF_INET;
+ }
+
+ talloc_free(outdata.dptr);
+
+ return 0;
+}
+
/*
drop the transport, reload the nodes file and restart the transport
*/
ret = ctdb_control(ctdb, destnode, 0,
CTDB_CONTROL_GET_PUBLIC_IPS, 0, tdb_null,
mem_ctx, &outdata, &res, &timeout, NULL);
+ if (ret == 0 && res == -1) {
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control to get public ips failed, falling back to ipv4-only version\n"));
+ return ctdb_ctrl_get_public_ipsv4(ctdb, timeout, destnode, mem_ctx, ips);
+ }
if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getpublicips failed\n"));
+ DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getpublicips failed ret:%d res:%d\n", ret, res));
return -1;
}
len = offsetof(struct ctdb_all_public_ips, ips) +
ipsv4->num*sizeof(struct ctdb_public_ip);
*ips = talloc_zero_size(mem_ctx, len);
+ (*ips)->num = ipsv4->num;
for (i=0; i<ipsv4->num; i++) {
(*ips)->ips[i].pnn = ipsv4->ips[i].pnn;
(*ips)->ips[i].addr.ip = ipsv4->ips[i].sin;