[ofa-general] [RDMA CM IPv6 support. PATCHv3 3/9] IPv6 support in rdma_translate_ip

Aleksey Senin alekseys at voltaire.com
Wed Aug 13 01:09:39 PDT 2008


>From ba9050a683e8c4ede8aa0d0739c6828b9dcf949f Mon Sep 17 00:00:00 2001
From: Aleksey Senin <alekseys at voltaire.com>
Date: Wed, 13 Aug 2008 09:53:16 +0300
Subject: [RDMA CM IPv6 support. PATCHv3 3/9] IPv6 support in rdma_translate_ip

Added support for IPv6 family in rdma_translate_ip function
New function cma_ipv6_dev_find used for searching netdevice with
given IP address

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

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index b59ad53..dd5997b 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -42,6 +42,7 @@
 #include <net/route.h>
 #include <net/netevent.h>
 #include <rdma/ib_addr.h>
+#include <net/addrconf.h>
 
 MODULE_AUTHOR("Sean Hefty");
 MODULE_DESCRIPTION("IB Address Translation");
@@ -110,18 +111,34 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
 }
 EXPORT_SYMBOL(rdma_copy_addr);
 
+static struct net_device *cma_ipv6_dev_find(struct in6_addr *addr)
+{
+	struct net_device *dev;
+	for_each_netdev(&init_net, dev)
+		if (ipv6_chk_addr(&init_net,  addr, dev, 1))
+			return dev;
+	return NULL;
+}
+
 int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
 {
 	struct net_device *dev;
-	__be32 ip = ((struct sockaddr_in *) addr)->sin_addr.s_addr;
-	int ret;
-
-	dev = ip_dev_find(&init_net, ip);
-	if (!dev)
-		return -EADDRNOTAVAIL;
+	int ret = -EADDRNOTAVAIL;
+
+	if (addr->sa_family == AF_INET) {
+		dev = ip_dev_find(&init_net,
+			((struct sockaddr_in *) addr)->sin_addr.s_addr);
+		if (dev) {
+			ret = rdma_copy_addr(dev_addr, dev, NULL);
+			dev_put(dev);
+		}
+	} else {
+		dev = cma_ipv6_dev_find(
+			&((struct sockaddr_in6 *)addr)->sin6_addr);
+		if (dev)
+			ret = rdma_copy_addr(dev_addr, dev, NULL);
+	}
 
-	ret = rdma_copy_addr(dev_addr, dev, NULL);
-	dev_put(dev);
 	return ret;
 }
 EXPORT_SYMBOL(rdma_translate_ip);
-- 
1.5.6.dirty





More information about the general mailing list