[ofa-general] [RFC PATCH] IPv6 preparation by using sockaddr in functions call

Aleksey Senin alekseys at voltaire.com
Tue Aug 5 04:14:47 PDT 2008


In order to prepare RDMA CM work with IPv6 these functions changed
obtain as argument struct sockaddr * pointer and not sockaddr_in

 addr_resolve_remote
 addr_resolve_local
 rdma_resolve_ip

Changes in process_req function are side effect of modifications in
functions above.

I would like to get a comments how to realize address resolution. Should I expand existing
existing functions ( addr_resolve_local, etc. ) and perform all changes inside of it, or rename
existing to addr4_resolve_XXX and write wrapper for them that will analyze sa_family and call 
proper function? 


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

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index c5b623b..b59ad53 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -171,12 +171,12 @@ static void addr_send_arp(struct sockaddr_in *dst_in)
 	ip_rt_put(rt);
 }
 
-static int addr_resolve_remote(struct sockaddr_in *src_in,
-			       struct sockaddr_in *dst_in,
+static int addr_resolve_remote(struct sockaddr *src_in,
+			       struct sockaddr *dst_in,
 			       struct rdma_dev_addr *addr)
 {
-	__be32 src_ip = src_in->sin_addr.s_addr;
-	__be32 dst_ip = dst_in->sin_addr.s_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;
 	struct flowi fl;
 	struct rtable *rt;
 	struct neighbour *neigh;
@@ -207,8 +207,8 @@ static int addr_resolve_remote(struct sockaddr_in *src_in,
 	}
 
 	if (!src_ip) {
-		src_in->sin_family = dst_in->sin_family;
-		src_in->sin_addr.s_addr = rt->rt_src;
+		src_in->sa_family = dst_in->sa_family;
+		((struct sockaddr_in *)src_in)->sin_addr.s_addr = rt->rt_src;
 	}
 
 	ret = rdma_copy_addr(addr, neigh->dev, neigh->ha);
@@ -223,7 +223,7 @@ out:
 static void process_req(struct work_struct *work)
 {
 	struct addr_req *req, *temp_req;
-	struct sockaddr_in *src_in, *dst_in;
+	struct sockaddr *src_in, *dst_in;
 	struct list_head done_list;
 
 	INIT_LIST_HEAD(&done_list);
@@ -231,8 +231,8 @@ static void process_req(struct work_struct *work)
 	mutex_lock(&lock);
 	list_for_each_entry_safe(req, temp_req, &req_list, list) {
 		if (req->status == -ENODATA) {
-			src_in = (struct sockaddr_in *) &req->src_addr;
-			dst_in = (struct sockaddr_in *) &req->dst_addr;
+			src_in = (struct sockaddr *) &req->src_addr;
+			dst_in = (struct sockaddr *) &req->dst_addr;
 			req->status = addr_resolve_remote(src_in, dst_in,
 							  req->addr);
 			if (req->status && time_after_eq(jiffies, req->timeout))
@@ -251,20 +251,20 @@ static void process_req(struct work_struct *work)
 
 	list_for_each_entry_safe(req, temp_req, &done_list, list) {
 		list_del(&req->list);
-		req->callback(req->status, &req->src_addr, req->addr,
-			      req->context);
+		req->callback(req->status, (struct sockaddr *) &req->src_addr, \
+			req->addr, req->context);
 		put_client(req->client);
 		kfree(req);
 	}
 }
 
-static int addr_resolve_local(struct sockaddr_in *src_in,
-			      struct sockaddr_in *dst_in,
+static int addr_resolve_local(struct sockaddr *src_in,
+			      struct sockaddr *dst_in,
 			      struct rdma_dev_addr *addr)
 {
 	struct net_device *dev;
-	__be32 src_ip = src_in->sin_addr.s_addr;
-	__be32 dst_ip = dst_in->sin_addr.s_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;
 	int ret;
 
 	dev = ip_dev_find(&init_net, dst_ip);
@@ -272,15 +272,15 @@ static int addr_resolve_local(struct sockaddr_in *src_in,
 		return -EADDRNOTAVAIL;
 
 	if (ipv4_is_zeronet(src_ip)) {
-		src_in->sin_family = dst_in->sin_family;
-		src_in->sin_addr.s_addr = dst_ip;
+		src_in->sa_family = dst_in->sa_family;
+		((struct sockaddr_in *)src_in)->sin_addr.s_addr = dst_ip;
 		ret = rdma_copy_addr(addr, dev, dev->dev_addr);
 	} else if (ipv4_is_loopback(src_ip)) {
-		ret = rdma_translate_ip((struct sockaddr *)dst_in, addr);
+		ret = rdma_translate_ip(dst_in, addr);
 		if (!ret)
 			memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
 	} else {
-		ret = rdma_translate_ip((struct sockaddr *)src_in, addr);
+		ret = rdma_translate_ip(src_in, addr);
 		if (!ret)
 			memcpy(addr->dst_dev_addr, dev->dev_addr, MAX_ADDR_LEN);
 	}
@@ -296,7 +296,7 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
 				     struct rdma_dev_addr *addr, void *context),
 		    void *context)
 {
-	struct sockaddr_in *src_in, *dst_in;
+	struct sockaddr *src_in, *dst_in;
 	struct addr_req *req;
 	int ret = 0;
 
@@ -313,8 +313,8 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
 	req->client = client;
 	atomic_inc(&client->refcount);
 
-	src_in = (struct sockaddr_in *) &req->src_addr;
-	dst_in = (struct sockaddr_in *) &req->dst_addr;
+	src_in = (struct sockaddr *) &req->src_addr;
+	dst_in = (struct sockaddr *) &req->dst_addr;
 
 	req->status = addr_resolve_local(src_in, dst_in, addr);
 	if (req->status == -EADDRNOTAVAIL)
@@ -328,7 +328,7 @@ int rdma_resolve_ip(struct rdma_addr_client *client,
 	case -ENODATA:
 		req->timeout = msecs_to_jiffies(timeout_ms) + jiffies;
 		queue_req(req);
-		addr_send_arp(dst_in);
+		addr_send_arp((struct sockaddr_in *)dst_in);
 		break;
 	default:
 		ret = req->status;
-- 
1.5.6.dirty





More information about the general mailing list