public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] IB/cma: cma_match_net_dev needs to take into account port_num
@ 2015-12-21 15:01 Matan Barak
       [not found] ` <1450710084-22547-1-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  0 siblings, 1 reply; 15+ messages in thread
From: Matan Barak @ 2015-12-21 15:01 UTC (permalink / raw)
  To: Doug Ledford
  Cc: linux-rdma-u79uwXL29TY76Z2rM5mHXA, Or Gerlitz, Moni Shoua,
	Haggai Eran, Eran Ben Elisha, Matan Barak

Previously, cma_match_net_dev called cma_protocol_roce which
tried to verify that the IB device uses RoCE protocol. However,
if rdma_id didn't have a bounded port, it used the first port
of the device.

In VPI systems, the first port might be an IB port while the second
one could be an Ethernet port. This made requests for unbounded rdma_ids
that come from the Ethernet port fail.
Fixing this by passing the port of the request and checking this port
of the device.

Fixes: b8cab5dab15f ('IB/cma: Accept connection without a valid netdev on RoCE')
Signed-off-by: Matan Barak <matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
---
Hi Doug,

This patch fixes a bug in VPI systems, where the first port is configured
as IB and the second one is configured as Ethernet.
In this case, if the rdma_id isn't bounded to a port, cma_match_net_dev
will try to verify that the first port is a RoCE port and fail.
This is fixed by passing the port of the incoming request.

Regards,
Matan

 drivers/infiniband/core/cma.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index d2d5d00..c8a265c 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -1265,15 +1265,17 @@ static bool cma_protocol_roce(const struct rdma_cm_id *id)
 	return cma_protocol_roce_dev_port(device, port_num);
 }
 
-static bool cma_match_net_dev(const struct rdma_id_private *id_priv,
-			      const struct net_device *net_dev)
+static bool cma_match_net_dev(const struct rdma_cm_id *id,
+			      const struct net_device *net_dev,
+			      u8 port_num)
 {
-	const struct rdma_addr *addr = &id_priv->id.route.addr;
+	const struct rdma_addr *addr = &id->route.addr;
 
 	if (!net_dev)
 		/* This request is an AF_IB request or a RoCE request */
-		return addr->src_addr.ss_family == AF_IB ||
-		       cma_protocol_roce(&id_priv->id);
+		return (!id->port_num || id->port_num == port_num) &&
+		       (addr->src_addr.ss_family == AF_IB ||
+			cma_protocol_roce_dev_port(id->device, port_num));
 
 	return !addr->dev_addr.bound_dev_if ||
 	       (net_eq(dev_net(net_dev), addr->dev_addr.net) &&
@@ -1295,13 +1297,13 @@ static struct rdma_id_private *cma_find_listener(
 	hlist_for_each_entry(id_priv, &bind_list->owners, node) {
 		if (cma_match_private_data(id_priv, ib_event->private_data)) {
 			if (id_priv->id.device == cm_id->device &&
-			    cma_match_net_dev(id_priv, net_dev))
+			    cma_match_net_dev(&id_priv->id, net_dev, req->port))
 				return id_priv;
 			list_for_each_entry(id_priv_dev,
 					    &id_priv->listen_list,
 					    listen_list) {
 				if (id_priv_dev->id.device == cm_id->device &&
-				    cma_match_net_dev(id_priv_dev, net_dev))
+				    cma_match_net_dev(&id_priv_dev->id, net_dev, req->port))
 					return id_priv_dev;
 			}
 		}
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-12-24  8:18 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-21 15:01 [PATCH] IB/cma: cma_match_net_dev needs to take into account port_num Matan Barak
     [not found] ` <1450710084-22547-1-git-send-email-matanb-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-12-22  6:44   ` Or Gerlitz
2015-12-22  7:17   ` Or Gerlitz
     [not found]     ` <5678F907.7080300-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-12-22 14:42       ` Or Gerlitz
2015-12-22 10:47   ` Or Gerlitz
     [not found]     ` <56792A4B.8060101-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2015-12-22 18:58       ` Doug Ledford
     [not found]         ` <56799D61.9010206-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-12-22 19:26           ` Matan Barak
     [not found]             ` <CAAKD3BDmenFsiZTDiw8OEW-F0GqK62+zJ-TVywyYd4YDtzxrCA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-22 20:01               ` Doug Ledford
     [not found]                 ` <5679AC18.4070002-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-12-23  8:48                   ` Sagi Grimberg
2015-12-23 16:08               ` Doug Ledford
     [not found]                 ` <567AC6E4.3030100-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-12-23 16:20                   ` Matan Barak
2015-12-23 16:35                   ` Matan Barak
     [not found]                     ` <CAAKD3BAt2YBB-Y-VH29w5B7rLfbBEq2EuH6BtDwb0O3W8-PGwg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-23 17:57                       ` Doug Ledford
     [not found]                         ` <567AE07A.10003-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-12-24  7:57                           ` Matan Barak
     [not found]                             ` <CAAKD3BADP_Jf2zNJDcx8YOv1zt4=pp5V+eYugfn-tBuVgFxBCw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-12-24  8:18                               ` Or Gerlitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox