[openib-general] [PATCH] CM cmpost utility fixes
William Jordan
bjordan.ics at gmail.com
Tue May 17 15:20:39 PDT 2005
Sean,
You mentioned that the cm_id leak was fixed, but I don't see a patch
for it, so I'm
submitting one.
Fixed leak of cm_ids in server side of cmpost. Fixed an Oops if number
of connections
on server and client side don't match.
Signed-off-by: Bill Jordan <bjordan at infinicon.com>
Index: cmpost.c
===================================================================
--- cmpost.c (revision 2369)
+++ cmpost.c (working copy)
@@ -207,7 +207,7 @@ static int modify_to_rts(struct cmtest_n
return 0;
}
-static void req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
+static int req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
{
struct cmtest_node *node;
struct ib_cm_req_event_param *req;
@@ -215,6 +215,10 @@ static void req_handler(struct ib_cm_id
int ret;
down(&test.sem);
+ if (test.conn_index == connections) {
+ up(&test.sem);
+ goto fail1;
+ }
node = &test.nodes[ test.conn_index++];
up(&test.sem);
@@ -223,11 +227,11 @@ static void req_handler(struct ib_cm_id
ret = modify_to_rtr(node);
if (ret)
- goto fail;
+ goto fail2;
ret = post_recvs(node);
if (ret)
- goto fail;
+ goto fail2;
req = &event->param.req_rcvd;
memset(&rep, 0, sizeof rep);
@@ -243,15 +247,18 @@ static void req_handler(struct ib_cm_id
ret = ib_send_cm_rep(cm_id, &rep);
if (ret) {
printk("cmpost: failed to send CM REP: %d\n", ret);
- goto fail;
+ goto fail2;
}
- return;
-fail:
- printk("cmpost: failing connection request\n");
- ib_send_cm_rej(cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0);
+ return 0;
+fail2:
+ node->cm_id = NULL;
atomic_dec(&test.disconnects_left);
if (atomic_dec_and_test(&test.connects_left))
wake_up(&test.wait);
+fail1:
+ printk("cmpost: failing connection request\n");
+ ib_send_cm_rej(cm_id, IB_CM_REJ_UNSUPPORTED, NULL, 0, NULL, 0);
+ return -1;
}
static void rep_handler(struct cmtest_node *node, struct ib_cm_event *event)
@@ -310,10 +317,11 @@ fail:
static int cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
{
struct cmtest_node *node = cm_id->context;
+ int ret = 0;
switch (event->event) {
case IB_CM_REQ_RECEIVED:
- req_handler(cm_id, event);
+ ret = req_handler(cm_id, event);
break;
case IB_CM_REP_RECEIVED:
rep_handler(node, event);
@@ -349,7 +357,7 @@ static int cm_handler(struct ib_cm_id *c
default:
break;
}
- return 0;
+ return ret;
}
static void comp_handler(struct ib_cq *cq, void *cq_context)
@@ -406,6 +414,8 @@ static int init_node(struct cmtest_node
printk("cmpost: failed to create cm_id: %d\n", ret);
return ret;
}
+ } else {
+ node->cm_id = NULL;
}
cqe = message_count ? message_count * 2 : 2;
@@ -438,7 +448,7 @@ static void destroy_node(struct cmtest_n
{
ib_destroy_qp(node->qp);
ib_destroy_cq(node->cq);
- if (!is_server)
+ if (node->cm_id)
ib_destroy_cm_id(node->cm_id);
}
--
Bill Jordan
InfiniCon Systems
More information about the general
mailing list