Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2018 08:06:17 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r337070 - stable/11/sys/ofed/drivers/infiniband/core
Message-ID:  <201808020806.w7286HqW033812@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Thu Aug  2 08:06:17 2018
New Revision: 337070
URL: https://svnweb.freebsd.org/changeset/base/337070

Log:
  MFC r336364:
  Only update source address when resolving is successful in ibcore.
  
  When resolving an IP address in ibcore, only update the source address
  upon normal completion. The ibcore address resolve function does not
  care about the scope ID value of the IPv6 link-local addresses and expects
  this information has already been extracted into the bound_dev_if field.
  Because the same IPv6 link-local address can exist on multiple interfaces
  the ibcore address resolver gets confused and returns ENETUNREACH.
  
  Instead of updating both source address and bound_dev_if just keep the
  address set to any address until resolving completes. For the sake of code
  symmetry a similar change has been applied to the IPv4 address resolve path.
  
  Sponsored by:		Mellanox Technologies

Modified:
  stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c
==============================================================================
--- stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c	Thu Aug  2 08:05:20 2018	(r337069)
+++ stable/11/sys/ofed/drivers/infiniband/core/ib_addr.c	Thu Aug  2 08:06:17 2018	(r337070)
@@ -257,7 +257,7 @@ static int addr4_resolve(struct sockaddr_in *src_in,
 	};
 	struct sockaddr_in dst_tmp = *dst_in;
 	in_port_t src_port;
-	struct sockaddr *saddr;
+	struct sockaddr *saddr = NULL;
 	struct rtentry *rte;
 	struct ifnet *ifp;
 	int error;
@@ -333,11 +333,6 @@ static int addr4_resolve(struct sockaddr_in *src_in,
 		/* get destination network interface from route */
 		ifp = rte->rt_ifp;
 		dev_hold(ifp);
-
-		/* update source address */
-		src_port = src_in->sin_port;
-		memcpy(src_in, saddr, rdma_addr_size(saddr));
-		src_in->sin_port = src_port;	/* preserve port number */
 		break;
 	default:
 		break;
@@ -369,6 +364,15 @@ static int addr4_resolve(struct sockaddr_in *src_in,
 			addr->network = RDMA_NETWORK_IPV4;
 	}
 
+	/*
+	 * Step 4 - update source address, if any
+	 */
+	if (saddr != NULL) {
+		src_port = src_in->sin_port;
+		memcpy(src_in, saddr, rdma_addr_size(saddr));
+		src_in->sin_port = src_port;	/* preserve port number */
+	}
+
 	if (rte != NULL)
 		RTFREE(rte);
 
@@ -412,7 +416,7 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
 	};
 	struct sockaddr_in6 dst_tmp = *dst_in;
 	in_port_t src_port;
-	struct sockaddr *saddr;
+	struct sockaddr *saddr = NULL;
 	struct rtentry *rte;
 	struct ifnet *ifp;
 	int error;
@@ -502,10 +506,6 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
 		/* get destination network interface from route */
 		ifp = rte->rt_ifp;
 		dev_hold(ifp);
-
-		src_port = src_in->sin6_port;
-		memcpy(src_in, saddr, rdma_addr_size(saddr));
-		src_in->sin6_port = src_port;	/* preserve port number */
 		break;
 	default:
 		break;
@@ -532,6 +532,15 @@ static int addr6_resolve(struct sockaddr_in6 *src_in,
 			goto error_put_ifp;
 		else if (is_gw != 0)
 			addr->network = RDMA_NETWORK_IPV6;
+	}
+
+	/*
+	 * Step 4 - update source address, if any
+	 */
+	if (saddr != NULL) {
+		src_port = src_in->sin6_port;
+		memcpy(src_in, saddr, rdma_addr_size(saddr));
+		src_in->sin6_port = src_port;	/* preserve port number */
 	}
 
 	if (rte != NULL)



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