Skip to content

Commit 15cbc51

Browse files
paravmellanoxjgunthorpe
authored andcommitted
RDMA/core: Simplify rdma_addr_get_sgid() to not support RoCE
Now that all callers who care about RoCE addresses have been converted to use rdma_read_gids() simplify rdma_addr_get_sgid() to only support real GID addresses. Callers should only use it for OPA and IB transports. The now deleted implementation for RoCE has several bugs related to IPv6 support and incorrect/inconsistent 'GID' addresses compared to the CM paths. Signed-off-by: Parav Pandit <[email protected]> Reviewed-by: Daniel Jurgens <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent a2e812e commit 15cbc51

File tree

1 file changed

+7
-26
lines changed

1 file changed

+7
-26
lines changed

include/rdma/ib_addr.h

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -197,34 +197,15 @@ static inline void rdma_gid2ip(struct sockaddr *out, const union ib_gid *gid)
197197
}
198198
}
199199

200-
static inline void iboe_addr_get_sgid(struct rdma_dev_addr *dev_addr,
201-
union ib_gid *gid)
202-
{
203-
struct net_device *dev;
204-
struct in_device *ip4;
205-
206-
dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
207-
if (dev) {
208-
ip4 = in_dev_get(dev);
209-
if (ip4 && ip4->ifa_list && ip4->ifa_list->ifa_address)
210-
ipv6_addr_set_v4mapped(ip4->ifa_list->ifa_address,
211-
(struct in6_addr *)gid);
212-
213-
if (ip4)
214-
in_dev_put(ip4);
215-
216-
dev_put(dev);
217-
}
218-
}
219-
200+
/*
201+
* rdma_get/set_sgid/dgid() APIs are applicable to IB, and iWarp.
202+
* They are not applicable to RoCE.
203+
* RoCE GIDs are derived from the IP addresses.
204+
*/
220205
static inline void rdma_addr_get_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)
221206
{
222-
if (dev_addr->transport == RDMA_TRANSPORT_IB &&
223-
dev_addr->dev_type != ARPHRD_INFINIBAND)
224-
iboe_addr_get_sgid(dev_addr, gid);
225-
else
226-
memcpy(gid, dev_addr->src_dev_addr +
227-
rdma_addr_gid_offset(dev_addr), sizeof *gid);
207+
memcpy(gid, dev_addr->src_dev_addr + rdma_addr_gid_offset(dev_addr),
208+
sizeof(*gid));
228209
}
229210

230211
static inline void rdma_addr_set_sgid(struct rdma_dev_addr *dev_addr, union ib_gid *gid)

0 commit comments

Comments
 (0)