[PATCH] link-local address fix for rdma_resolve_addr

David J. Wilder
2009-10-13T22:09:40Z

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;