summaryrefslogtreecommitdiffstats
path: root/src/msg/async/rdma
diff options
context:
space:
mode:
authorKefu Chai <kchai@redhat.com>2020-03-26 16:25:39 +0100
committerGitHub <noreply@github.com>2020-03-26 16:25:39 +0100
commitbe11e75d5d6a5e8404840482da304a29f8e01b83 (patch)
treefa827d0512734632a53e818b8584093eb62c7972 /src/msg/async/rdma
parentMerge pull request #34195 from tchaikov/wip-tasks-mgr-submodule (diff)
parentmsg/async/rdma: add return value check after qp created (diff)
downloadceph-be11e75d5d6a5e8404840482da304a29f8e01b83.tar.xz
ceph-be11e75d5d6a5e8404840482da304a29f8e01b83.zip
Merge pull request #33882 from rosinL/wip-fix-rdma-segfault
msg/async/rdma: add return value check after qp created Reviewed-by: Kefu Chai <kchai@redhat.com>
Diffstat (limited to 'src/msg/async/rdma')
-rw-r--r--src/msg/async/rdma/RDMAConnectedSocketImpl.cc4
-rw-r--r--src/msg/async/rdma/RDMAServerSocketImpl.cc7
-rw-r--r--src/msg/async/rdma/RDMAStack.h1
3 files changed, 12 insertions, 0 deletions
diff --git a/src/msg/async/rdma/RDMAConnectedSocketImpl.cc b/src/msg/async/rdma/RDMAConnectedSocketImpl.cc
index 5e75e961d18..5ab6c9b2e80 100644
--- a/src/msg/async/rdma/RDMAConnectedSocketImpl.cc
+++ b/src/msg/async/rdma/RDMAConnectedSocketImpl.cc
@@ -58,6 +58,10 @@ RDMAConnectedSocketImpl::RDMAConnectedSocketImpl(CephContext *cct, std::shared_p
{
if (!cct->_conf->ms_async_rdma_cm) {
qp = ib->create_queue_pair(cct, dispatcher->get_tx_cq(), dispatcher->get_rx_cq(), IBV_QPT_RC, NULL);
+ if (!qp) {
+ lderr(cct) << __func__ << " queue pair create failed" << dendl;
+ return;
+ }
local_qpn = qp->get_local_qp_number();
notify_fd = eventfd(0, EFD_CLOEXEC|EFD_NONBLOCK);
dispatcher->register_qp(qp, this);
diff --git a/src/msg/async/rdma/RDMAServerSocketImpl.cc b/src/msg/async/rdma/RDMAServerSocketImpl.cc
index 99d12131ffb..665faa9311c 100644
--- a/src/msg/async/rdma/RDMAServerSocketImpl.cc
+++ b/src/msg/async/rdma/RDMAServerSocketImpl.cc
@@ -113,6 +113,13 @@ int RDMAServerSocketImpl::accept(ConnectedSocket *sock, const SocketOptions &opt
RDMAConnectedSocketImpl* server;
//Worker* w = dispatcher->get_stack()->get_worker();
server = new RDMAConnectedSocketImpl(cct, ib, dispatcher, dynamic_cast<RDMAWorker*>(w));
+ if (!server->get_qp()) {
+ lderr(cct) << __func__ << " server->qp is null" << dendl;
+ // cann't use delete server here, destructor will fail.
+ server->cleanup();
+ ::close(sd);
+ return -1;
+ }
server->set_accept_fd(sd);
ldout(cct, 20) << __func__ << " accepted a new QP, tcp_fd: " << sd << dendl;
std::unique_ptr<RDMAConnectedSocketImpl> csi(server);
diff --git a/src/msg/async/rdma/RDMAStack.h b/src/msg/async/rdma/RDMAStack.h
index c9772904ac2..84434b00cb7 100644
--- a/src/msg/async/rdma/RDMAStack.h
+++ b/src/msg/async/rdma/RDMAStack.h
@@ -221,6 +221,7 @@ class RDMAConnectedSocketImpl : public ConnectedSocketImpl {
const char* get_qp_state() { return Infiniband::qp_state_string(qp->get_state()); }
uint32_t get_peer_qpn () const { return peer_qpn; }
uint32_t get_local_qpn () const { return local_qpn; }
+ Infiniband::QueuePair* get_qp () const { return qp; }
ssize_t submit(bool more);
int activate();
void fin();