diff options
author | Peter Somogyi <psomogyi@gamax.hu> | 2007-04-26 16:54:24 +0200 |
---|---|---|
committer | Peter Somogyi <psomogyi@gamax.hu> | 2007-04-26 16:54:24 +0200 |
commit | 4a106ade411a0fee739a41c37f754ea147a5a2de (patch) | |
tree | d5c11019994ccd41ada69eeb79e9a534c1ee69b4 /ctdb | |
parent | 946702979eb2ad08389f13c1b938e374b058f15b (diff) | |
download | samba-4a106ade411a0fee739a41c37f754ea147a5a2de.tar.gz |
ctdb/ib: reduce debug output; allow not only ip
(This used to be ctdb commit 1942c21fe7b52f2b0c8f6895bdc7efd70505a9db)
Diffstat (limited to 'ctdb')
-rw-r--r-- | ctdb/ib/ibw_ctdb.c | 20 | ||||
-rw-r--r-- | ctdb/ib/ibw_ctdb.h | 5 | ||||
-rw-r--r-- | ctdb/ib/ibw_ctdb_init.c | 3 | ||||
-rw-r--r-- | ctdb/ib/ibwrapper.c | 7 | ||||
-rw-r--r-- | ctdb/ib/ibwrapper_test.c | 25 |
5 files changed, 53 insertions, 7 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) { diff --git a/ctdb/ib/ibw_ctdb.h b/ctdb/ib/ibw_ctdb.h index 8286eef65aa..30c2f87eeb6 100644 --- a/ctdb/ib/ibw_ctdb.h +++ b/ctdb/ib/ibw_ctdb.h @@ -36,6 +36,9 @@ struct ctdb_ibw_node { int qcnt; }; +int ctdb_ibw_get_address(struct ctdb_context *ctdb, + const char *address, struct in_addr *addr); + int ctdb_ibw_connstate_handler(struct ibw_ctx *ctx, struct ibw_conn *conn); int ctdb_ibw_receive_handler(struct ibw_conn *conn, void *buf, int n); @@ -44,3 +47,5 @@ void ctdb_ibw_node_connect_event(struct event_context *ev, struct timed_event *t struct timeval t, void *private_data); int ctdb_flush_cn_queue(struct ctdb_ibw_node *cn); + +int ctdb_ibw_init(struct ctdb_context *ctdb); diff --git a/ctdb/ib/ibw_ctdb_init.c b/ctdb/ib/ibw_ctdb_init.c index c8f9e97feb7..66919568df5 100644 --- a/ctdb/ib/ibw_ctdb_init.c +++ b/ctdb/ib/ibw_ctdb_init.c @@ -38,7 +38,8 @@ static int ctdb_ibw_listen(struct ctdb_context *ctdb, int backlog) memset(&my_addr, 0, sizeof(struct sockaddr_in)); my_addr.sin_port = htons(ctdb->address.port); my_addr.sin_family = PF_INET; - inet_pton(AF_INET, ctdb->address.address, &my_addr.sin_addr); + if (ctdb_ibw_get_address(ctdb, ctdb->address.address, &my_addr.sin_addr)) + return -1; if (ibw_bind(ictx, &my_addr)) { DEBUG(0, ("ctdb_ibw_listen: ibw_bind failed\n")); diff --git a/ctdb/ib/ibwrapper.c b/ctdb/ib/ibwrapper.c index a558ab44b8f..23600ced349 100644 --- a/ctdb/ib/ibwrapper.c +++ b/ctdb/ib/ibwrapper.c @@ -495,7 +495,7 @@ static void ibw_event_handler_cm(struct event_context *ev, case RDMA_CM_EVENT_ESTABLISHED: /* expected after ibw_accept and ibw_connect[not directly] */ - DEBUG(0, ("ESTABLISHED (conn: %p)\n", cma_id->context)); + DEBUG(1, ("ESTABLISHED (conn: %p)\n", cma_id->context)); conn = talloc_get_type(cma_id->context, struct ibw_conn); assert(conn!=NULL); /* important assumption */ @@ -516,10 +516,13 @@ static void ibw_event_handler_cm(struct event_context *ev, sprintf(ibw_lasterr, "RDMA_CM_EVENT_CONNECT_ERROR, error %d\n", event->status); case RDMA_CM_EVENT_UNREACHABLE: sprintf(ibw_lasterr, "RDMA_CM_EVENT_UNREACHABLE, error %d\n", event->status); + goto error; case RDMA_CM_EVENT_REJECTED: sprintf(ibw_lasterr, "RDMA_CM_EVENT_REJECTED, error %d\n", event->status); + DEBUG(1, ("cm event handler: %s", ibw_lasterr)); conn = talloc_get_type(cma_id->context, struct ibw_conn); if (conn) { + /* must be done BEFORE connstate */ if ((rc=rdma_ack_cm_event(event))) DEBUG(0, ("reject/rdma_ack_cm_event failed with %d\n", rc)); event = NULL; /* not to touch cma_id or conn */ @@ -527,7 +530,7 @@ static void ibw_event_handler_cm(struct event_context *ev, /* it should free the conn */ pctx->connstate_func(NULL, conn); } - goto error; + break; /* this is not strictly an error */ case RDMA_CM_EVENT_DISCONNECTED: DEBUG(11, ("RDMA_CM_EVENT_DISCONNECTED\n")); diff --git a/ctdb/ib/ibwrapper_test.c b/ctdb/ib/ibwrapper_test.c index 6ef5aa1e679..d48a0cee482 100644 --- a/ctdb/ib/ibwrapper_test.c +++ b/ctdb/ib/ibwrapper_test.c @@ -290,7 +290,7 @@ int ibwtest_connstate_handler(struct ibw_ctx *ctx, struct ibw_conn *conn) talloc_free(conn); break; case IBWC_ERROR: - DEBUG(10, ("test IBWC_ERROR\n")); + DEBUG(10, ("test IBWC_ERROR %s\n", ibw_getLastError())); break; default: assert(0); @@ -466,6 +466,19 @@ int ibwtest_parse_attrs(struct ibwtest_ctx *tcx, char *optext, return 0; } +static int ibwtest_get_address(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)) { + DEBUG(0, ("invalid nework address '%s'\n", address)); + return -1; + } + memcpy(addr, he->h_addr, he->h_length); + } + return 0; +} + int ibwtest_getdests(struct ibwtest_ctx *tcx, char op) { int i; @@ -483,7 +496,8 @@ int ibwtest_getdests(struct ibwtest_ctx *tcx, char op) for(i=0; i<tcx->naddrs; i++) { p = tcx->addrs + i; p->sin_family = AF_INET; - p->sin_addr.s_addr = inet_addr(attrs[i].name); + if (ibwtest_get_address(attrs[i].name, &p->sin_addr)) + return -1; p->sin_port = htons(atoi(attrs[i].value)); } @@ -524,6 +538,7 @@ void ibwtest_usage(struct ibwtest_ctx *tcx, char *name) printf("\t-n number of messages to send [default %d]\n", tcx->nmsg); printf("\t-l usec time to sleep in the main loop [default %d]\n", tcx->sleep_usec); printf("\t-v max variable msg size in bytes [default %d], 0=don't send var. size\n", tcx->maxsize); + printf("\t-g LogLevel [default %d]\n", LogLevel); printf("Press ctrl+C to stop the program.\n"); } @@ -539,13 +554,14 @@ int main(int argc, char *argv[]) memset(tcx, 0, sizeof(struct ibwtest_ctx)); tcx->nsec = 0; tcx->nmsg = 1000; + LogLevel = 0; /* here is the only case we can't avoid using global... */ testctx = tcx; signal(SIGINT, ibwtest_sigint_handler); srand((unsigned)time(NULL)); - while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:v:")) != -1) { + while ((op=getopt(argc, argv, "i:o:d:m:st:n:l:v:g:")) != -1) { switch (op) { case 'i': tcx->id = talloc_strdup(tcx, optarg); @@ -575,6 +591,9 @@ int main(int argc, char *argv[]) case 'v': tcx->maxsize = (unsigned int)atoi(optarg); break; + case 'g': + LogLevel = atoi(optarg); + break; default: fprintf(stderr, "ERROR: unknown option -%c\n", (char)op); ibwtest_usage(tcx, argv[0]); |