From patchwork Fri Dec 14 22:38:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 206583 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "aserp1040.oracle.com", Issuer "VeriSign Class 3 International Server CA - G3" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B6B5C2C0095 for ; Sat, 15 Dec 2012 09:38:46 +1100 (EST) Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by aserp1040.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qBEMchhs027702 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Dec 2012 22:38:44 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 qBEMchYG004186 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Dec 2012 22:38:43 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tjdty-0005x5-WC; Fri, 14 Dec 2012 14:38:43 -0800 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tjdtu-0005wn-NB for fedfs-utils-devel@oss.oracle.com; Fri, 14 Dec 2012 14:38:38 -0800 Received: from aserp1020.oracle.com (aserp1020.oracle.com [141.146.126.67]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qBEMccBR004110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 22:38:38 GMT Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) by aserp1020.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qBEMcb02006714 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 14 Dec 2012 22:38:38 GMT Received: by mail-ie0-f171.google.com with SMTP id 17so6805155iea.2 for ; Fri, 14 Dec 2012 14:38:37 -0800 (PST) Received: by 10.50.153.169 with SMTP id vh9mr3043654igb.67.1355524717260; Fri, 14 Dec 2012 14:38:37 -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 hg2sm7772135igc.3.2012.12.14.14.38.36 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 14:38:36 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Fri, 14 Dec 2012 17:38:36 -0500 Message-ID: <20121214223836.22243.5401.stgit@seurat.1015granger.net> In-Reply-To: <20121214221556.22243.9462.stgit@seurat.1015granger.net> References: <20121214221556.22243.9462.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.171 ct-class=R5 ct-vol1=-97 ct-vol2=9 ct-vol3=8 ct-risk=50 ct-spam1=82 ct-spam2=6 ct-bulk=5 rcpts=1 size=2597 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090202.50CBAA6E.0031,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 09/11] plug-in: Follow LDAP referrals when resolving FSNs 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] FSN resolution is allowed to follow LDAP referrals if the NSDB's "follow referrals" flag is on. Signed-off-by: Chuck Lever --- src/plug-ins/nfs-plugin.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/src/plug-ins/nfs-plugin.c b/src/plug-ins/nfs-plugin.c index 71f0cda..c50c648 100644 --- a/src/plug-ins/nfs-plugin.c +++ b/src/plug-ins/nfs-plugin.c @@ -327,6 +327,52 @@ nfs_jp_convert_fedfs_fsls(struct fedfs_fsl *fsls, nfs_fsloc_set_t new) } /** + * Attempt to follow an LDAP referral to another NSDB + * + * @param host OUT: pointer to an initialized nsdb_t that may be replaced + * @return a FedFsStatus code + */ +static FedFsStatus +nfs_jp_follow_ldap_referral(nsdb_t *host) +{ + static unsigned int nest = 0; + FedFsStatus retval; + nsdb_t old, refer; + + old = *host; + if (!nsdb_follow_referrals(old)) { + nfs_jp_debug("LDAP referrals for NSDB %s:%u disallowed\n", + nsdb_hostname(old), nsdb_port(old)); + return FEDFS_ERR_NSDB_LDAP_REFERRAL_NOTFOLLOWED; + } + + if (nest++ > 10) { + nfs_jp_debug("Possible referral loop for NSDB %s:%u\n", + nsdb_hostname(old), nsdb_port(old)); + return FEDFS_ERR_NSDB_LDAP_REFERRAL_NOTFOLLOWED; + } + + retval = nsdb_lookup_nsdb_by_uri(nsdb_referred_to(old), &refer); + switch (retval) { + case FEDFS_OK: + break; + case FEDFS_ERR_NSDB_PARAMS: + nfs_jp_debug("Encountered referral to unrecognized NSDB %s\n", + nsdb_referred_to(old)); + return FEDFS_ERR_NSDB_LDAP_REFERRAL_NOTFOLLOWED; + default: + nfs_jp_debug("Problem following referral: %s\n", + nsdb_display_fedfsstatus(retval)); + return retval; + } + + nsdb_close_nsdb(old); + nsdb_free_nsdb(old); + *host = refer; + return FEDFS_OK; +} + +/** * Resolve a FedFS fileset name into a set of NFS locations * * @param fsn_uuid NUL-terminated C string containing FSN UUID to resolve @@ -348,6 +394,7 @@ nfs_jp_resolve_fsn(const char *fsn_uuid, nsdb_t host, FedFsStatus retval; int fsn_ttl; +again: if (nsdb_open_nsdb(host, NULL, NULL, &ldap_err) != FEDFS_OK) return JP_NSDBLOCAL; @@ -394,6 +441,12 @@ nfs_jp_resolve_fsn(const char *fsn_uuid, nsdb_t host, __func__, fsn_uuid); break; case FEDFS_ERR_NSDB_LDAP_VAL: + if (ldap_err == LDAP_REFERRAL) { + retval = nfs_jp_follow_ldap_referral(&host); + if (retval != FEDFS_OK) + break; + goto again; + } nfs_jp_debug("%s: NSDB operation failed with %s\n", __func__, ldap_err2string(ldap_err)); break;