From patchwork Fri Feb 1 16:45:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haakon Bugge X-Patchwork-Id: 10793273 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46D2A13B5 for ; Fri, 1 Feb 2019 16:46:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 360743237F for ; Fri, 1 Feb 2019 16:46:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A42B324D3; Fri, 1 Feb 2019 16:46:25 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 2358A3237F for ; Fri, 1 Feb 2019 16:46:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729050AbfBAQqY (ORCPT ); Fri, 1 Feb 2019 11:46:24 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:58296 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726486AbfBAQqX (ORCPT ); Fri, 1 Feb 2019 11:46:23 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x11GXttm071716; Fri, 1 Feb 2019 16:46:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=Xew49SMkxyOXlaMufoxg55A98+3QDeaE1ncM5Hi1OXo=; b=Lfq6Dz1cpR9dlDv+aGKf3RljCnAUu5wxuXRHAT3A6qZM7ZAONL1NSuiLqNNm5ZVJkzbd m9cRsHPKdf1tz0QLYriZ7gja0aeQLm20b9O1jxNiKducZdsjPHnm348Dv0WGX52htclB GmnZBSH/9262lkjEDJaqovXWZUtldBA5DP6p0zWalnxXk9B5XPtS4oiwYWRblRN8pq2Y BmzzthifIyL7nX7JS/l4CMEoaRGVVGLTHczxeU9juBNniSnRKoKgWe37OtlWpQ0+80O3 wCfgvrRcdqX4Nj232y+bFeLwh9C+OzyyK9mC3PRLkIrq2bAqa0mh9yOu5/epPYl1MekM ig== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2q8g6rqmxd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 16:46:14 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkCwD027081 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 16:46:13 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkB3D022061; Fri, 1 Feb 2019 16:46:12 GMT Received: from lab02.no.oracle.com (/10.172.144.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 08:46:11 -0800 From: =?utf-8?q?H=C3=A5kon_Bugge?= To: jgg@mellanox.com Cc: dledford@redhat.com, hal@dev.mellanox.co.il, sean.hefty@intel.com, leon@kernel.org, linux-rdma@vger.kernel.org, ira.weiny@intel.com, aron.silverton@oracle.com, mark.haywood@oracle.com Subject: [PATCH v3 1/4] ibacm: Replace ioctl with netlink Date: Fri, 1 Feb 2019 17:45:54 +0100 Message-Id: <20190201164557.234039-2-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201164557.234039-1-haakon.bugge@oracle.com> References: <20190201164557.234039-1-haakon.bugge@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9154 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010122 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 ibacm uses ioctl with SIOCGIFCONF to enumerate the interfaces. This particular ioctl will only return interfaces that are "running". This is a problem if, for example, ibacm is started before the interfaces get plumbed, or when an interface gets resurrected. By using netlink (nl), we avoid using the sysfs interface to read the gid, as it is supplied directly by nl. This commit does not change the existing functionality, but is made to prepare for a fix where ibacm is unable to resurrect an interface. Detailed logging added: acm_if_iter: name: stib0 label: stib0 index: 9 flags: broadcast,multicast,up,running,lowerup addr: 192.168.200.200/24 pkey: 0x88b4 guid: 0x21280001a17c97 Signed-off-by: Håkon Bugge Reviewed-by: Ira Weiny --- v1 -> v2: * Use static for CB function (Jason, Ira) * Use original order of includes (Ira) * Use ib_gid's global.interface_id instead of casting (Ira) * Require Netlink in CMakeLists.txt (Jason) * Removed ioctl.h include (Håkon) * Removed Gerrit's Change-Id tag (Håkon) --- ibacm/CMakeLists.txt | 4 + ibacm/src/acm.c | 7 ++ ibacm/src/acm_util.c | 251 ++++++++++++++++++++++++------------------- ibacm/src/acm_util.h | 5 +- 4 files changed, 155 insertions(+), 112 deletions(-) diff --git a/ibacm/CMakeLists.txt b/ibacm/CMakeLists.txt index 3a4e2632..7020def6 100644 --- a/ibacm/CMakeLists.txt +++ b/ibacm/CMakeLists.txt @@ -1,3 +1,5 @@ +pkg_check_modules(NL libnl-3.0 libnl-route-3.0 REQUIRED) + publish_headers(infiniband include/infiniband/acm.h include/infiniband/acm_prov.h @@ -7,6 +9,7 @@ publish_headers(infiniband include_directories("include") include_directories("src") include_directories("linux") +include_directories(${NL_INCLUDE_DIRS}) # NOTE: ibacm exports symbols from its own binary for use by ibacm rdma_sbin_executable(ibacm @@ -16,6 +19,7 @@ rdma_sbin_executable(ibacm target_link_libraries(ibacm LINK_PRIVATE ibverbs ibumad + ${NL_LIBRARIES} ${SYSTEMD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS} diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index 6453c5f0..e8d50a4a 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -3250,6 +3250,12 @@ int main(int argc, char **argv) acm_log(0, "Error: failed to create sa resp rcving thread"); return -1; } + + if (acm_init_if_iter_sys()) { + acm_log(0, "Error: unable to initialize acm_if_iter_sys"); + return -1; + } + acm_activate_devices(); acm_log(1, "starting server\n"); acm_server(systemd); @@ -3260,6 +3266,7 @@ int main(int argc, char **argv) acm_close_providers(); acm_stop_sa_handler(); umad_done(); + acm_fini_if_iter_sys(); fclose(flog); return 0; } diff --git a/ibacm/src/acm_util.c b/ibacm/src/acm_util.c index f4654f12..fecb6c89 100644 --- a/ibacm/src/acm_util.c +++ b/ibacm/src/acm_util.c @@ -33,42 +33,18 @@ #include #include #include -#include #include #include #include #include +#include +#include +#include #include #include "acm_mad.h" #include "acm_util.h" -int acm_if_is_ib(char *ifname) -{ - unsigned type; - char buf[128]; - FILE *f; - int ret; - - snprintf(buf, sizeof buf, "//sys//class//net//%s//type", ifname); - f = fopen(buf, "r"); - if (!f) { - acm_log(0, "failed to open %s\n", buf); - return 0; - } - - if (fgets(buf, sizeof buf, f)) { - type = strtol(buf, NULL, 0); - ret = (type == ARPHRD_INFINIBAND); - } else { - acm_log(0, "failed to read interface type\n"); - ret = 0; - } - - fclose(f); - return ret; -} - int acm_if_get_pkey(char *ifname, uint16_t *pkey) { char buf[128], *end; @@ -122,103 +98,156 @@ int acm_if_get_sgid(char *ifname, union ibv_gid *sgid) return ret; } -int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) +static struct nl_sock *sk = NULL; +static struct nl_cache *link_cache; +static struct nl_cache *addr_cache; + +int acm_init_if_iter_sys(void) { - struct ifconf *ifc; - struct ifreq *ifr; - char ip_str[INET6_ADDRSTRLEN]; - int family = AF_INET6; - int s, ret, i, len; - uint16_t pkey; - union ibv_gid sgid; - uint8_t addr_type; - uint8_t addr[ACM_MAX_ADDRESS]; - char *alias_sep; - - s = socket(family, SOCK_DGRAM, 0); - if (!s) { - family = AF_INET; - s = socket(family, SOCK_DGRAM, 0); - if (!s) - return -1; + int sts; + + sk = nl_socket_alloc(); + if (!sk) { + acm_log(0, "nl_socket_alloc"); + return -1; } - len = sizeof(*ifc) + sizeof(*ifr) * 64; - ifc = malloc(len); - if (!ifc) { - ret = -1; - goto out1; + sts = nl_connect(sk, NETLINK_ROUTE); + if (sts) { + acm_log(0, "nl_connect failed"); + goto out_connect; } - memset(ifc, 0, len); - ifc->ifc_len = len - sizeof(*ifc); - ifc->ifc_req = (struct ifreq *) (ifc + 1); - -retry_ioctl: - ret = ioctl(s, SIOCGIFCONF, ifc); - if (ret < 0) { - acm_log(0, "ioctl IPv%s ifconf error: %s\n", - (family == AF_INET6) ? "6" : "4", strerror(errno)); - if (family == AF_INET6) { - close(s); - family = AF_INET; - s = socket(family, SOCK_DGRAM, 0); - if (!s) { - free(ifc); - return ret; - } - goto retry_ioctl; - } - goto out2; + sts = rtnl_link_alloc_cache(sk, AF_UNSPEC, &link_cache); + if (sts) { + acm_log(0, "rtnl_link_alloc_cache failed"); + goto out_connect; } - ifr = ifc->ifc_req; - for (i = 0; i < ifc->ifc_len / sizeof(struct ifreq); i++) { - switch (ifr[i].ifr_addr.sa_family) { - case AF_INET: - addr_type = ACM_ADDRESS_IP; - memcpy(&addr, &((struct sockaddr_in *) &ifr[i].ifr_addr)->sin_addr, - sizeof addr); - inet_ntop(ifr[i].ifr_addr.sa_family, - &((struct sockaddr_in *) &ifr[i].ifr_addr)->sin_addr, - ip_str, sizeof ip_str); - break; - case AF_INET6: - addr_type = ACM_ADDRESS_IP6; - memcpy(&addr, &((struct sockaddr_in6 *) &ifr[i].ifr_addr)->sin6_addr, - sizeof addr); - inet_ntop(ifr[i].ifr_addr.sa_family, - &((struct sockaddr_in6 *) &ifr[i].ifr_addr)->sin6_addr, - ip_str, sizeof ip_str); - break; - default: - continue; - } + sts = rtnl_addr_alloc_cache(sk, &addr_cache); + if (sts) { + acm_log(0, "rtnl_addr_alloc_cache"); + goto out_addr; + } - acm_log(2, "%s\n", ifr[i].ifr_name); + return 0; - alias_sep = strchr(ifr[i].ifr_name, ':'); - if (alias_sep) - *alias_sep = '\0'; +out_addr: + nl_cache_free(link_cache); - if (!acm_if_is_ib(ifr[i].ifr_name)) - continue; +out_connect: + nl_close(sk); + return sts; +} - ret = acm_if_get_sgid(ifr[i].ifr_name, &sgid); - if (ret) - continue; +void acm_fini_if_iter_sys(void) +{ + nl_cache_free(link_cache); + nl_cache_free(addr_cache); + nl_close(sk); +} - ret = acm_if_get_pkey(ifr[i].ifr_name, &pkey); - if (ret) - continue; +static inline int af2acm_addr_type(int af) +{ + switch (af) { + case AF_INET: + return ACM_ADDRESS_IP; - cb(ifr[i].ifr_name, &sgid, pkey, addr_type, addr, ip_str, ctx); + case AF_INET6: + return ACM_ADDRESS_IP6; } - ret = 0; -out2: - free(ifc); -out1: - close(s); - return ret; + acm_log(0, "Unnkown address family\n"); + return ACM_ADDRESS_INVALID; +} + +struct ctx_and_cb { + void *ctx; + acm_if_iter_cb cb; +}; + +static void acm_if_iter(struct nl_object *obj, void *_ctx_and_cb) +{ + struct ctx_and_cb *ctx_cb = (struct ctx_and_cb *)_ctx_and_cb; + struct rtnl_addr *addr = (struct rtnl_addr *)obj; + uint8_t bin_addr[ACM_MAX_ADDRESS] = {}; + char ip_str[INET6_ADDRSTRLEN]; + struct nl_addr *link_addr; + struct rtnl_link *link; + char flags_str[128]; + union ibv_gid sgid; + struct nl_addr *a; + uint16_t pkey; + int addr_len; + char *label; + int flags; + int ret; + int af; + + link = rtnl_link_get(link_cache, rtnl_addr_get_ifindex(addr)); + flags = rtnl_link_get_flags(link); + + if (rtnl_link_get_arptype(link) != ARPHRD_INFINIBAND) + return; + + if (!(flags & IFF_RUNNING)) + return; + + if (!(a = rtnl_addr_get_local(addr))) + return; + + if ((addr_len = nl_addr_get_len(a)) > ACM_MAX_ADDRESS) { + acm_log(0, "address too long (%d)\n", addr_len); + return; + } + + af = nl_addr_get_family(a); + if (af != AF_INET && af != AF_INET6) + return; + + label = rtnl_addr_get_label(addr); + if (!label) + return; + + link_addr = rtnl_link_get_addr(link); + memcpy(sgid.raw, nl_addr_get_binary_addr(link_addr) + 4, sizeof(sgid)); + + ret = acm_if_get_pkey(rtnl_link_get_name(link), &pkey); + if (ret) + return; + + acm_log(2, "name: %5s label: %9s index: %2d flags: %s addr: %s pkey: 0x%04x guid: 0x%lx\n", + rtnl_link_get_name(link), label, + rtnl_addr_get_ifindex(addr), + rtnl_link_flags2str(flags, flags_str, sizeof(flags_str)), + nl_addr2str(a, ip_str, sizeof(ip_str)), pkey, + be64toh(sgid.global.interface_id)); + + memcpy(&bin_addr, nl_addr_get_binary_addr(a), addr_len); + ctx_cb->cb(rtnl_link_get_name(link), &sgid, pkey, af2acm_addr_type(af), bin_addr, ip_str, ctx_cb->ctx); +} + + +int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx) +{ + struct ctx_and_cb ctx_cb; + int sts; + + sts = nl_cache_refill(sk, link_cache); + if (sts) { + acm_log(0, "nl_cache_refill link_cache"); + return sts; + } + + sts = nl_cache_refill(sk, addr_cache); + if (sts) { + acm_log(0, "nl_cache_refill addr_cache"); + return sts; + } + + ctx_cb.ctx = ctx; + ctx_cb.cb = cb; + nl_cache_foreach(addr_cache, acm_if_iter, (void *)&ctx_cb); + + return 0; } diff --git a/ibacm/src/acm_util.h b/ibacm/src/acm_util.h index cfa6f1a2..83b49edd 100644 --- a/ibacm/src/acm_util.h +++ b/ibacm/src/acm_util.h @@ -33,6 +33,7 @@ #include #include + #ifdef ACME_PRINTS #undef acm_log @@ -47,12 +48,14 @@ int acm_if_is_ib(char *ifname); int acm_if_get_pkey(char *ifname, uint16_t *pkey); int acm_if_get_sgid(char *ifname, union ibv_gid *sgid); - +int acm_init_if_iter_sys(void); +void acm_fini_if_iter_sys(void); typedef void (*acm_if_iter_cb)(char *ifname, union ibv_gid *gid, uint16_t pkey, uint8_t addr_type, uint8_t *addr, char *ip_str, void *ctx); int acm_if_iter_sys(acm_if_iter_cb cb, void *ctx); + char **parse(const char *args, int *count); #endif /* ACM_IF_H */ From patchwork Fri Feb 1 16:45:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haakon Bugge X-Patchwork-Id: 10793279 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6AD86C2 for ; Fri, 1 Feb 2019 16:46:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7BA53237F for ; Fri, 1 Feb 2019 16:46:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B983324D3; Fri, 1 Feb 2019 16:46:28 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 45A983237F for ; Fri, 1 Feb 2019 16:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729626AbfBAQq2 (ORCPT ); Fri, 1 Feb 2019 11:46:28 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:51140 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbfBAQq1 (ORCPT ); Fri, 1 Feb 2019 11:46:27 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x11GXvB4052089; Fri, 1 Feb 2019 16:46:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=5XNIkY6sCC9Tp+l3Jwjo1LxJMG8N27FL15IFBIN7zJo=; b=49FNuQ6EMsyAurdq1J7j48aTg9Vi7dGnj8HiuDpJJstOQyquCVRlyEC8mvulDtzPplD2 pp8mUBByeVMz5iwFkU1VmISZSqJDXufuddJmDnq0bdY4SH5aUBObW+s6zHHa9OacBgU1 5qbLfJc3ym8juHNryUb437Hch5ouy2jP3zN5/rmq/o+GzG+us9KlrT82DKZIEmgFbSSo 17XgyEZNiz5f32/zd1aXP2TwfoFHDqEfK87DA7h900n0s781R4c4MsdUxe0bVAvvDFjo 0cOla8wvEowlq4KyVlBkrXzSVN81O/E8iIX/82x6hvt/cFmV+b/Sp1Jd5lf8YiOlGob0 Ug== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2130.oracle.com with ESMTP id 2q8d2eqwem-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 16:46:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkEPb000784 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 16:46:14 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkDwC007957; Fri, 1 Feb 2019 16:46:13 GMT Received: from lab02.no.oracle.com (/10.172.144.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 08:46:13 -0800 From: =?utf-8?q?H=C3=A5kon_Bugge?= To: jgg@mellanox.com Cc: dledford@redhat.com, hal@dev.mellanox.co.il, sean.hefty@intel.com, leon@kernel.org, linux-rdma@vger.kernel.org, ira.weiny@intel.com, aron.silverton@oracle.com, mark.haywood@oracle.com Subject: [PATCH v3 2/4] ibacm: Print correct pkey Date: Fri, 1 Feb 2019 17:45:55 +0100 Message-Id: <20190201164557.234039-3-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201164557.234039-1-haakon.bugge@oracle.com> References: <20190201164557.234039-1-haakon.bugge@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9154 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010122 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 In commit 0161b49e3e1e ("ibacm: Unable to assign EP name for limited pkey"), a fix was introduced enabling an ipoib interface to be associated with its corresponding IB port, when a limited pkey was used. Said commit missed to change the debug print, such that the real pkey was printed. Fixes: 0161b49e3e1e ("ibacm: Unable to assign EP name for limited pkey") Signed-off-by: Håkon Bugge Reviewed-by: Ira Weiny --- v1 -> v2: * Added Ira's r-b * Removed Gerrit's Change-Id tag (Håkon) --- ibacm/src/acm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ibacm/src/acm.c b/ibacm/src/acm.c index e8d50a4a..a05a3cc0 100644 --- a/ibacm/src/acm.c +++ b/ibacm/src/acm.c @@ -2090,7 +2090,7 @@ static void acm_ep_ip_iter_cb(char *ifname, union ibv_gid *gid, uint16_t pkey, (ep->endpoint.pkey | IB_PKEY_FULL_MEMBER) == pkey) { if (!acm_ep_insert_addr(ep, ip_str, addr, addr_type)) { acm_log(0, "Added %s %s %d 0x%x from %s\n", ip_str, - dev->device.verbs->device->name, port_num, pkey, + dev->device.verbs->device->name, port_num, ep->endpoint.pkey, ifname); } } From patchwork Fri Feb 1 16:45:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haakon Bugge X-Patchwork-Id: 10793277 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BC826C2 for ; Fri, 1 Feb 2019 16:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38FC23237F for ; Fri, 1 Feb 2019 16:46:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CBB4324D3; Fri, 1 Feb 2019 16:46:27 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 AEDC53237F for ; Fri, 1 Feb 2019 16:46:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729208AbfBAQq0 (ORCPT ); Fri, 1 Feb 2019 11:46:26 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:58356 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729129AbfBAQq0 (ORCPT ); Fri, 1 Feb 2019 11:46:26 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x11GXtIS071713; Fri, 1 Feb 2019 16:46:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=itmQR2vfK2LjAoFXRd2prm4AnmmAjlkYCXmZ+qSrXpI=; b=LyWYytOcTo87nerf4XhLlmBiYWVqgvsxNJpbvWhaNSviy/eKmN8fFWRWXOB1MPt002ej U9Z5rQcdGce0idmkYFm8LarGv/w+5T3O6Pt99yIXEuBsxrgLdSJXSQtPPCwZytDgbCMI 0AB5e2dGwSqMfA/66Jiqs5Pp8tsnPfWLuB14NNTIKVe8ElWIap5+u+2C/fnbtg2NuQ7G WA5ULQDec3oKmPlLmkfFwhABldPIO5jQmmFOntJue7lK0nUosztrIqKrKUDa4vFpkWeu 7cn9v4JTdGbZM8b/N2aI/nmzQkFoc7l6H1bzPKJICxKFIKr3/xigUdml6K17HWHvES8r /Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2q8g6rqmxn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 16:46:17 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkGsA027270 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 16:46:16 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkFV6022144; Fri, 1 Feb 2019 16:46:16 GMT Received: from lab02.no.oracle.com (/10.172.144.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 08:46:15 -0800 From: =?utf-8?q?H=C3=A5kon_Bugge?= To: jgg@mellanox.com Cc: dledford@redhat.com, hal@dev.mellanox.co.il, sean.hefty@intel.com, leon@kernel.org, linux-rdma@vger.kernel.org, ira.weiny@intel.com, aron.silverton@oracle.com, mark.haywood@oracle.com Subject: [PATCH v3 3/4] ibacm: Unable to resurrect an interface Date: Fri, 1 Feb 2019 17:45:56 +0100 Message-Id: <20190201164557.234039-4-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201164557.234039-1-haakon.bugge@oracle.com> References: <20190201164557.234039-1-haakon.bugge@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9154 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010122 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 When an IB port has been brought back to Active state, after being down, ibacm gets an event about it. It will then (re) enumerate the devices, and does so by executing an ioctl with SIOCGIFCONF. This particular ioctl will only return interfaces that are "running". There may be a delay after the IB port becomes Active until its address has been provisioned, and becomes "running". If ibacm attempts to associate IPoIB interfaces to the port during this interval, it will not see the interface because it is not "running". Later, when ibacm is asked for a Path Record (PR) using the IP address of the resurrected IPoIB interface, it will not be able to find the associated end-point (EP), and the following is printed in the log: acm_svr_resolve_path: notice - unknown local end point address The bug can be provoked by the following script. We have a single HCA with two ports, the IPoIB interfaces are named stib{0,1}, the IP address of the first interface is 192.168.200.200, and the remote IP address is 192.168.200.202. The LID of the IB switch is 1 and the switch port number connected to port 1 of the HCA is 22. This fix depends on the commit that re-factors the use of ioctl in acm_if_iter(), and instead uses netlink. Now, by reducing the requirements of the state of the interface, the EP is added, and afterwards, when an address is assigned, it is associated with the EP. This commit is a new implementation of https://patchwork.kernel.org/patch/10748357, which was NAKed. Signed-off-by: Håkon Bugge Reviewed-by: Ira Weiny v1 -> v2: * Removed Gerrit's Change-Id tag (Håkon) --- ibacm/src/acm_util.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/ibacm/src/acm_util.c b/ibacm/src/acm_util.c index fecb6c89..8807579d 100644 --- a/ibacm/src/acm_util.c +++ b/ibacm/src/acm_util.c @@ -180,19 +180,13 @@ static void acm_if_iter(struct nl_object *obj, void *_ctx_and_cb) uint16_t pkey; int addr_len; char *label; - int flags; - int ret; int af; link = rtnl_link_get(link_cache, rtnl_addr_get_ifindex(addr)); - flags = rtnl_link_get_flags(link); if (rtnl_link_get_arptype(link) != ARPHRD_INFINIBAND) return; - if (!(flags & IFF_RUNNING)) - return; - if (!(a = rtnl_addr_get_local(addr))) return; @@ -206,20 +200,18 @@ static void acm_if_iter(struct nl_object *obj, void *_ctx_and_cb) return; label = rtnl_addr_get_label(addr); - if (!label) - return; link_addr = rtnl_link_get_addr(link); + /* gid has a 4 byte offset into the link address */ memcpy(sgid.raw, nl_addr_get_binary_addr(link_addr) + 4, sizeof(sgid)); - ret = acm_if_get_pkey(rtnl_link_get_name(link), &pkey); - if (ret) + if (acm_if_get_pkey(rtnl_link_get_name(link), &pkey)) return; acm_log(2, "name: %5s label: %9s index: %2d flags: %s addr: %s pkey: 0x%04x guid: 0x%lx\n", rtnl_link_get_name(link), label, rtnl_addr_get_ifindex(addr), - rtnl_link_flags2str(flags, flags_str, sizeof(flags_str)), + rtnl_link_flags2str(rtnl_link_get_flags(link), flags_str, sizeof(flags_str)), nl_addr2str(a, ip_str, sizeof(ip_str)), pkey, be64toh(sgid.global.interface_id)); From patchwork Fri Feb 1 16:45:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Haakon Bugge X-Patchwork-Id: 10793281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 427F217E9 for ; Fri, 1 Feb 2019 16:46:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 321163237F for ; Fri, 1 Feb 2019 16:46:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26235324D3; Fri, 1 Feb 2019 16:46:29 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 C29213237F for ; Fri, 1 Feb 2019 16:46:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729884AbfBAQq2 (ORCPT ); Fri, 1 Feb 2019 11:46:28 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:51144 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729517AbfBAQq2 (ORCPT ); Fri, 1 Feb 2019 11:46:28 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x11GYBfH052208; Fri, 1 Feb 2019 16:46:19 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=G8TuojEkorEyyqaDxsQZCdcPT8RA8xjBFWvC9gt5u00=; b=S3xxwLzhMlCKse4beqnS/DHpBS8321Bf0FSEsu9fq1jh4kLrq8S0vAYPS3cH2McgHfS1 nUDkUI0GEX800RgvDoSz2IsMKiNjbXu37ec16rgcllj08YsU0JC1e9xhKz0eGGyF19p0 wbtJLByNmFbeOE4k7nc1M1AzrG5aQGy9fzgPffktl5zGQRJKYPkC5OVqJuaTR4pbOzaL cx0hQ+nT6/tzkycos9ND5l+huYS9EbjCZQa/dlEtcsPzoVWtIoIYFWUr9orq0z7yyMds TchMH5mrSayzrpya2+P5XtBDtrAozZM7ljGJ3f4xRzLxZugbhyF+4dyZczlJca745hW3 Cg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2130.oracle.com with ESMTP id 2q8d2eqwej-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 01 Feb 2019 16:46:19 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkIRK001613 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 1 Feb 2019 16:46:18 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x11GkHeT007980; Fri, 1 Feb 2019 16:46:17 GMT Received: from lab02.no.oracle.com (/10.172.144.56) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 01 Feb 2019 08:46:17 -0800 From: =?utf-8?q?H=C3=A5kon_Bugge?= To: jgg@mellanox.com Cc: dledford@redhat.com, hal@dev.mellanox.co.il, sean.hefty@intel.com, leon@kernel.org, linux-rdma@vger.kernel.org, ira.weiny@intel.com, aron.silverton@oracle.com, mark.haywood@oracle.com Subject: [PATCH v3 4/4] ibacm: Use alias name when possible Date: Fri, 1 Feb 2019 17:45:57 +0100 Message-Id: <20190201164557.234039-5-haakon.bugge@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201164557.234039-1-haakon.bugge@oracle.com> References: <20190201164557.234039-1-haakon.bugge@oracle.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9154 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902010122 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 When using ipoib child interfaces, the names displayed by the ip utility show: # ip addr show | grep inet' ' | grep ib inet 192.168.200.201/24 scope global stib1 inet 192.168.200.200/24 scope global secondary stib1:P03 However, the logging of ibacm uses the device names (slightly edited for better brevity): # grep acm_ep_ip_iter_cb /usr/local/var/log/ibacm.log Added 192.168.200.201/24 mlx4_0 2 0x84b4 from stib1 Added 192.168.200.200/24 mlx4_0 2 0x84b4 from stib1 This commit changes this by using the alias name when possible, and the above would read: # grep acm_ep_ip_iter_cb /usr/local/var/log/ibacm.log Added 192.168.200.201/24 mlx4_0 2 0x84b4 from stib1 Added 192.168.200.200/24 mlx4_0 2 0x84b4 from stib1:P03 Signed-off-by: Håkon Bugge Reviewed-by: Ira Weiny --- v1 -> v2: * Added Ira's r-b * Removed Gerrit's Change-Id tag (Håkon) --- ibacm/src/acm_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ibacm/src/acm_util.c b/ibacm/src/acm_util.c index 8807579d..828501df 100644 --- a/ibacm/src/acm_util.c +++ b/ibacm/src/acm_util.c @@ -216,7 +216,8 @@ static void acm_if_iter(struct nl_object *obj, void *_ctx_and_cb) be64toh(sgid.global.interface_id)); memcpy(&bin_addr, nl_addr_get_binary_addr(a), addr_len); - ctx_cb->cb(rtnl_link_get_name(link), &sgid, pkey, af2acm_addr_type(af), bin_addr, ip_str, ctx_cb->ctx); + ctx_cb->cb(label ? label : rtnl_link_get_name(link), + &sgid, pkey, af2acm_addr_type(af), bin_addr, ip_str, ctx_cb->ctx); }