From patchwork Tue Mar 23 18:03:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hefty, Sean" X-Patchwork-Id: 87722 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 o2NI35f9005733 for ; Tue, 23 Mar 2010 18:03:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754083Ab0CWSDE (ORCPT ); Tue, 23 Mar 2010 14:03:04 -0400 Received: from mga09.intel.com ([134.134.136.24]:65071 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754065Ab0CWSDD (ORCPT ); Tue, 23 Mar 2010 14:03:03 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 23 Mar 2010 11:00:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.51,296,1267430400"; d="scan'208";a="502951162" Received: from unknown (HELO msheftyMOBL2) ([10.254.89.25]) by orsmga002.jf.intel.com with ESMTP; 23 Mar 2010 11:02:09 -0700 From: "Sean Hefty" To: "Hefty, Sean" , "linux-rdma" References: <2F3826558E79459EAD2A457A604221C1@amr.corp.intel.com> Subject: [RFC] [PATCH 7/22] [for 2.6.36] rdma/cm: do not modify sa_family when setting loopback address Date: Tue, 23 Mar 2010 11:03:02 -0700 Message-ID: <07356581EBDF4A50823E4DAFBD6BDBDC@amr.corp.intel.com> MIME-Version: 1.0 X-Mailer: Microsoft Office Outlook 11 Thread-Index: AcrKsQISoZCN8VP+SeqPIDQtSiqGcAAAdBHQ X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 In-Reply-To: <2F3826558E79459EAD2A457A604221C1@amr.corp.intel.com> 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]); Tue, 23 Mar 2010 18:03:05 +0000 (UTC) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 0a3bbf9..7981a85 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1776,6 +1776,23 @@ err: } EXPORT_SYMBOL(rdma_resolve_route); +static void cma_set_loopback(struct sockaddr *addr) +{ + switch (addr->sa_family) { + case AF_INET: + ((struct sockaddr_in *) addr)->sin_addr.s_addr = htonl(INADDR_LOOPBACK); + break; + case AF_INET6: + ipv6_addr_set(&((struct sockaddr_in6 *) addr)->sin6_addr, + 0, 0, 0, htonl(1)); + break; + default: + ib_addr_set(&((struct sockaddr_ib *) addr)->sib_addr, + 0, 0, 0, htonl(1)); + break; + } +} + static int cma_bind_loopback(struct rdma_id_private *id_priv) { struct cma_device *cma_dev; @@ -1816,6 +1833,7 @@ port_found: ib_addr_set_pkey(&id_priv->id.route.addr.dev_addr, pkey); id_priv->id.port_num = p; cma_attach_to_dev(id_priv, cma_dev); + cma_set_loopback((struct sockaddr *) &id_priv->id.route.addr.src_addr); out: mutex_unlock(&lock); return ret; @@ -1870,7 +1888,6 @@ out: static int cma_resolve_loopback(struct rdma_id_private *id_priv) { struct cma_work *work; - struct sockaddr *src, *dst; union ib_gid gid; int ret; @@ -1887,18 +1904,6 @@ static int cma_resolve_loopback(struct rdma_id_private *id_priv) rdma_addr_get_sgid(&id_priv->id.route.addr.dev_addr, &gid); rdma_addr_set_dgid(&id_priv->id.route.addr.dev_addr, &gid); - src = (struct sockaddr *) &id_priv->id.route.addr.src_addr; - if (cma_zero_addr(src)) { - dst = (struct sockaddr *) &id_priv->id.route.addr.dst_addr; - if ((src->sa_family = dst->sa_family) == AF_INET) { - ((struct sockaddr_in *) src)->sin_addr.s_addr = - ((struct sockaddr_in *) dst)->sin_addr.s_addr; - } else { - ipv6_addr_copy(&((struct sockaddr_in6 *) src)->sin6_addr, - &((struct sockaddr_in6 *) dst)->sin6_addr); - } - } - work->id = id_priv; INIT_WORK(&work->work, cma_work_handler); work->old_state = CMA_ADDR_QUERY;