From patchwork Mon Oct 19 22:47:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David J Wilder X-Patchwork-Id: 54850 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9JMlH3L015872 for ; Mon, 19 Oct 2009 22:47:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751411AbZJSWrJ (ORCPT ); Mon, 19 Oct 2009 18:47:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755962AbZJSWrJ (ORCPT ); Mon, 19 Oct 2009 18:47:09 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:36479 "EHLO e6.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751411AbZJSWrJ (ORCPT ); Mon, 19 Oct 2009 18:47:09 -0400 Received: from d01relay03.pok.ibm.com (d01relay03.pok.ibm.com [9.56.227.235]) by e6.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9JMqLtI021310 for ; Mon, 19 Oct 2009 18:52:21 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9JMlDvh188690 for ; Mon, 19 Oct 2009 18:47:13 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id n9JMlAKX002477 for ; Mon, 19 Oct 2009 18:47:11 -0400 Received: from [9.65.55.79] (sig-9-65-55-79.mts.ibm.com [9.65.55.79]) by d01av02.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id n9JMl9Cd002342; Mon, 19 Oct 2009 18:47:10 -0400 Subject: [PATCH] link-local address fix for rdma_resolve_addr From: "David J. Wilder" To: sean.hefty@intel.com, rdreier@cisco.com, linux-rdma , pradeep@us.ibm.com, ewg@lists.openfabrics.org Date: Mon, 19 Oct 2009 15:47:09 -0700 Message-Id: <1255992430.12075.7.camel@wilder.ibm.com> Mime-Version: 1.0 X-Mailer: Evolution 2.12.3 (2.12.3-8.el5_2.2) Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index bd07803..3442256 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -278,6 +278,21 @@ static int addr6_resolve_remote(struct sockaddr_in6 *src_in, fl.nl_u.ip6_u.daddr = dst_in->sin6_addr; fl.nl_u.ip6_u.saddr = src_in->sin6_addr; + if (ipv6_addr_type(&src_in->sin6_addr) & IPV6_ADDR_LINKLOCAL) { + if (!src_in->sin6_scope_id) + return -EINVAL; + fl.oif = src_in->sin6_scope_id; + } + if (ipv6_addr_type(&dst_in->sin6_addr) & IPV6_ADDR_LINKLOCAL) { + if (dst_in->sin6_scope_id) { + if (fl.oif && fl.oif != dst_in->sin6_scope_id) + return -EINVAL; + fl.oif = dst_in->sin6_scope_id; + } + if (!fl.oif) + return -EINVAL; + } + dst = ip6_route_output(&init_net, NULL, &fl); if (!dst) return ret; @@ -390,14 +405,16 @@ static int addr_resolve_local(struct sockaddr *src_in, case AF_INET6: { struct in6_addr *a; + int found = 0; for_each_netdev(&init_net, dev) if (ipv6_chk_addr(&init_net, &((struct sockaddr_in6 *) dst_in)->sin6_addr, - dev, 1)) + dev, 1)) { + found = 1; break; - - if (!dev) + } + if (!found) return -EADDRNOTAVAIL; a = &((struct sockaddr_in6 *) src_in)->sin6_addr; @@ -406,6 +423,8 @@ static int addr_resolve_local(struct sockaddr *src_in, src_in->sa_family = dst_in->sa_family; ((struct sockaddr_in6 *) src_in)->sin6_addr = ((struct sockaddr_in6 *) dst_in)->sin6_addr; + ((struct sockaddr_in6 *) src_in)->sin6_scope_id = + ((struct sockaddr_in6 *) dst_in)->sin6_scope_id; ret = rdma_copy_addr(addr, dev, dev->dev_addr); } else if (ipv6_addr_loopback(a)) { ret = rdma_translate_ip(dst_in, addr);