[ofa-general] [RDMA CM IPv6 support. PATCHv3 9/9] Remote IPv6 resolution

Aleksey Senin alekseys at voltaire.com
Wed Aug 13 01:19:21 PDT 2008


>From ff5fb35f1e78bdfefab4702ab33127ca28de20ae Mon Sep 17 00:00:00 2001
From: Aleksey Senin <alekseys at voltaire.com>
Date: Wed, 13 Aug 2008 10:53:24 +0300
Subject: [RDMA CM IPv6 support. PATCHv3 9/9] Remote IPv6 resolution

Added remote address resolusion for RDMA CM
Function addr_resolve_remote used as wrapper for two other functions

addr4_resolve_remote ( original addr_resolve_remote )
addr6_resolve_remote ( new function )


It seems like in the one of previews patches arguments changed to sockaddr and
now switched back, but it's not true. It happens because of function names have
heen changed.

Signed-off-by: Aleksey Senin <alekseys at voltaire.com>
---
 drivers/infiniband/core/addr.c |   53 +++++++++++++++++++++++++++++++++++----
 1 files changed, 47 insertions(+), 6 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index c949ab0..83987e7 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -204,12 +204,12 @@ static void addr_send_arp(struct sockaddr *dst_in)
 	}
 }
 
-static int addr_resolve_remote(struct sockaddr *src_in,
-			       struct sockaddr *dst_in,
+static int addr4_resolve_remote(struct sockaddr_in *src_in,
+			       struct sockaddr_in *dst_in,
 			       struct rdma_dev_addr *addr)
 {
-	__be32 src_ip = ((struct sockaddr_in *)src_in)->sin_addr.s_addr;
-	__be32 dst_ip = ((struct sockaddr_in *)dst_in)->sin_addr.s_addr;
+	__be32 src_ip = src_in->sin_addr.s_addr;
+	__be32 dst_ip = dst_in->sin_addr.s_addr;
 	struct flowi fl;
 	struct rtable *rt;
 	struct neighbour *neigh;
@@ -240,8 +240,8 @@ static int addr_resolve_remote(struct sockaddr *src_in,
 	}
 
 	if (!src_ip) {
-		src_in->sa_family = dst_in->sa_family;
-		((struct sockaddr_in *)src_in)->sin_addr.s_addr = rt->rt_src;
+		src_in->sin_family = dst_in->sin_family;
+		src_in->sin_addr.s_addr = rt->rt_src;
 	}
 
 	ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
@@ -253,6 +253,47 @@ out:
 	return ret;
 }
 
+static int addr6_resolve_remote(struct sockaddr_in6 *src_in,
+			       struct sockaddr_in6 *dst_in,
+			       struct rdma_dev_addr *addr)
+{
+	struct flowi fl;
+	struct neighbour *neigh;
+	struct dst_entry *dst;
+	int ret = -ENODATA;
+
+	memset(&fl, 0, sizeof fl);
+	fl.nl_u.ip6_u.daddr = dst_in->sin6_addr;
+	fl.nl_u.ip6_u.saddr = src_in->sin6_addr;
+
+	dst = ip6_route_output(&init_net, NULL, &fl);
+	if (!dst)
+		return ret;
+
+	if (dst->dev->flags & IFF_NOARP) {
+		ret = rdma_copy_addr(addr, dst->dev, NULL);
+	} else {
+		neigh = dst->neighbour;
+		if (neigh && (neigh->nud_state & NUD_VALID))
+			ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
+	}
+
+	dst_release(dst);
+	return ret;
+}
+
+static int addr_resolve_remote(struct sockaddr *src_in,
+				struct sockaddr *dst_in,
+				struct rdma_dev_addr *addr)
+{
+	if (src_in->sa_family == AF_INET) {
+		return addr4_resolve_remote((struct sockaddr_in *)src_in,
+			(struct sockaddr_in *)dst_in, addr);
+	} else
+		return addr6_resolve_remote((struct sockaddr_in6 *)src_in,
+			(struct sockaddr_in6 *)dst_in, addr);
+}
+
 static void process_req(struct work_struct *work)
 {
 	struct addr_req *req, *temp_req;
-- 
1.5.6.dirty





More information about the general mailing list