]> git.openfabrics.org - ~shefty/librdmacm.git/commitdiff
Only allow a user to allocate a single QP off an rdma_cm_id
authorSean Hefty <sean.hefty@intel.com>
Sat, 5 Mar 2011 00:13:44 +0000 (16:13 -0800)
committerSean Hefty <sean.hefty@intel.com>
Sat, 5 Mar 2011 00:13:44 +0000 (16:13 -0800)
Add a simple check to rdma_create_qp() to see if a QP has already been
associated with an rdma_cm_id.  Otherwise a user can allocate a
second QP with an ID, with the reference to the first QP replaced
by the second allocation.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
man/rdma_create_qp.3 [changed mode: 0644->0755]
src/cma.c

old mode 100644 (file)
new mode 100755 (executable)
index 7445db3..7e37888
@@ -41,7 +41,8 @@ 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.
+returned to the user through the qp_init_attr parameter.  An rdma_cm_id
+may only be associated with a single QP.
 .SH "SEE ALSO"
 rdma_bind_addr(3), rdma_resolve_addr(3), rdma_destroy_qp(3), ibv_create_qp(3),
 ibv_modify_qp(3)
index 7ac5335be070711de8d844f583bf073496268f54..846b5ce4ec239f4a71e9afb76347e334308339c6 100755 (executable)
--- a/src/cma.c
+++ b/src/cma.c
@@ -1176,6 +1176,9 @@ int rdma_create_qp(struct rdma_cm_id *id, struct ibv_pd *pd,
        struct ibv_qp *qp;
        int ret;
 
+       if (id->qp)
+               return ERR(EINVAL);
+
        id_priv = container_of(id, struct cma_id_private, id);
        if (!pd)
                pd = id_priv->cma_dev->pd;