[ofw] [PATCH 1/3] DAPL v2.0: scm: when hostname has loopback addr assigned, default to eth0 instead of failing

Davis, Arlin R arlin.r.davis at intel.com
Wed Oct 26 14:10:24 PDT 2011


Cleanup some SCM bugs.

There are some cases where the eth0 device is configured with an IP address
but the getaddrinfo() will only return loopback address because the
hostname is configured in the /etc/hosts file with 127.0.0.1. In this case,
the provider will now retry address on eth0 before failing the open.

Signed-off-by: Arlin Davis <arlin.r.davis at intel.com>
---
 dapl/openib_common/util.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/dapl/openib_common/util.c b/dapl/openib_common/util.c
index 29fc12f..053c376 100644
--- a/dapl/openib_common/util.c
+++ b/dapl/openib_common/util.c
@@ -160,14 +160,15 @@ DAT_RETURN getlocalipaddr(char *addr, int addr_len)
 	char hostname[256];
 	char *netdev = getenv("DAPL_SCM_NETDEV");
 
+retry:
 	/* use provided netdev instead of default hostname */
 	if (netdev != NULL) {
 		ret = getipaddr_netdev(netdev, addr, addr_len);
 		if (ret) {			
 			dapl_log(DAPL_DBG_TYPE_ERR,
-				 " getlocalipaddr: DAPL_SCM_NETDEV provided %s"
-				" but not configured on system? ERR = %s\n",
-				netdev, strerror(ret));
+				 " getlocalipaddr: NETDEV = %s"
+				 " but not configured on system? ERR = %s\n",
+				 netdev, strerror(ret));
 			return dapl_convert_errno(ret, "getlocalipaddr");
 		} else 
 			return DAT_SUCCESS;
@@ -205,6 +206,13 @@ DAT_RETURN getlocalipaddr(char *addr, int addr_len)
 	}
 
 	freeaddrinfo(res);
+
+	/* only loopback found, retry netdev eth0 */
+	if (ret == DAT_INVALID_ADDRESS) {
+		netdev = "eth0";
+		goto retry;
+	}
+
 	return ret;
 }
 
-- 
1.7.3





More information about the ofw mailing list