From c9665032f79977f35024ef2cd9c77c1657f13b1b Mon Sep 17 00:00:00 2001 From: jaycedowell Date: Tue, 5 Sep 2023 10:50:48 -0600 Subject: [PATCH] Add a helpful message for https://github.com/ledatelescope/bifrost/issues/196. --- src/ib_verbs.hpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/ib_verbs.hpp b/src/ib_verbs.hpp index 84bf0bc25..d30ef67a1 100644 --- a/src/ib_verbs.hpp +++ b/src/ib_verbs.hpp @@ -553,8 +553,8 @@ class Verbs { qp_init.send_cq = _verbs.send_cq[i]; qp_init.recv_cq = _verbs.cq[i]; _verbs.qp[i] = ibv_create_qp(_verbs.pd, &qp_init); - check_null(_verbs.qp[i], - "create queue pair"); + check_null_qp(_verbs.qp[i], + "create queue pair"); // Transition queue pair to INIT state ibv_qp_attr qp_attr; @@ -961,6 +961,23 @@ class Verbs { throw Verbs::Error(ss.str()); } } + inline void check_null_qp(void* ptr, std::string what) { + if( ptr == NULL ) { + destroy_flows(); + destroy_queues(); + destroy_buffers(); + destroy_context(); + + std::stringstream ss; + ss << "Failed to " << what << ": (" << errno << ") " + << strerror(errno); + if( errno == EPERM ) { + ss << " Do you need to set 'options ibverbs disable_raw_qp_enforcement=1' " + << "or add the CAP_NET_RAW capability?"; + } + throw Verbs::Error(ss.str()); + } + } public: class Error : public std::runtime_error { typedef std::runtime_error super_t;