[SCM] CTDB repository - branch ipv6-test updated -
4dfbfb4618433d9ed79ca1bdb1e2e51d96d4ee62
Ronnie Sahlberg
sahlberg at samba.org
Thu Aug 21 23:15:06 GMT 2008
The branch, ipv6-test has been updated
via 4dfbfb4618433d9ed79ca1bdb1e2e51d96d4ee62 (commit)
from 293d12a40501320a21efaf592b8f20e8590a5197 (commit)
http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=ipv6-test
- Log -----------------------------------------------------------------
commit 4dfbfb4618433d9ed79ca1bdb1e2e51d96d4ee62
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date: Fri Aug 22 09:09:08 2008 +1000
when we collect all ip addresses and sort them for the "ctdb ip -n all" output we must look at more than just the first 4 bytes of the sockaddr address or ipv6 wont work
-----------------------------------------------------------------------
Summary of changes:
tests/nodes.txt | 2 +-
tools/ctdb.c | 43 ++++++++++++++++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/tests/nodes.txt b/tests/nodes.txt
index 20e29b1..7b9ad53 100644
--- a/tests/nodes.txt
+++ b/tests/nodes.txt
@@ -1 +1 @@
-::1
+127.0.0.1
diff --git a/tools/ctdb.c b/tools/ctdb.c
index 90af2a8..8aa934d 100644
--- a/tools/ctdb.c
+++ b/tools/ctdb.c
@@ -574,12 +574,42 @@ void getips_count_callback(void *param, void *data)
(*count)++;
}
+#define IP_KEYLEN 4
+static uint32_t *ip_key(ctdb_sock_addr *ip)
+{
+ static uint32_t key[IP_KEYLEN];
+
+ bzero(key, sizeof(key));
+
+ switch (ip->sa.sa_family) {
+ case AF_INET:
+ key[0] = ip->ip.sin_addr.s_addr;
+ break;
+ case AF_INET6:
+ key[0] = ip->ip6.sin6_addr.s6_addr32[3];
+ key[1] = ip->ip6.sin6_addr.s6_addr32[2];
+ key[2] = ip->ip6.sin6_addr.s6_addr32[1];
+ key[3] = ip->ip6.sin6_addr.s6_addr32[0];
+ break;
+ default:
+ DEBUG(DEBUG_ERR, (__location__ " ERROR, unknown family passed :%u\n", ip->sa.sa_family));
+ return key;
+ }
+
+ return key;
+}
+
+static void *add_ip_callback(void *parm, void *data)
+{
+ return parm;
+}
+
static int
control_get_all_public_ips(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx, struct ctdb_all_public_ips **ips)
{
struct ctdb_all_public_ips *tmp_ips;
struct ctdb_node_map *nodemap=NULL;
- trbt_tree_t *tree;
+ trbt_tree_t *ip_tree;
int i, j, len, ret;
uint32_t count;
@@ -589,7 +619,7 @@ control_get_all_public_ips(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx, struc
return ret;
}
- tree = trbt_create(tmp_ctx, 0);
+ ip_tree = trbt_create(tmp_ctx, 0);
for(i=0;i<nodemap->num;i++){
if (nodemap->nodes[i].flags & NODE_FLAGS_DISCONNECTED) {
@@ -610,19 +640,22 @@ control_get_all_public_ips(struct ctdb_context *ctdb, TALLOC_CTX *tmp_ctx, struc
node_ip->pnn = tmp_ips->ips[j].pnn;
node_ip->addr = tmp_ips->ips[j].addr;
- trbt_insert32(tree, tmp_ips->ips[j].addr.ip.sin_addr.s_addr, node_ip);
+ trbt_insertarray32_callback(ip_tree,
+ IP_KEYLEN, ip_key(&tmp_ips->ips[j].addr),
+ add_ip_callback,
+ node_ip);
}
talloc_free(tmp_ips);
}
/* traverse */
count = 0;
- trbt_traversearray32(tree, 1, getips_count_callback, &count);
+ trbt_traversearray32(ip_tree, IP_KEYLEN, getips_count_callback, &count);
len = offsetof(struct ctdb_all_public_ips, ips) +
count*sizeof(struct ctdb_public_ip);
tmp_ips = talloc_zero_size(tmp_ctx, len);
- trbt_traversearray32(tree, 1, getips_store_callback, tmp_ips);
+ trbt_traversearray32(ip_tree, IP_KEYLEN, getips_store_callback, tmp_ips);
*ips = tmp_ips;
--
CTDB repository
More information about the samba-cvs
mailing list