diff mbox

[v2,2/2] RDMA/core: Initialize port_num in qp_attr

Message ID 1500043291-19768-3-git-send-email-mustafa.ismail@intel.com (mailing list archive)
State Accepted
Headers show

Commit Message

Ismail, Mustafa July 14, 2017, 2:41 p.m. UTC
Initialize the port_num for iWARP in rdma_init_qp_attr.

Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
Cc: <stable@vger.kernel.org> # v2.6.14+
Reviewed-by: Steve Wise <swise@opengridcomputing.com>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
---
 drivers/infiniband/core/cma.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Marciniszyn, Mike July 17, 2017, 7:10 p.m. UTC | #1
> Subject: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
> 
> Initialize the port_num for iWARP in rdma_init_qp_attr.
> 
> Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> Cc: <stable@vger.kernel.org> # v2.6.14+
> Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>

Tested-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kalderon, Michal July 19, 2017, 8:09 a.m. UTC | #2
> From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma-
> owner@vger.kernel.org] On Behalf Of Marciniszyn, Mike
> > Initialize the port_num for iWARP in rdma_init_qp_attr.
> >
> > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > Cc: <stable@vger.kernel.org> # v2.6.14+
> > Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> 
Why is the second patch required if you only validate the port_num if the IB_QP_PORT mask is on? 
Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port number, this one seems
redundant. 

Thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ismail, Mustafa July 19, 2017, 2:38 p.m. UTC | #3
> -----Original Message-----
> From: Kalderon, Michal [mailto:Michal.Kalderon@cavium.com]
> Sent: Wednesday, July 19, 2017 3:10 AM
> To: Marciniszyn, Mike <mike.marciniszyn@intel.com>; Ismail, Mustafa
> <mustafa.ismail@intel.com>; linux-rdma@vger.kernel.org;
> dledford@redhat.com
> Cc: swise@opengridcomputing.com; linux-kernel@vger.kernel.org;
> stable@vger.kernel.org; e1000-rdma@lists.sourceforge.net; Saleem, Shiraz
> <shiraz.saleem@intel.com>; Amrani, Ram <Ram.Amrani@cavium.com>
> Subject: RE: [PATCH v2 2/2] RDMA/core: Initialize port_num in qp_attr
> 
> > From: linux-rdma-owner@vger.kernel.org [mailto:linux-rdma-
> > owner@vger.kernel.org] On Behalf Of Marciniszyn, Mike
> > > Initialize the port_num for iWARP in rdma_init_qp_attr.
> > >
> > > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > > Cc: <stable@vger.kernel.org> # v2.6.14+
> > > Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> > > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> >
> Why is the second patch required if you only validate the port_num if the
> IB_QP_PORT mask is on?
> Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port
> number, this one seems redundant.
Strictly speaking it is not required, but we felt it safer to always return a valid port number
as is done in the IB case.

Regards,

Mustafa
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kalderon, Michal July 19, 2017, 3:09 p.m. UTC | #4
From: Ismail, Mustafa <mustafa.ismail@intel.com>
Sent: Wednesday, July 19, 2017 5:38 PM

> > > > Fixes: 5ecce4c9b17b("Check port number supplied by user verbs cmds")
> > > > Cc: <stable@vger.kernel.org> # v2.6.14+
> > > > Reviewed-by: Steve Wise <swise@opengridcomputing.com>
> > > > Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
> > >
> > Why is the second patch required if you only validate the port_num if the
> > IB_QP_PORT mask is on?
> > Given the first patch [PATCH v2 1/2] RDMA/uverbs: Fix the check for port
> > number, this one seems redundant.
> Strictly speaking it is not required, but we felt it safer to always return a valid port number
> as is done in the IB case.

It's not always initialized in the IB case either. More than that if at this point you'll
initialize it for ib as well you'll get a failure on ib_modify_qp_is_ok, since when
transitioning to RTR  / RTS providing IB_QP_PORT is not a valid option.
We actually hit this issue when running rping over RoCE. (prior to your fix i mean ) 
I agree that in general there's no real harm, but it seems a bit out of context, and if we
make the change common for ib/iwarp we'll have to modify ib_modify_qp_is_ok which 
is written close to the spec. 

thanks,
Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 31bb82d..d65a093 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1044,6 +1044,8 @@  int rdma_init_qp_attr(struct rdma_cm_id *id, struct ib_qp_attr *qp_attr,
 		} else
 			ret = iw_cm_init_qp_attr(id_priv->cm_id.iw, qp_attr,
 						 qp_attr_mask);
+		qp_attr->port_num = id_priv->id.port_num;
+		*qp_attr_mask |= IB_QP_PORT;
 	} else
 		ret = -ENOSYS;