From: Noa Osherovich <noaos@mellanox.com>
To: dledford@redhat.com, jgg@mellanox.com, leonro@mellanox.com
Cc: linux-rdma@vger.kernel.org, Noa Osherovich <noaos@mellanox.com>,
Maor Gottlieb <maorg@mellanox.com>
Subject: [PATCH rdma-core 4/4] pyverbs: Fix assignments of bad work requests
Date: Wed, 10 Jul 2019 17:22:51 +0300 [thread overview]
Message-ID: <20190710142251.9396-5-noaos@mellanox.com> (raw)
In-Reply-To: <20190710142251.9396-1-noaos@mellanox.com>
The bad work request content wasn't properly copied from the C
object, fix copying to contain the bad work request data.
Signed-off-by: Noa Osherovich <noaos@mellanox.com>
Reviewd-by: Maor Gottlieb <maorg@mellanox.com>
---
pyverbs/qp.pyx | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/pyverbs/qp.pyx b/pyverbs/qp.pyx
index 47a2158a5acc..ad89c94c002e 100644
--- a/pyverbs/qp.pyx
+++ b/pyverbs/qp.pyx
@@ -14,6 +14,9 @@ cimport pyverbs.libibverbs as v
from pyverbs.pd cimport PD
+cdef extern from 'string.h':
+ void *memcpy(void *dest, const void *src, size_t n);
+
cdef class QPCap(PyverbsObject):
def __cinit__(self, max_send_wr=1, max_recv_wr=10, max_send_sge=1,
max_recv_sge=1, max_inline_data=0):
@@ -963,10 +966,12 @@ cdef class QP(PyverbsCM):
:return: None
"""
cdef v.ibv_recv_wr *my_bad_wr
+ # In order to provide a pointer to a pointer, use a temporary cdef'ed
+ # variable.
rc = v.ibv_post_recv(self.qp, &wr.recv_wr, &my_bad_wr)
if rc != 0:
- if bad_wr is not None:
- bad_wr.wr = <object>my_bad_wr
+ if (bad_wr):
+ memcpy(&bad_wr.recv_wr, my_bad_wr, sizeof(bad_wr.recv_wr))
raise PyverbsRDMAErrno('Failed to post recv (returned {rc})'.
format(rc=rc))
@@ -978,11 +983,13 @@ cdef class QP(PyverbsCM):
case of a failure
:return: None
"""
+ # In order to provide a pointer to a pointer, use a temporary cdef'ed
+ # variable.
cdef v.ibv_send_wr *my_bad_wr
rc = v.ibv_post_send(self.qp, &wr.send_wr, &my_bad_wr)
if rc != 0:
- if bad_wr is not None:
- bad_wr.wr = <object>my_bad_wr
+ if (bad_wr):
+ memcpy(&bad_wr.send_wr, my_bad_wr, sizeof(bad_wr.send_wr))
raise PyverbsRDMAErrno('Failed to post send (returned {rc})'.
format(rc=rc))
--
2.21.0
prev parent reply other threads:[~2019-07-10 14:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-10 14:22 [PATCH rdma-core 0/4] pyverbs fixes Noa Osherovich
2019-07-10 14:22 ` [PATCH rdma-core 1/4] pyverbs: Fix Cython future warning during build Noa Osherovich
2019-07-10 14:22 ` [PATCH rdma-core 2/4] build: Remove warning-causing compilation flag from pyverbs Noa Osherovich
2019-07-10 14:22 ` [PATCH rdma-core 3/4] pyverbs: Avoid casting pointers to object type Noa Osherovich
2019-07-10 14:22 ` Noa Osherovich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190710142251.9396-5-noaos@mellanox.com \
--to=noaos@mellanox.com \
--cc=dledford@redhat.com \
--cc=jgg@mellanox.com \
--cc=leonro@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=maorg@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).