public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] link-local address fix for rdma_resolve_addr
@ 2009-10-19 22:47 David J. Wilder
       [not found] ` <1255992430.12075.7.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
  0 siblings, 1 reply; 44+ messages in thread
From: David J. Wilder @ 2009-10-19 22:47 UTC (permalink / raw)
  To: sean.hefty-ral2JQCrhuEAvxtiuMwx3w, rdreier-FYB4Gu1CFyUAvxtiuMwx3w,
	linux-rdma, pradeep-r/Jw6+rmf7HQT0dZR+AlfA,
	ewg-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5

Sean, Roland

Here is the updated patch that Jason and I discussed last week.

rdma_resolve_addr() returns an error when attempting to resolve ipv6
link-local address.  This patch fixes the handling of link-local address.

The patch was tested using rping run as such:

Link-local with scope:
# /usr/bin/rping -c -a <remote-system-link-local>%ib0

Link-local w/out scope: (expect failure)
# /usr/bin/rping -c -a <remote-system-link-local>
rdma_resolve_addr error -1

Own interface link local:
# /usr/bin/rping -c -a <remote-system-link-local>%ib0

Other ipv6 address:
# /usr/bin/rping -c -a 2001:db8:1234::2

(server side started with rping -s -P -v -a ::0)

Tested against ofed build OFED-1.5-20091019-0811 and kernel 2.6.30.

Signed-off-by: David Wilder <dwilder-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>

------------------------------------------------------
 drivers/infiniband/core/addr.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

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);


--
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] 44+ messages in thread
* [PATCH]  link-local address fix for rdma_resolve_addr
@ 2009-10-13 22:09 David J. Wilder
       [not found] ` <1255471781.14513.7.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
  0 siblings, 1 reply; 44+ messages in thread
From: David J. Wilder @ 2009-10-13 22:09 UTC (permalink / raw)
  To: ewg-ZwoEplunGu1OwGhvXhtEPSCwEArCW2h5, linux-rdma,
	pradeep-r/Jw6+rmf7HQT0dZR+AlfA, wilder-r/Jw6+rmf7HQT0dZR+AlfA

Here is a patch to addr6_resolve_remote() to correctly handle link-local address.
It should cover all the conditions Jason described. 

With this patch rping works as expected.

Link-local with scope:
# /usr/bin/rping -c -a fe80::202:c903:1:1925%ib0
 
Link-local w/out scope:
# /usr/bin/rping -c  -a fe80::202:c903:1:1925
rdma_resolve_addr error -1

Other ipv6 address:
# /usr/bin/rping -c -a 2001:db8:1234::2
 
(server side started with rping -s -P -v -a ::0)

Signed-off-by: David Wilder <dwilder-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
-----------------------------------------------------------------

--- drivers/infiniband/core/addr.c.1759	2009-10-13 15:57:48.000000000 -0500
+++ drivers/infiniband/core/addr.c	2009-10-13 16:11:02.000000000 -0500
@@ -278,6 +278,15 @@ static int addr6_resolve_remote(struct s
 	fl.nl_u.ip6_u.daddr = dst_in->sin6_addr;
 	fl.nl_u.ip6_u.saddr = src_in->sin6_addr;
 
+	if (ipv6_addr_type(&dst_in->sin6_addr) & IPV6_ADDR_LINKLOCAL){
+		if (!dst_in->sin6_scope_id)
+			return -EINVAL;
+		if ( src_in->sin6_scope_id &&
+			(src_in->sin6_scope_id != dst_in->sin6_scope_id))
+			return -EINVAL;
+		fl.oif = dst_in->sin6_scope_id;
+	}
+
 	dst = ip6_route_output(&init_net, NULL, &fl);
 	if (!dst)
 		return ret;

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

end of thread, other threads:[~2009-10-28 14:33 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-19 22:47 [PATCH] link-local address fix for rdma_resolve_addr David J. Wilder
     [not found] ` <1255992430.12075.7.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-19 23:43   ` Jason Gunthorpe
     [not found]     ` <20091019234329.GC9643-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-19 23:47       ` Sean Hefty
     [not found]         ` <676AB781CD644CC28E1AD4951EA4EEF8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-20  0:33           ` Jason Gunthorpe
     [not found]             ` <20091020003344.GA14520-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-21 22:30               ` David J. Wilder
     [not found]                 ` <1256164230.12075.31.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-21 23:08                   ` Jason Gunthorpe
     [not found]                     ` <20091021230845.GR14520-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-22 21:12                       ` David J. Wilder
     [not found]                         ` <1256245942.12075.46.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-22 22:02                           ` Sean Hefty
     [not found]                             ` <660D538F30E647F3AE1E5E6C1ACBE882-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-27 18:22                               ` David J. Wilder
     [not found]                                 ` <1256667738.16192.1.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-27 18:58                                   ` [PATCH] librdmacm/cmatose: add support for ipv6 Sean Hefty
     [not found]                                     ` <EE6710D62B854E4FBA82524DEB84E8DC-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-27 19:42                                       ` Sean Hefty
2009-10-27 21:50                                       ` David J. Wilder
2009-10-21 23:17                   ` [PATCH] link-local address fix for rdma_resolve_addr Sean Hefty
     [not found]                     ` <9D257695083141E79685CB2B260D7D7C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-21 23:36                       ` Jason Gunthorpe
     [not found]                         ` <20091021233639.GS14520-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-21 23:46                           ` Jason Gunthorpe
2009-10-21 23:58                           ` Sean Hefty
     [not found]                             ` <BFF5CD71FFA74BF09A2EED5F3319F370-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-22  0:28                               ` Jason Gunthorpe
     [not found]                                 ` <20091022002846.GU14520-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-22  0:40                                   ` Sean Hefty
     [not found]                                     ` <4803112A5B7A4953B62ABAFD1BBD9881-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-22  1:19                                       ` Jason Gunthorpe
     [not found]                                         ` <20091022011939.GW14520-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-22  5:24                                           ` Sean Hefty
     [not found]                                             ` <60E9443821EE4FFA90448DF5CC1368A8-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-22  6:25                                               ` Jason Gunthorpe
     [not found]                                                 ` <20091022062531.GB26003-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-22  6:49                                                   ` Sean Hefty
     [not found]                                                     ` <B1D32A650C2F400E92AFC4909D8880A0-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-22 16:47                                                       ` Jason Gunthorpe
     [not found]                                                         ` <20091022164717.GG26003-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-22 17:59                                                           ` Sean Hefty
     [not found]                                                             ` <A03920DE5BAE4309BAFC1B6471AE928C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-22 18:22                                                               ` Jason Gunthorpe
     [not found]                                                                 ` <20091022182221.GZ14520-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-22 18:31                                                                   ` Sean Hefty
     [not found]                                                                     ` <60293EE44E7243B59C41498F20D558A0-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-10-22 18:40                                                                       ` Jason Gunthorpe
2009-10-25 11:52                                                   ` Or Gerlitz
     [not found]                                                     ` <4AE43BED.3090405-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2009-10-25 20:03                                                       ` Jason Gunthorpe
     [not found]                                                         ` <20091025200332.GN26003-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-27 13:01                                                           ` Or Gerlitz
     [not found]                                                             ` <4AE6EF44.5040004-smomgflXvOZWk0Htik3J/w@public.gmane.org>
2009-10-27 17:14                                                               ` Jason Gunthorpe
     [not found]                                                                 ` <20091027171403.GP26003-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-28 14:33                                                                   ` Or Gerlitz
  -- strict thread matches above, loose matches on Subject: below --
2009-10-13 22:09 David J. Wilder
     [not found] ` <1255471781.14513.7.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-13 23:12   ` Jason Gunthorpe
     [not found]     ` <20091013231234.GK5191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-14 16:23       ` David J. Wilder
     [not found]         ` <1255537437.14513.28.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-14 17:01           ` Jason Gunthorpe
     [not found]             ` <20091014170155.GL5191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-14 17:30               ` David J. Wilder
     [not found]                 ` <1255541405.5111.14.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-14 17:40                   ` Jason Gunthorpe
     [not found]                     ` <20091014174017.GM5191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-15 19:27                       ` David J. Wilder
     [not found]                         ` <1255634841.5111.40.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-15 21:32                           ` Jason Gunthorpe
     [not found]                             ` <20091015213205.GV5191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2009-10-16 18:54                               ` David J. Wilder
     [not found]                                 ` <1255719280.14675.30.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-16 19:28                                   ` Jason Gunthorpe
2009-10-14 19:33               ` David J. Wilder
     [not found]                 ` <1255548798.5111.24.camel-XfwDJb4SXxnMbYB6QlFGEg@public.gmane.org>
2009-10-14 20:09                   ` Jason Gunthorpe

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