/* * dapls_create_gid_map() * * Read /usr/local/etc/ibhosts to obtain host names and GIDs. * Create a table containing IP addresses and GIDs which can * be used for lookups. * * This implementation is a simple method providing name services * when more advanced mechanisms do not exist. The proper way * to obtain these mappings is to use a name service such as is * provided by IPoIB on InfiniBand. * * Input: * device_name Name of device as reported by the provider * * Output: * none * * Returns: * char * to string number */ DAT_RETURN dapli_ns_create_gid_map(void) { FILE *f; ib_gid_t gid; char hostname[128]; int rc; struct addrinfo *addr; struct sockaddr_in *si; DAPL_GID_MAP gmt; f = fopen(MAP_FILE, "r"); if (f == NULL) { dapl_dbg_log(DAPL_DBG_TYPE_ERR, "ERROR: Must have file <%s> " "for IP/GID mappings\n", MAP_FILE); return (DAT_ERROR(DAT_INTERNAL_ERROR, 0)); } rc = fscanf(f, "%s " F64x " " F64x, hostname, &gid.gid_prefix, &gid.gid_guid); while (rc != EOF) { rc = dapls_osd_getaddrinfo(hostname, &addr); if (rc != 0) { /* * hostname not registered in DNS, * provide a dummy value */ dapl_dbg_log(DAPL_DBG_TYPE_ERR, "WARNING: <%s> not registered in " "DNS, using dummy IP value\n", hostname); gmt.ip_address = 0x01020304; } else { /* * Load into the ip/gid mapping table */ si = (struct sockaddr_in *)addr->ai_addr; if (AF_INET == addr->ai_addr->sa_family) { gmt.ip_address = si->sin_addr.s_addr; } else { dapl_dbg_log(DAPL_DBG_TYPE_ERR, "WARNING: <%s> Address family " "not supported, using dummy " "IP value\n", hostname); gmt.ip_address = 0x01020304; } dapls_osd_freeaddrinfo(addr); } gmt.gid.gid_prefix = gid.gid_prefix; gmt.gid.gid_guid = gid.gid_guid; dapli_ns_add_address(&gmt); rc = fscanf(f, "%s " F64x " " F64x, hostname, &gid.gid_prefix, &gid.gid_guid); } (void) fclose(f); return (DAT_SUCCESS); }
/* * dapli_assign_hca_ip_address * * Obtain the IP address of the passed in name, which represents a * port on the hca. There are three methods here to obtain the * appropriate IP address, each with their own shortcoming: * 1) IPOIB_NAMING. Requires the implementation of the IPoIB * interface defined in include/dapl/ipoib_names.h. This is * not the recommended interface as IPoIB is limited at * the point we need to obtain an IP address on the * passive side of a connection. The code supporting this * implementation has been removed. * * 2) IBHOSTS. An entry exists in DNS and in the /etc/dapl/ibhosts * file. The immediate drawback here is that we must dictate * how to name the interface, which is a stated DAPL non-goal. * In the broader perspective, this method requires us to xmit * the IP address in the private data of a connection, which has * other fun problems. This is the default method and is known to * work, but it has problems. * * 3) Obtain the IP address from the driver, which has registered * the address with the SA for retrieval. * * * Input: * hca_ptr Pointer to HCA structure * device_name Name of device as reported by the provider * * Output: * none * * Returns: * char * to string number */ void dapli_assign_hca_ip_address(DAPL_HCA * hca_ptr, char *device_name) { char *adapter_num; #define NAMELEN 128 struct addrinfo *addr; char hostname[NAMELEN]; char *str; int rc; /* * Obtain the IP address of the adapter. This is a simple * scheme that creates a name that must appear available to * DNS, e.g. it must be in the local site DNS or in the local * /etc/hosts file, etc. * * <hostname>-ib<index> * * This scheme obviously doesn't work with adapters from * multiple vendors, but will suffice in common installations. */ rc = gethostname(hostname, NAMELEN); /* guarantee NUL termination if hostname gets truncated */ hostname[NAMELEN - 1] = '\0'; /* * Strip off domain info if it exists (e.g. mynode.mydomain.com) */ for (str = hostname; *str && *str != '.';) { str++; } if (*str == '.') { *str = '\0'; } strcat(hostname, "-ib"); adapter_num = dapli_get_adapter_num(device_name); strcat(hostname, adapter_num); rc = dapls_osd_getaddrinfo(hostname, &addr); if (rc != 0) { /* Not registered in DNS, provide a dummy value */ dapli_setup_dummy_addr(hca_ptr, hostname); } else { hca_ptr->hca_address = *((DAT_SOCK_ADDR6 *) addr->ai_addr); dapls_osd_freeaddrinfo(addr); } }