Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 31 Aug 2020 16:17:29 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364997 - in head/sys/ofed: drivers/infiniband/core include/rdma
Message-ID:  <202008311617.07VGHTGO041531@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Mon Aug 31 16:17:28 2020
New Revision: 364997
URL: https://svnweb.freebsd.org/changeset/base/364997

Log:
  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

Modified:
  head/sys/ofed/drivers/infiniband/core/ib_addr.c
  head/sys/ofed/drivers/infiniband/core/ib_cma.c
  head/sys/ofed/drivers/infiniband/core/ib_sa_query.c
  head/sys/ofed/include/rdma/ib_addr.h

Modified: head/sys/ofed/drivers/infiniband/core/ib_addr.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/ib_addr.c	Mon Aug 31 16:07:40 2020	(r364996)
+++ head/sys/ofed/drivers/infiniband/core/ib_addr.c	Mon Aug 31 16:17:28 2020	(r364997)
@@ -860,11 +860,7 @@ int rdma_addr_find_l2_eth_by_grh(const union ib_gid *s
 	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);

Modified: head/sys/ofed/drivers/infiniband/core/ib_cma.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/ib_cma.c	Mon Aug 31 16:07:40 2020	(r364996)
+++ head/sys/ofed/drivers/infiniband/core/ib_cma.c	Mon Aug 31 16:17:28 2020	(r364997)
@@ -450,18 +450,15 @@ static int cma_igmp_send(struct net_device *ndev, cons
 	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;

Modified: head/sys/ofed/drivers/infiniband/core/ib_sa_query.c
==============================================================================
--- head/sys/ofed/drivers/infiniband/core/ib_sa_query.c	Mon Aug 31 16:07:40 2020	(r364996)
+++ head/sys/ofed/drivers/infiniband/core/ib_sa_query.c	Mon Aug 31 16:17:28 2020	(r364997)
@@ -668,11 +668,7 @@ int ib_init_ah_from_path(struct ib_device *device, u8 
 		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;

Modified: head/sys/ofed/include/rdma/ib_addr.h
==============================================================================
--- head/sys/ofed/include/rdma/ib_addr.h	Mon Aug 31 16:07:40 2020	(r364996)
+++ head/sys/ofed/include/rdma/ib_addr.h	Mon Aug 31 16:17:28 2020	(r364997)
@@ -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.
  */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008311617.07VGHTGO041531>