Skip to content

Commit

Permalink
Add a helpful message for #196.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaycedowell committed Sep 5, 2023
1 parent cf4dbc4 commit c966503
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/ib_verbs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c966503

Please sign in to comment.