infiniband: Appease Coverty

Coverity claims the call to rdma_gid2ip in cma_igmp_send overwrites addr.
Use a consistent definition of sockaddr to prevent detections and code
changes in the future.

Submitted by:	bret_ketchum@dell.com
Reported by:	Coverity
Reviewed by:	hselasky, kib
MFC after:	2 weeks
Sponsored by:	Dell EMC Isilon
Differential Revision:	https://reviews.freebsd.org/D26229
This commit is contained in:
vangyzen 2020-08-31 16:17:28 +00:00
parent 242dc4660b
commit 8b9d289826
4 changed files with 13 additions and 17 deletions

View File

@ -860,11 +860,7 @@ int rdma_addr_find_l2_eth_by_grh(const union ib_gid *sgid,
struct rdma_dev_addr dev_addr;
struct resolve_cb_context ctx;
union {
struct sockaddr _sockaddr;
struct sockaddr_in _sockaddr_in;
struct sockaddr_in6 _sockaddr_in6;
} sgid_addr, dgid_addr;
union rdma_sockaddr sgid_addr, dgid_addr;
rdma_gid2ip(&sgid_addr._sockaddr, sgid);
rdma_gid2ip(&dgid_addr._sockaddr, dgid);

View File

@ -450,18 +450,15 @@ static int cma_igmp_send(struct net_device *ndev, const union ib_gid *mgid, bool
int retval;
if (ndev) {
union {
struct sockaddr sock;
struct sockaddr_storage storage;
} addr;
union rdma_sockaddr addr;
rdma_gid2ip(&addr.sock, mgid);
rdma_gid2ip(&addr._sockaddr, mgid);
CURVNET_SET_QUIET(ndev->if_vnet);
if (join)
retval = -if_addmulti(ndev, &addr.sock, NULL);
retval = -if_addmulti(ndev, &addr._sockaddr, NULL);
else
retval = -if_delmulti(ndev, &addr.sock);
retval = -if_delmulti(ndev, &addr._sockaddr);
CURVNET_RESTORE();
} else {
retval = -ENODEV;

View File

@ -668,11 +668,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 port_num,
struct rdma_dev_addr dev_addr = {.bound_dev_if = rec->ifindex,
.net = rec->net ? rec->net :
&init_net};
union {
struct sockaddr _sockaddr;
struct sockaddr_in _sockaddr_in;
struct sockaddr_in6 _sockaddr_in6;
} sgid_addr, dgid_addr;
union rdma_sockaddr sgid_addr, dgid_addr;
if (!device->get_netdev)
return -EOPNOTSUPP;

View File

@ -57,6 +57,13 @@ struct rdma_addr_client {
struct completion comp;
};
union rdma_sockaddr {
struct sockaddr _sockaddr;
struct sockaddr_in _sockaddr_in;
struct sockaddr_in6 _sockaddr_in6;
struct sockaddr_storage _sockaddr_ss;
};
/**
* rdma_addr_register_client - Register an address client.
*/