Commit 783793b5 authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe

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: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarDaniel Jurgens <danielj@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent 77addc52
...@@ -500,8 +500,8 @@ static int addr_resolve(struct sockaddr *src_in, ...@@ -500,8 +500,8 @@ static int addr_resolve(struct sockaddr *src_in,
bool resolve_neigh, bool resolve_neigh,
u32 seq) u32 seq)
{ {
struct dst_entry *dst = NULL;
struct rtable *rt = NULL; struct rtable *rt = NULL;
struct dst_entry *dst;
int ret; int ret;
if (!addr->net) { if (!addr->net) {
...@@ -510,28 +510,26 @@ static int addr_resolve(struct sockaddr *src_in, ...@@ -510,28 +510,26 @@ static int addr_resolve(struct sockaddr *src_in,
} }
if (src_in->sa_family == AF_INET) { if (src_in->sa_family == AF_INET) {
ret = addr4_resolve(src_in, dst_in, addr, &rt); ret = addr4_resolve(src_in, dst_in, addr, &rt);
if (ret) dst = &rt->dst;
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);
} else { } else {
ret = addr6_resolve(src_in, dst_in, addr, &dst); ret = addr6_resolve(src_in, dst_in, addr, &dst);
}
if (ret) if (ret)
return ret; return ret;
ret = rdma_set_src_addr(dst, dst_in, addr); 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) if (!ret && resolve_neigh)
ret = addr_resolve_neigh(dst, dst_in, addr, seq); ret = addr_resolve_neigh(dst, dst_in, addr, seq);
if (src_in->sa_family == AF_INET)
ip_rt_put(rt);
else
dst_release(dst); dst_release(dst);
}
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment