From patchwork Thu Apr 1 17:08:41 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 90196 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o31H8iDa030454 for ; Thu, 1 Apr 2010 17:08:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757610Ab0DARIz (ORCPT ); Thu, 1 Apr 2010 13:08:55 -0400 Received: from mga11.intel.com ([192.55.52.93]:44648 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754140Ab0DARIy (ORCPT ); Thu, 1 Apr 2010 13:08:54 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP; 01 Apr 2010 10:08:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,349,1267430400"; d="scan'208";a="785809604" Received: from unknown (HELO msheftyMOBL2) ([10.254.108.159]) by fmsmga001.fm.intel.com with ESMTP; 01 Apr 2010 10:08:52 -0700 From: "Sean Hefty" To: "Hefty, Sean" , References: Subject: [PATCH 12/26] rdma/cm: restrict AF_IB loopback to binding to IB devices only Date: Thu, 1 Apr 2010 10:08:41 -0700 Message-ID: <345CC3FB3F8741D78696D2CD8D8F7446@amr.corp.intel.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcrRtMZV7yVukZHyQqa3gseqBpR7/wABAO1Q In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 01 Apr 2010 17:08:57 +0000 (UTC) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 224b817..7179409 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1794,26 +1794,40 @@ static void cma_set_loopback(struct sockaddr *addr) static int cma_bind_loopback(struct rdma_id_private *id_priv) { - struct cma_device *cma_dev; + struct cma_device *cma_dev, *cur_dev; + struct sockaddr *addr; struct ib_port_attr port_attr; union ib_gid gid; u16 pkey; int ret; u8 p; + cma_dev = NULL; + addr = (struct sockaddr *) &id_priv->id.route.addr.src_addr; mutex_lock(&lock); - if (list_empty(&dev_list)) { + list_for_each_entry(cur_dev, &dev_list, list) { + if (addr->sa_family == AF_IB && + rdma_node_get_transport(cur_dev->device->node_type) != RDMA_TRANSPORT_IB) + continue; + + if (!cma_dev) + cma_dev = cur_dev; + + for (p = 1; p <= cur_dev->device->phys_port_cnt; ++p) { + if (!ib_query_port(cur_dev->device, p, &port_attr) && + port_attr.state == IB_PORT_ACTIVE) { + cma_dev = cur_dev; + goto port_found; + } + } + } + + if (!cma_dev) { ret = -ENODEV; goto out; } - list_for_each_entry(cma_dev, &dev_list, list) - for (p = 1; p <= cma_dev->device->phys_port_cnt; ++p) - if (!ib_query_port(cma_dev->device, p, &port_attr) && - port_attr.state == IB_PORT_ACTIVE) - goto port_found; p = 1; - cma_dev = list_entry(dev_list.next, struct cma_device, list); port_found: ret = ib_get_cached_gid(cma_dev->device, p, 0, &gid);