From patchwork Tue Jan 28 07:04:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 3545421 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A92C19F381 for ; Tue, 28 Jan 2014 07:05:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CD39C20131 for ; Tue, 28 Jan 2014 07:05:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DDE162013A for ; Tue, 28 Jan 2014 07:05:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754583AbaA1HFt (ORCPT ); Tue, 28 Jan 2014 02:05:49 -0500 Received: from cmexedge2.ext.emulex.com ([138.239.224.100]:53204 "EHLO CMEXEDGE2.ext.emulex.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754574AbaA1HFt (ORCPT ); Tue, 28 Jan 2014 02:05:49 -0500 Received: from CMEXHTCAS2.ad.emulex.com (138.239.115.218) by CMEXEDGE2.ext.emulex.com (138.239.224.100) with Microsoft SMTP Server (TLS) id 14.3.174.1; Mon, 27 Jan 2014 23:06:27 -0800 Received: from localhost.localdomain (10.192.201.1) by smtp.emulex.com (138.239.115.208) with Microsoft SMTP Server id 14.3.174.1; Mon, 27 Jan 2014 23:05:42 -0800 From: Somnath Kotur To: CC: , Somnath Kotur Subject: [PATCH v2] IB/CMA: Fix initialization of hop_limit instead of hardcode to 1. Date: Tue, 28 Jan 2014 12:34:09 +0530 X-Mailer: git-send-email 1.6.0.2 MIME-Version: 1.0 Message-ID: <90ba6b41-2a1a-4419-bb49-4ed8c216e2a7@CMEXHTCAS2.ad.emulex.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP As suggested by Sean Hefty, take into account src/dst addresses on different subnets and set hop_limit in cma_resolve_iboe_route accordingly instead of blind hardcode to 1 or any other value. Signed-off-by: Somnath Kotur --- Incorporated comments by Sean Hefty drivers/infiniband/core/addr.c | 5 +++++ drivers/infiniband/core/cma.c | 2 +- include/rdma/ib_addr.h | 1 + 3 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index e90f2b2..6fa4721 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -250,6 +250,8 @@ static int addr4_resolve(struct sockaddr_in *src_in, goto put; } + addr->uses_gateway = rt->rt_uses_gateway; + ret = dst_fetch_ha(&rt->dst, addr, &fl4.daddr); put: ip_rt_put(rt); @@ -263,6 +265,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, struct rdma_dev_addr *addr) { struct flowi6 fl6; + struct rt6_info *rt; struct dst_entry *dst; int ret; @@ -275,6 +278,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, if ((ret = dst->error)) goto put; + rt = (struct rt6_info *)dst; if (ipv6_addr_any(&fl6.saddr)) { ret = ipv6_dev_get_saddr(&init_net, ip6_dst_idev(dst)->dev, &fl6.daddr, 0, &fl6.saddr); @@ -298,6 +302,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in, goto put; } + addr->uses_gateway = rt->rt6i_flags & RTF_GATEWAY; ret = dst_fetch_ha(dst, addr, &fl6.daddr); put: dst_release(dst); diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 8e49db6..ae60104 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -1902,7 +1902,7 @@ static int cma_resolve_iboe_route(struct rdma_id_private *id_priv) iboe_mac_vlan_to_ll(&route->path_rec->sgid, addr->dev_addr.src_dev_addr, vid); iboe_mac_vlan_to_ll(&route->path_rec->dgid, addr->dev_addr.dst_dev_addr, vid); - route->path_rec->hop_limit = 1; + route->path_rec->hop_limit = addr->uses_gateway ? 0xFF : 1; route->path_rec->reversible = 1; route->path_rec->pkey = cpu_to_be16(0xffff); route->path_rec->mtu_selector = IB_SA_EQ; diff --git a/include/rdma/ib_addr.h b/include/rdma/ib_addr.h index f3ac0f2..24bc985 100644 --- a/include/rdma/ib_addr.h +++ b/include/rdma/ib_addr.h @@ -64,6 +64,7 @@ struct rdma_dev_addr { unsigned char dst_dev_addr[MAX_ADDR_LEN]; unsigned char broadcast[MAX_ADDR_LEN]; unsigned short dev_type; + bool uses_gateway; int bound_dev_if; enum rdma_transport_type transport; };