From patchwork Thu Nov 9 08:04:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10050393 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 F2B3860381 for ; Thu, 9 Nov 2017 08:04:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E677F2A873 for ; Thu, 9 Nov 2017 08:04:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB3302A878; Thu, 9 Nov 2017 08:04:46 +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.9 required=2.0 tests=BAYES_00, 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 533AB2A877 for ; Thu, 9 Nov 2017 08:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752231AbdKIIEp (ORCPT ); Thu, 9 Nov 2017 03:04:45 -0500 Received: from aserp1040.oracle.com ([141.146.126.69]:36241 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752195AbdKIIEp (ORCPT ); Thu, 9 Nov 2017 03:04:45 -0500 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA984gfT011695 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Nov 2017 08:04:42 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vA984fHD019567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 9 Nov 2017 08:04:42 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vA984foi001892; Thu, 9 Nov 2017 08:04:41 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 09 Nov 2017 00:04:40 -0800 From: Yuval Shaia To: sean.hefty@intel.com, hal@dev.mellanox.co.il, jgg@ziepe.ca, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH rdma-core] librdmacm: Print correct error message from rdma_getaddrinfo Date: Thu, 9 Nov 2017 10:04:24 +0200 Message-Id: <20171109080424.4900-1-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.13.6 X-Source-IP: aserv0021.oracle.com [141.146.126.233] 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 A return value of -1 from rdma_getaddrinfo can indicates either EAI_BADFLAGS returned from getaddrinfo or a generic error returned by rdma_getaddrinfo itself. Fix this conflict by printing errno in case it is set, otherwise gai_strerror. Signed-off-by: Yuval Shaia --- librdmacm/examples/cmatose.c | 6 ++++-- librdmacm/examples/cmtime.c | 6 ++++-- librdmacm/examples/rdma_client.c | 3 ++- librdmacm/examples/rdma_server.c | 3 ++- librdmacm/examples/rdma_xclient.c | 3 ++- librdmacm/examples/riostream.c | 6 ++++-- librdmacm/examples/rstream.c | 9 ++++++--- librdmacm/examples/udaddy.c | 6 ++++-- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/librdmacm/examples/cmatose.c b/librdmacm/examples/cmatose.c index b1c9dd13..6f6a99d8 100644 --- a/librdmacm/examples/cmatose.c +++ b/librdmacm/examples/cmatose.c @@ -507,7 +507,8 @@ static int run_server(void) ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); if (ret) { - printf("cmatose: getrdmaaddr error: %s\n", gai_strerror(ret)); + printf("cmatose: getrdmaaddr error: %s\n", errno ? + strerror(errno) : gai_strerror(ret)); goto out; } @@ -580,7 +581,8 @@ static int run_client(void) ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); if (ret) { - printf("cmatose: getaddrinfo error: %s\n", gai_strerror(ret)); + printf("cmatose: getaddrinfo error: %s\n", errno ? + strerror(errno) : gai_strerror(ret)); return ret; } diff --git a/librdmacm/examples/cmtime.c b/librdmacm/examples/cmtime.c index aa96b901..a7d109dd 100644 --- a/librdmacm/examples/cmtime.c +++ b/librdmacm/examples/cmtime.c @@ -462,7 +462,8 @@ static int run_server(void) ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai); if (ret) { - printf("getrdmaaddr error: %s\n", gai_strerror(ret)); + printf("getrdmaaddr error: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); goto out; } @@ -491,7 +492,8 @@ static int run_client(void) ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &rai); if (ret) { - printf("getaddrinfo error: %s\n", gai_strerror(ret)); + printf("getaddrinfo error: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } diff --git a/librdmacm/examples/rdma_client.c b/librdmacm/examples/rdma_client.c index c27047c5..de43eb0a 100644 --- a/librdmacm/examples/rdma_client.c +++ b/librdmacm/examples/rdma_client.c @@ -56,7 +56,8 @@ static int run(void) hints.ai_port_space = RDMA_PS_TCP; ret = rdma_getaddrinfo(server, port, &hints, &res); if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); + printf("rdma_getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); goto out; } diff --git a/librdmacm/examples/rdma_server.c b/librdmacm/examples/rdma_server.c index bcf649fe..bedd9a73 100644 --- a/librdmacm/examples/rdma_server.c +++ b/librdmacm/examples/rdma_server.c @@ -57,7 +57,8 @@ static int run(void) hints.ai_port_space = RDMA_PS_TCP; ret = rdma_getaddrinfo(NULL, port, &hints, &res); if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); + printf("rdma_getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } diff --git a/librdmacm/examples/rdma_xclient.c b/librdmacm/examples/rdma_xclient.c index 63dfb6df..687e1deb 100644 --- a/librdmacm/examples/rdma_xclient.c +++ b/librdmacm/examples/rdma_xclient.c @@ -82,7 +82,8 @@ static int test(void) ret = rdma_getaddrinfo(server, port, &hints, &res); if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); + printf("rdma_getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } diff --git a/librdmacm/examples/riostream.c b/librdmacm/examples/riostream.c index bdf4fd34..883f8a82 100644 --- a/librdmacm/examples/riostream.c +++ b/librdmacm/examples/riostream.c @@ -363,7 +363,8 @@ static int server_listen(void) ret = getaddrinfo(src_addr, port, &ai_hints, &ai); } if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); + printf("getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } @@ -444,7 +445,8 @@ static int client_connect(void) ret = use_rgai ? rdma_getaddrinfo(dst_addr, port, &rai_hints, &rai) : getaddrinfo(dst_addr, port, &ai_hints, &ai); if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); + printf("getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } diff --git a/librdmacm/examples/rstream.c b/librdmacm/examples/rstream.c index 7523269c..11fe6f25 100644 --- a/librdmacm/examples/rstream.c +++ b/librdmacm/examples/rstream.c @@ -327,7 +327,8 @@ static int server_listen(void) ret = getaddrinfo(src_addr, port, &ai_hints, &ai); } if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); + printf("getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } @@ -412,7 +413,8 @@ static int client_connect(void) getaddrinfo(dst_addr, port, &ai_hints, &ai); if (ret) { - printf("getaddrinfo: %s\n", gai_strerror(ret)); + printf("getaddrinfo: %s\n", errno ? strerror(errno) : + gai_strerror(ret)); return ret; } @@ -425,7 +427,8 @@ static int client_connect(void) ret = getaddrinfo(src_addr, port, &ai_hints, &ai_src); } if (ret) { - printf("getaddrinfo src_addr: %s\n", gai_strerror(ret)); + printf("getaddrinfo src_addr: %s\n", errno ? + strerror(errno) : gai_strerror(ret)); return ret; } } diff --git a/librdmacm/examples/udaddy.c b/librdmacm/examples/udaddy.c index b1ac90c3..914be0a2 100644 --- a/librdmacm/examples/udaddy.c +++ b/librdmacm/examples/udaddy.c @@ -514,7 +514,8 @@ static int run_server(void) ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); if (ret) { - printf("udaddy: getrdmaaddr error: %s\n", gai_strerror(ret)); + printf("udaddy: getrdmaaddr error: %s\n", errno ? + strerror(errno) : gai_strerror(ret)); goto out; } @@ -563,7 +564,8 @@ static int run_client(void) ret = get_rdma_addr(src_addr, dst_addr, port, &hints, &test.rai); if (ret) { - printf("udaddy: getaddrinfo error: %s\n", gai_strerror(ret)); + printf("udaddy: getaddrinfo error: %s\n", errno ? + strerror(errno) : gai_strerror(ret)); return ret; }