Blame SOURCES/4320.patch

5af42d
From a1524608b05e6c89e2b99f64923f064d888465ce Mon Sep 17 00:00:00 2001
5af42d
From: Hui Zhou <hzhou321@anl.gov>
5af42d
Date: Mon, 18 Nov 2019 14:52:55 -0600
5af42d
Subject: [PATCH 1/2] ch3: fix improper error handling from MPL_get_sockaddr
5af42d
5af42d
MPL layer does not directly return mpi_errno. Use MPIR_ERR_CHKANDJUMP
5af42d
macro to create the appropriate return code. See pmodels/mpich#4318.
5af42d
5af42d
Cherry-picked from [8d923937ec5d].
5af42d
---
5af42d
 .../channels/nemesis/netmod/tcp/tcp_init.c    | 23 +++++++++++--------
5af42d
 1 file changed, 13 insertions(+), 10 deletions(-)
5af42d
5af42d
diff --git a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c
5af42d
index 4c2383ed8f..bc58211eb6 100644
5af42d
--- a/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c
5af42d
+++ b/src/mpid/ch3/channels/nemesis/netmod/tcp/tcp_init.c
5af42d
@@ -307,8 +307,9 @@ static int GetSockInterfaceAddr(int myRank, char *ifname, int maxIfname,
5af42d
     if (MPIR_CVAR_NEMESIS_TCP_NETWORK_IFACE) {
5af42d
         char s[100];
5af42d
 	int len;
5af42d
-        mpi_errno = MPL_get_sockaddr_iface(MPIR_CVAR_NEMESIS_TCP_NETWORK_IFACE, p_addr);
5af42d
-        MPIR_ERR_CHKANDJUMP1(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**iface_notfound", "**iface_notfound %s", MPIR_CVAR_NEMESIS_TCP_NETWORK_IFACE);
5af42d
+        int ret = MPL_get_sockaddr_iface(MPIR_CVAR_NEMESIS_TCP_NETWORK_IFACE, p_addr);
5af42d
+        MPIR_ERR_CHKANDJUMP1(ret != 0, mpi_errno, MPI_ERR_OTHER, "**iface_notfound",
5af42d
+                             "**iface_notfound %s", MPIR_CVAR_NEMESIS_TCP_NETWORK_IFACE);
5af42d
 
5af42d
         MPL_sockaddr_to_str(p_addr, s, 100);
5af42d
         MPL_DBG_MSG_FMT(MPIDI_CH3_DBG_CONNECT, VERBOSE, (MPL_DBG_FDEST,
5af42d
@@ -354,12 +355,13 @@ static int GetSockInterfaceAddr(int myRank, char *ifname, int maxIfname,
5af42d
 
5af42d
 	ifname_string = ifname;
5af42d
 
5af42d
-	/* If we didn't find a specific name, then try to get an IP address
5af42d
-	   directly from the available interfaces, if that is supported on
5af42d
-	   this platform.  Otherwise, we'll drop into the next step that uses 
5af42d
-	   the ifname */
5af42d
-	mpi_errno = MPL_get_sockaddr_iface( NULL, p_addr);
5af42d
-        if (mpi_errno) MPIR_ERR_POP(mpi_errno);
5af42d
+        /* If we didn't find a specific name, then try to get an IP address
5af42d
+         * directly from the available interfaces, if that is supported on
5af42d
+         * this platform.  Otherwise, we'll drop into the next step that uses
5af42d
+         * the ifname */
5af42d
+        int ret = MPL_get_sockaddr_iface(NULL, p_addr);
5af42d
+        MPIR_ERR_CHKANDJUMP1(ret != 0, mpi_errno, MPI_ERR_OTHER, "**iface_notfound",
5af42d
+                             "**iface_notfound %s", NULL);
5af42d
         ifaddrFound = 1;
5af42d
     }
5af42d
     else {
5af42d
@@ -369,8 +371,9 @@ static int GetSockInterfaceAddr(int myRank, char *ifname, int maxIfname,
5af42d
 
5af42d
     /* If we don't have an IP address, try to get it from the name */
5af42d
     if (!ifaddrFound) {
5af42d
-        mpi_errno = MPL_get_sockaddr(ifname_string, p_addr);
5af42d
-        MPIR_ERR_CHKANDJUMP2(mpi_errno, mpi_errno, MPI_ERR_OTHER, "**gethostbyname", "**gethostbyname %s %d", ifname_string, h_errno);
5af42d
+        int ret = MPL_get_sockaddr(ifname_string, p_addr);
5af42d
+        MPIR_ERR_CHKANDJUMP2(ret != 0, mpi_errno, MPI_ERR_OTHER, "**gethostbyname",
5af42d
+                             "**gethostbyname %s %d", ifname_string, h_errno);
5af42d
     }
5af42d
 
5af42d
 fn_exit:
5af42d
5af42d
From 89157ad35c0885b4758d250d019f0f7cf0f59095 Mon Sep 17 00:00:00 2001
5af42d
From: Hui Zhou <hzhou321@anl.gov>
5af42d
Date: Wed, 15 Jan 2020 13:29:56 -0600
5af42d
Subject: [PATCH 2/2] pmi: fix a wrong condition checking return of
5af42d
 MPL_get_sockaddr
5af42d
5af42d
Cherry-picked from [3e6af3c2fbaf]. See pmodels/mpich#4318.
5af42d
---
5af42d
 src/mpl/include/mpl_sockaddr.h | 3 +++
5af42d
 src/pmi/simple/simple_pmi.c    | 2 +-
5af42d
 2 files changed, 4 insertions(+), 1 deletion(-)
5af42d
5af42d
diff --git a/src/mpl/include/mpl_sockaddr.h b/src/mpl/include/mpl_sockaddr.h
5af42d
index c0eb749419..a9860c1353 100644
5af42d
--- a/src/mpl/include/mpl_sockaddr.h
5af42d
+++ b/src/mpl/include/mpl_sockaddr.h
5af42d
@@ -21,6 +21,9 @@
5af42d
 
5af42d
 typedef struct sockaddr_storage MPL_sockaddr_t;
5af42d
 
5af42d
+/* The following functions when return an int, it returns 0 on success,
5af42d
+ * non-zero indicates error. It is consistent with posix socket functions.
5af42d
+ */
5af42d
 void MPL_sockaddr_set_aftype(int type);
5af42d
 int MPL_get_sockaddr(const char *s_hostname, MPL_sockaddr_t * p_addr);
5af42d
 int MPL_get_sockaddr_direct(int type, MPL_sockaddr_t * p_addr);
5af42d
diff --git a/src/pmi/simple/simple_pmi.c b/src/pmi/simple/simple_pmi.c
5af42d
index df37a8689f..7f660bdac9 100644
5af42d
--- a/src/pmi/simple/simple_pmi.c
5af42d
+++ b/src/pmi/simple/simple_pmi.c
5af42d
@@ -881,7 +881,7 @@ static int PMII_Connect_to_pm(char *hostname, int portnum)
5af42d
     int q_wait = 1;
5af42d
 
5af42d
     ret = MPL_get_sockaddr(hostname, &addr);
5af42d
-    if (!ret) {
5af42d
+    if (ret) {
5af42d
         PMIU_printf(1, "Unable to get host entry for %s\n", hostname);
5af42d
         return PMI_FAIL;
5af42d
     }