[PATCH rdma-next 06/11] RDMA/core: Use common code flow for IPv4/6 for addr resolve

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Parav Pandit <parav@xxxxxxxxxxxx>

Use common code flow for resolving neighbour and for finding
source addresses.

Signed-off-by: Parav Pandit <parav@xxxxxxxxxxxx>
Reviewed-by: Daniel Jurgens <danielj@xxxxxxxxxxxx>
Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxxxx>
---
 drivers/infiniband/core/addr.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index c9d14d6996b2..cbc64de2d791 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -500,8 +500,8 @@ static int addr_resolve(struct sockaddr *src_in,
 			bool resolve_neigh,
 			u32 seq)
 {
+	struct dst_entry *dst = NULL;
 	struct rtable *rt = NULL;
-	struct dst_entry *dst;
 	int ret;
 
 	if (!addr->net) {
@@ -510,28 +510,26 @@ static int addr_resolve(struct sockaddr *src_in,
 	}
 
 	if (src_in->sa_family == AF_INET) {
-
 		ret = addr4_resolve(src_in, dst_in, addr, &rt);
-		if (ret)
-			return ret;
-
-		ret = rdma_set_src_addr(&rt->dst, dst_in, addr);
-		if (!ret && resolve_neigh)
-			ret = addr_resolve_neigh(&rt->dst, dst_in, addr, seq);
-
-		ip_rt_put(rt);
+		dst = &rt->dst;
 	} else {
 		ret = addr6_resolve(src_in, dst_in, addr, &dst);
-		if (ret)
-			return ret;
+	}
+	if (ret)
+		return ret;
 
-		ret = rdma_set_src_addr(dst, dst_in, addr);
-		if (!ret && resolve_neigh)
-			ret = addr_resolve_neigh(dst, dst_in, addr, seq);
+	ret = rdma_set_src_addr(dst, dst_in, addr);
+	/*
+	 * Resolve neighbor destination address if requested and
+	 * only if src addr translation didn't fail.
+	 */
+	if (!ret && resolve_neigh)
+		ret = addr_resolve_neigh(dst, dst_in, addr, seq);
 
+	if (src_in->sa_family == AF_INET)
+		ip_rt_put(rt);
+	else
 		dst_release(dst);
-	}
-
 	return ret;
 }
 
-- 
2.14.4




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux