summaryrefslogtreecommitdiff
path: root/ctdb/ib/ibw_ctdb.c
diff options
context:
space:
mode:
authorPeter Somogyi <psomogyi@gamax.hu>2007-04-26 16:54:24 +0200
committerPeter Somogyi <psomogyi@gamax.hu>2007-04-26 16:54:24 +0200
commit4a106ade411a0fee739a41c37f754ea147a5a2de (patch)
treed5c11019994ccd41ada69eeb79e9a534c1ee69b4 /ctdb/ib/ibw_ctdb.c
parent946702979eb2ad08389f13c1b938e374b058f15b (diff)
downloadsamba-4a106ade411a0fee739a41c37f754ea147a5a2de.tar.gz
ctdb/ib: reduce debug output; allow not only ip
(This used to be ctdb commit 1942c21fe7b52f2b0c8f6895bdc7efd70505a9db)
Diffstat (limited to 'ctdb/ib/ibw_ctdb.c')
-rw-r--r--ctdb/ib/ibw_ctdb.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/ctdb/ib/ibw_ctdb.c b/ctdb/ib/ibw_ctdb.c
index dfe4adc6d3e..d8528ec5f06 100644
--- a/ctdb/ib/ibw_ctdb.c
+++ b/ctdb/ib/ibw_ctdb.c
@@ -29,6 +29,21 @@
#include "ibwrapper.h"
#include "ibw_ctdb.h"
+int ctdb_ibw_get_address(struct ctdb_context *ctdb,
+ const char *address, struct in_addr *addr)
+{
+ if (inet_pton(AF_INET, address, addr) <= 0) {
+ struct hostent *he = gethostbyname(address);
+ if (he == NULL || he->h_length > sizeof(*addr)) {
+ ctdb_set_error(ctdb, "invalid nework address '%s'\n",
+ address);
+ return -1;
+ }
+ memcpy(addr, he->h_addr, he->h_length);
+ }
+ return 0;
+}
+
int ctdb_ibw_node_connect(struct ctdb_node *node)
{
struct ctdb_ibw_node *cn = talloc_get_type(node->private_data, struct ctdb_ibw_node);
@@ -39,9 +54,12 @@ int ctdb_ibw_node_connect(struct ctdb_node *node)
struct sockaddr_in sock_out;
memset(&sock_out, 0, sizeof(struct sockaddr_in));
- inet_pton(AF_INET, node->address.address, &sock_out.sin_addr);
sock_out.sin_port = htons(node->address.port);
sock_out.sin_family = PF_INET;
+ if (ctdb_ibw_get_address(node->ctdb, node->address.address, &sock_out.sin_addr)) {
+ DEBUG(0, ("ctdb_ibw_node_connect failed\n"));
+ return -1;
+ }
rc = ibw_connect(cn->conn, &sock_out, node);
if (rc) {