Upon QP creation failure provider's create_qp function sets errno with error code and return NULL to caller. Let's return this errno to caller to reflect the exact reason for the error. Signed-off-by: Yuval Shaia <yuval.shaia@xxxxxxxxxx> --- librdmacm/cma.c | 4 +++- librdmacm/cma.h | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/librdmacm/cma.c b/librdmacm/cma.c index fa370650..9920eaba 100644 --- a/librdmacm/cma.c +++ b/librdmacm/cma.c @@ -1367,9 +1367,11 @@ int rdma_create_qp_ex(struct rdma_cm_id *id, attr->recv_cq = id->recv_cq; if (id->srq && !attr->srq) attr->srq = id->srq; + + errno = 0; qp = ibv_create_qp_ex(id->verbs, attr); if (!qp) { - ret = ERR(ENOMEM); + ret = CHK_ERRNO("ibv_create_qp_ex"); goto err1; } diff --git a/librdmacm/cma.h b/librdmacm/cma.h index 62821055..c2dc4865 100644 --- a/librdmacm/cma.h +++ b/librdmacm/cma.h @@ -41,6 +41,7 @@ #include <endian.h> #include <semaphore.h> #include <stdatomic.h> +#include <stdio.h> #include <rdma/rdma_cma.h> #include <infiniband/ib.h> @@ -92,6 +93,13 @@ static inline int ERR(int err) return -1; } +static inline int CHK_ERRNO(const char *funcname) +{ + if (!errno) + fprintf(stderr, "Function %s did not set errno\n", funcname); + return -1; +} + int ucma_init(void); extern int af_ib_support; -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html