This can occur when IPv6 is disabled. Signed-off-by: Hal Rosenstock <hal@xxxxxxxxxxxx> --- ibacm/src/acm_util.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ibacm/src/acm_util.c b/ibacm/src/acm_util.c index b50fd74..5b84be8 100644 --- a/ibacm/src/acm_util.c +++ b/ibacm/src/acm_util.c @@ -127,7 +127,8 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) struct ifconf *ifc; struct ifreq *ifr; char ip_str[INET6_ADDRSTRLEN]; - int s, ret, i, len; + int family = AF_INET6; + int s, ret, i, len, intfs = 0; uint16_t pkey; union ibv_gid sgid; uint8_t addr_type; @@ -135,9 +136,12 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) size_t addr_len; char *alias_sep; - s = socket(AF_INET6, SOCK_DGRAM, 0); - if (!s) - return -1; +next_family: + s = socket(family, SOCK_DGRAM, 0); + if (!s) { + ret = -1; + goto out; + } len = sizeof(*ifc) + sizeof(*ifr) * 64; ifc = malloc(len); @@ -152,7 +156,8 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) ret = ioctl(s, SIOCGIFCONF, ifc); if (ret < 0) { - acm_log(0, "ioctl ifconf error: %s\n", strerror(errno)); + acm_log(0, "ioctl IPv%s ifconf error: %s\n", + (family == AF_INET6) ? "6" : "4", strerror(errno)); goto out2; } @@ -199,6 +204,7 @@ int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) continue; cb(ifr[i].ifr_name, &sgid, pkey, addr_type, addr, addr_len, ip_str, ctx); + intfs++; } ret = 0; @@ -206,6 +212,10 @@ out2: free(ifc); out1: close(s); +out: + if (family == AF_INET6 && intfs == 0) { + family = AF_INET; + goto next_family; + } return ret; - } -- 2.8.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html