From patchwork Wed Oct 25 13:42:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hal Rosenstock X-Patchwork-Id: 10026745 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C258E601E8 for ; Wed, 25 Oct 2017 13:42:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B306927B2F for ; Wed, 25 Oct 2017 13:42:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7DA1289A2; Wed, 25 Oct 2017 13:42:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3279B27B2F for ; Wed, 25 Oct 2017 13:42:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932194AbdJYNmw (ORCPT ); Wed, 25 Oct 2017 09:42:52 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:50434 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932177AbdJYNmv (ORCPT ); Wed, 25 Oct 2017 09:42:51 -0400 Received: by mail-qk0-f193.google.com with SMTP id o187so25534qke.7 for ; Wed, 25 Oct 2017 06:42:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dev-mellanox-co-il.20150623.gappssmtp.com; s=20150623; h=to:cc:from:subject:message-id:date:user-agent:mime-version :content-language:content-transfer-encoding; bh=tDEbkVeR11XxM8u/Ya5y6RgzUHi/KRo7Mp2fq8Ej8bs=; b=sS0tjYC46yPHU4vr7iTe6FfwGJZZ53rttNfK/zI5jdIJudC8/e8xXR9oV4e3deG7SR 5N+Rk0+AVVPftXGngKUiHY05M9MRpcFE22sm/lTjBbAaz+i0o1HstXU1J6JrHBSne8Hd XPEz6MNWbvcdDv5JGN/4+QA5U85a3MuKDfWa/kXV7fIk4TceYopAHYKjv65hIVnD5IrR ZeWlhjLyAlG3k2FqGDIQMPj2QjVnOzVtt0hV5fNywi/2haG6XaIg7d3Gd5GuznnfQ2SI Ho/jnC69d0DBmdXv6U5h8wcmv8iW2yDr0vXEh4bDyA0/gRYi1h/N0svW6LoHlQdIMEj+ xAig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:cc:from:subject:message-id:date:user-agent :mime-version:content-language:content-transfer-encoding; bh=tDEbkVeR11XxM8u/Ya5y6RgzUHi/KRo7Mp2fq8Ej8bs=; b=KbrOweZWGd1Rk+BtyiSFV0j2NZhhDR2HAzvBzT96OQ7AJBZu8/Xr55Mh4wqoq3YLnc czQ59As+up4oYofJhBuk9BXhPzJJVECQU3bKPK+MEpAbSHU/0VwXvOir+m76mhkIYbht +J5mBYydOmjl65zofVeJ6qf0vLHAgtW8SfeCR3bY0F49PAR6bkVCFbPpow6+94qRpJuG uGxhlqkUdfM2Vz/a0GtKhR374wI+XCS40/Iq4dFE+31ytM1YnjFTsdakXuB8Jpaf0+n5 fq3KVorGUkFl49XrbzndRpJJLwbbFvi9PQxIP65l80Pd0SQiOxqcxo1zWtQc6eYztuL+ XJWg== X-Gm-Message-State: AMCzsaXwYVmMt4ch5GSKZKLSoSg9Sd0hQfkb+7JowAHg20hXAfxhjecR k/+cGMDjWscEir45dd2moLdijUlB X-Google-Smtp-Source: ABhQp+TyoBlIAy7yGrzkH+lOJge7ZyBgkLOzdR/BX7lDGIk3FTWFyZ/vSnMmIhJabw+Z+IJ3yKESEA== X-Received: by 10.55.221.68 with SMTP id n65mr3078756qki.27.1508938970755; Wed, 25 Oct 2017 06:42:50 -0700 (PDT) Received: from [192.168.1.183] (c-73-182-207-166.hsd1.ma.comcast.net. [73.182.207.166]) by smtp.googlemail.com with ESMTPSA id f142sm1902429qka.6.2017.10.25.06.42.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Oct 2017 06:42:50 -0700 (PDT) To: "Hefty, Sean" Cc: "linux-rdma@vger.kernel.org" From: Hal Rosenstock Subject: [PATCH rdma-core 3/3] ibacm: In acm_util.c:acm_if_iter_sys, try IPv4 if IPv6 doesn't find any appropriate interfaces Message-ID: <8d19d9a9-1f97-408e-ca60-d42e67fbf60c@dev.mellanox.co.il> Date: Wed, 25 Oct 2017 09:42:49 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-US Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This can occur when IPv6 is disabled. Signed-off-by: Hal Rosenstock --- 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; - }