From 48dcae8ea23bd498f5116a30c90496942caa67ef Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Mon, 18 Oct 2010 09:53:53 -0700 Subject: [PATCH] librdmacm: do not modify qp_init_attr in rdma_get_request rdma_create_qp modifies the qp_init_attr structure passed in by the user to return the actual QP capabilities that were allocated. If the qp_init_attr does not specify CQs, the librdmacm will allocate CQs for the user and return them. rdma_get_request will allocate a QP off newly connected rdma_cm_id if the corresponding listen request is associated with a qp_init_attr structure. The librdmacm passes in the listen-> qp_init_attr structure into the rdma_create_qp call. rdma_create_qp ends up modifying the qp_init_attr's associated with the listen. The result is that future calls to rdma_get_request will use the modified qp attributes, rather than those specified by the user. Fix this by having rdma_get_request pass in a copy of the qp_init_attr, rather than modifying those associated with the listen. Also update the man page for rdma_create_qp to indicate that the qp_init_attr structure may be modified on output. Signed-off-by: Sean Hefty --- man/rdma_create_qp.3 | 3 +++ src/cma.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/man/rdma_create_qp.3 b/man/rdma_create_qp.3 index 9d2de765..7445db35 100644 --- a/man/rdma_create_qp.3 +++ b/man/rdma_create_qp.3 @@ -39,6 +39,9 @@ a send or receive completion queue is not specified, then a CQ will be allocated by the rdma_cm for the QP, along with corresponding completion channels. Completion channels and CQ data created by the rdma_cm are exposed to the user through the rdma_cm_id structure. +.P +The actual capabilities and properties of the created QP will be +returned to the user through the qp_init_attr parameter. .SH "SEE ALSO" rdma_bind_addr(3), rdma_resolve_addr(3), rdma_destroy_qp(3), ibv_create_qp(3), ibv_modify_qp(3) diff --git a/src/cma.c b/src/cma.c index 253cf800..7ac5335b 100755 --- a/src/cma.c +++ b/src/cma.c @@ -1368,7 +1368,10 @@ int rdma_get_request(struct rdma_cm_id *listen, struct rdma_cm_id **id) } if (id_priv->qp_init_attr) { - ret = rdma_create_qp(event->id, id_priv->pd, id_priv->qp_init_attr); + struct ibv_qp_init_attr attr; + + attr = *id_priv->qp_init_attr; + ret = rdma_create_qp(event->id, id_priv->pd, &attr); if (ret) goto err; } -- 2.46.0