summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParav Pandit <parav@mellanox.com>2018-09-05 12:54:21 +0300
committerJason Gunthorpe <jgg@mellanox.com>2018-09-12 15:48:08 -0600
commit783793b5543d3b886f0704803198feeb058cccab (patch)
treeb8f30df7b08d12ccceedae4a1de48e167c94c812
parent77addc524473ee9a85d2ef5747a32173c85768d4 (diff)
RDMA/core: Use common code flow for IPv4/6 for addr resolve
Use common code flow for resolving neighbour and for finding source addresses. Signed-off-by: Parav Pandit <parav@mellanox.com> Reviewed-by: Daniel Jurgens <danielj@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
-rw-r--r--drivers/infiniband/core/addr.c32
1 files 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;
}