From patchwork Tue Nov 7 09:50:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10046121 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 50E116031B for ; Tue, 7 Nov 2017 09:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2BB7B28F2A for ; Tue, 7 Nov 2017 09:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2067829B23; Tue, 7 Nov 2017 09:51: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=-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 DE9B929B1F for ; Tue, 7 Nov 2017 09:51:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933755AbdKGJvU (ORCPT ); Tue, 7 Nov 2017 04:51:20 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:37615 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933753AbdKGJuw (ORCPT ); Tue, 7 Nov 2017 04:50:52 -0500 Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id vA79onl3009763 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Nov 2017 09:50:50 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vA79onk0002174 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Nov 2017 09:50:49 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 vA79onYS001423; Tue, 7 Nov 2017 09:50:49 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 07 Nov 2017 01:50:48 -0800 From: Yuval Shaia To: sean.hefty@intel.com, hal@dev.mellanox.co.il, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH rdma-core] librdmacm: Store error code from getaddrinfo in errno Date: Tue, 7 Nov 2017 11:50:38 +0200 Message-Id: <20171107095038.7348-1-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.13.6 X-Source-IP: aserv0022.oracle.com [141.146.126.234] 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 sticking to the existing convention where -1 indicates an error while the actual underling error code is stored in errno. Signed-off-by: Yuval Shaia --- librdmacm/addrinfo.c | 2 +- librdmacm/examples/cmatose.c | 4 ++-- librdmacm/examples/cmtime.c | 4 ++-- librdmacm/examples/rdma_client.c | 2 +- librdmacm/examples/rdma_server.c | 2 +- librdmacm/examples/rdma_xclient.c | 2 +- librdmacm/examples/rdma_xserver.c | 2 +- librdmacm/examples/riostream.c | 5 ++++- librdmacm/examples/rstream.c | 9 ++++++--- librdmacm/examples/udaddy.c | 4 ++-- 10 files changed, 21 insertions(+), 15 deletions(-) diff --git a/librdmacm/addrinfo.c b/librdmacm/addrinfo.c index 7e660659..b5f45f69 100644 --- a/librdmacm/addrinfo.c +++ b/librdmacm/addrinfo.c @@ -227,7 +227,7 @@ static int ucma_getaddrinfo(const char *node, const char *service, ret = getaddrinfo(node, service, NULL, &ai); } if (ret) - return ret; + return ERR(ret); ret = ucma_convert_to_rai(rai, hints, ai); freeaddrinfo(ai); diff --git a/librdmacm/examples/cmatose.c b/librdmacm/examples/cmatose.c index b1c9dd13..625849ce 100644 --- a/librdmacm/examples/cmatose.c +++ b/librdmacm/examples/cmatose.c @@ -507,7 +507,7 @@ 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", gai_strerror(errno)); goto out; } @@ -580,7 +580,7 @@ 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", gai_strerror(errno)); return ret; } diff --git a/librdmacm/examples/cmtime.c b/librdmacm/examples/cmtime.c index aa96b901..dc881701 100644 --- a/librdmacm/examples/cmtime.c +++ b/librdmacm/examples/cmtime.c @@ -462,7 +462,7 @@ 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", gai_strerror(errno)); goto out; } @@ -491,7 +491,7 @@ 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", gai_strerror(errno)); return ret; } diff --git a/librdmacm/examples/rdma_client.c b/librdmacm/examples/rdma_client.c index c27047c5..0bfd9323 100644 --- a/librdmacm/examples/rdma_client.c +++ b/librdmacm/examples/rdma_client.c @@ -56,7 +56,7 @@ 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", gai_strerror(errno)); goto out; } diff --git a/librdmacm/examples/rdma_server.c b/librdmacm/examples/rdma_server.c index bcf649fe..89feaa64 100644 --- a/librdmacm/examples/rdma_server.c +++ b/librdmacm/examples/rdma_server.c @@ -57,7 +57,7 @@ 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", gai_strerror(errno)); return ret; } diff --git a/librdmacm/examples/rdma_xclient.c b/librdmacm/examples/rdma_xclient.c index 63dfb6df..0466c1a6 100644 --- a/librdmacm/examples/rdma_xclient.c +++ b/librdmacm/examples/rdma_xclient.c @@ -82,7 +82,7 @@ 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", gai_strerror(errno)); return ret; } diff --git a/librdmacm/examples/rdma_xserver.c b/librdmacm/examples/rdma_xserver.c index 8d8ac314..6cc00927 100644 --- a/librdmacm/examples/rdma_xserver.c +++ b/librdmacm/examples/rdma_xserver.c @@ -79,7 +79,7 @@ static int test(void) ret = rdma_getaddrinfo(NULL, port, &hints, &res); if (ret) { - printf("rdma_getaddrinfo: %s\n", gai_strerror(ret)); + printf("rdma_getaddrinfo: %s\n", gai_strerror(errno)); return ret; } diff --git a/librdmacm/examples/riostream.c b/librdmacm/examples/riostream.c index bdf4fd34..872cfcdc 100644 --- a/librdmacm/examples/riostream.c +++ b/librdmacm/examples/riostream.c @@ -358,6 +358,8 @@ static int server_listen(void) if (use_rgai) { rai_hints.ai_flags |= RAI_PASSIVE; ret = rdma_getaddrinfo(src_addr, port, &rai_hints, &rai); + if (ret == -1) + ret = errno; } else { ai_hints.ai_flags |= AI_PASSIVE; ret = getaddrinfo(src_addr, port, &ai_hints, &ai); @@ -444,7 +446,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", gai_strerror(use_rgai ? errno : + ret)); return ret; } diff --git a/librdmacm/examples/rstream.c b/librdmacm/examples/rstream.c index 7523269c..c1d7bb49 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", gai_strerror(use_rgai ? errno : + 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", gai_strerror(use_rgai ? errno : + 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", + gai_strerror(use_rgai ? errno : ret)); return ret; } } diff --git a/librdmacm/examples/udaddy.c b/librdmacm/examples/udaddy.c index b1ac90c3..fae3d09c 100644 --- a/librdmacm/examples/udaddy.c +++ b/librdmacm/examples/udaddy.c @@ -514,7 +514,7 @@ 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", gai_strerror(errno)); goto out; } @@ -563,7 +563,7 @@ 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", gai_strerror(errno)); return ret; }