[ofa-general] [RMDA CM IPv6 support. PATCHv4 6/6] Remote IPv6 resolution
Aleksey Senin
alekseys at voltaire.com
Wed Nov 26 09:59:31 PST 2008
>From 34464092a263d339c919432b1e4495dce36ee568 Mon Sep 17 00:00:00 2001
From: Aleksey Senin <alekseys at voltaire.com>
Date: Wed, 26 Nov 2008 18:24:35 +0200
Subject: [PATCH] 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 )
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 460dcc2..16ffd49 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -203,12 +203,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;
@@ -239,8 +239,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);
@@ -252,6 +252,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