From patchwork Wed Jan 16 21:53:03 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 213077 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "userp1040.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id BB1B72C0092 for ; Thu, 17 Jan 2013 08:53:18 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0GLrFmH018847 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Jan 2013 21:53:15 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0GLrE9o008817 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Jan 2013 21:53:14 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tvav4-0006NI-Jo; Wed, 16 Jan 2013 13:53:14 -0800 Received: from acsinet21.oracle.com ([141.146.126.237]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tvauz-0006N4-7P for fedfs-utils-devel@oss.oracle.com; Wed, 16 Jan 2013 13:53:09 -0800 Received: from aserp1020.oracle.com (aserp1020.oracle.com [141.146.126.67]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r0GLr89Q012647 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 16 Jan 2013 21:53:09 GMT Received: from mail-ie0-f174.google.com (mail-ie0-f174.google.com [209.85.223.174]) by aserp1020.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id r0GLr8br015447 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 16 Jan 2013 21:53:08 GMT Received: by mail-ie0-f174.google.com with SMTP id c11so3493038ieb.19 for ; Wed, 16 Jan 2013 13:53:08 -0800 (PST) X-Received: by 10.50.151.227 with SMTP id ut3mr6180668igb.5.1358373187959; Wed, 16 Jan 2013 13:53:07 -0800 (PST) Received: from seurat.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net. [99.26.161.222]) by mx.google.com with ESMTPS id as6sm5330322igc.8.2013.01.16.13.53.04 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 16 Jan 2013 13:53:07 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Wed, 16 Jan 2013 16:53:03 -0500 Message-ID: <20130116215303.21683.91052.stgit@seurat.1015granger.net> In-Reply-To: <20130116214757.21683.47697.stgit@seurat.1015granger.net> References: <20130116214757.21683.47697.stgit@seurat.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-Flow-Control-Info: class=Default reputation=ipRepBelow100 ip=209.85.223.174 ct-class=R5 ct-vol1=-93 ct-vol2=8 ct-vol3=8 ct-risk=42 ct-spam1=65 ct-spam2=6 ct-bulk=5 rcpts=1 size=2574 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090207.50F72144.007D,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 09/11] fedfsd: Encapsulate nsdb_ping_s() logic in separate function X-BeenThere: fedfs-utils-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list Reply-To: fedfs-utils Developers List-Id: fedfs-utils Developers List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: fedfs-utils-devel-bounces@oss.oracle.com Errors-To: fedfs-utils-devel-bounces@oss.oracle.com X-Source-IP: acsinet22.oracle.com [141.146.126.238] Clean up: simplify fedfsd_svc_set_nsdb_params_1() by moving the nsdb_ping_s() call site and the following switch statement to a separate function. Signed-off-by: Chuck Lever --- src/fedfsd/svc.c | 55 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/fedfsd/svc.c b/src/fedfsd/svc.c index ec8258b..e3c9bc4 100644 --- a/src/fedfsd/svc.c +++ b/src/fedfsd/svc.c @@ -935,6 +935,46 @@ out: } /** + * Ping NSDB node + * + * @param hostname NUL-terminated C string containing NDS hostname of NSDB + * @param port NSDB node's IP port number + * @return a FedFsStatus code + */ +static FedFsStatus +fedfsd_test_nsdb(const char *hostname, unsigned short port) +{ + unsigned int ldap_err; + FedFsStatus retval; + + xlog(D_CALL, "%s: pinging %s:%u", __func__, hostname, port); + + retval = nsdb_ping_s(hostname, port, &ldap_err); + switch (retval) { + case FEDFS_OK: + xlog(D_GENERAL, "%s: %s:%u passed ping test", + __func__, hostname, port); + break; + case FEDFS_ERR_NSDB_NONCE: + xlog(D_GENERAL, "%s: %s:%u is up, but not an NSDB: %s", + __func__, hostname, port, + nsdb_display_fedfsstatus(retval)); + break; + case FEDFS_ERR_NSDB_LDAP_VAL: + xlog(D_GENERAL, "%s: failed to ping NSDB %s:%u: %s\n", + __func__, hostname, port, + ldap_err2string(ldap_err)); + break; + default: + xlog(D_GENERAL, "%s: failed to ping NSDB %s:%u: %s", + __func__, hostname, port, + nsdb_display_fedfsstatus(retval)); + } + + return retval; +} + +/** * Service a SET_NSDB_PARAMS request * * @param xprt transport on which to send reply @@ -947,7 +987,6 @@ fedfsd_svc_set_nsdb_params_1(SVCXPRT *xprt) struct fedfs_secdata secdata; FedFsSetNsdbParamsArgs args; char *hostname = NULL; - unsigned int ldap_err; unsigned short port; FedFsStatus result; @@ -962,19 +1001,9 @@ fedfsd_svc_set_nsdb_params_1(SVCXPRT *xprt) if (result != FEDFS_OK) goto out; - result = nsdb_ping_s(hostname, port, &ldap_err); - switch (result) { - case FEDFS_OK: - break; - case FEDFS_ERR_NSDB_LDAP_VAL: - xlog(L_ERROR, "Failed to ping NSDB %s:%u: %s\n", - hostname, port, ldap_err2string(ldap_err)); - goto out; - default: - xlog(L_ERROR, "Warning: %s:%u is not an NSDB: %s", - hostname, port, nsdb_display_fedfsstatus(result)); + result = fedfsd_test_nsdb(hostname, port); + if (result != FEDFS_OK) goto out; - } switch (args.params.secType) { case FEDFS_SEC_NONE: