From patchwork Fri Dec 14 22:38:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 206584 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 D33412C0089 for ; Sat, 15 Dec 2012 09:38:56 +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 qBEMcri9017039 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 14 Dec 2012 22:38:54 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 qBEMcrf1004413 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 14 Dec 2012 22:38:53 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tjdu9-0005xl-10; Fri, 14 Dec 2012 14:38:53 -0800 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1Tjdu3-0005xV-HT for fedfs-utils-devel@oss.oracle.com; Fri, 14 Dec 2012 14:38:47 -0800 Received: from userp1030.oracle.com (userp1030.oracle.com [156.151.31.80]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id qBEMckhV004261 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 14 Dec 2012 22:38:47 GMT Received: from mail-ie0-f171.google.com (mail-ie0-f171.google.com [209.85.223.171]) by userp1030.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id qBEMcjHF027259 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 14 Dec 2012 22:38:46 GMT Received: by mail-ie0-f171.google.com with SMTP id 17so6805282iea.2 for ; Fri, 14 Dec 2012 14:38:45 -0800 (PST) Received: by 10.50.185.194 with SMTP id fe2mr3135838igc.60.1355524725863; Fri, 14 Dec 2012 14:38:45 -0800 (PST) Received: from seurat.1015granger.net ([99.26.161.222]) by mx.google.com with ESMTPS id c3sm2485407igj.1.2012.12.14.14.38.45 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 14 Dec 2012 14:38:45 -0800 (PST) From: Chuck Lever To: fedfs-utils-devel@oss.oracle.com Date: Fri, 14 Dec 2012 17:38:44 -0500 Message-ID: <20121214223844.22243.59180.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=2631 X-MM-CT-Classification: not spam X-MM-CT-RefID: str=0001.0A090202.50CBAA76.005D,ss=1,re=0.000,fgs=0 Subject: [fedfs-utils] [PATCH 10/11] nfsref: 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/nfsref/lookup.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-) diff --git a/src/nfsref/lookup.c b/src/nfsref/lookup.c index 96454fd..cc3e293 100644 --- a/src/nfsref/lookup.c +++ b/src/nfsref/lookup.c @@ -268,6 +268,52 @@ nfsref_lookup_display_fedfs_fsl(struct fedfs_fsl *fsl) } /** + * 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 +nfsref_lookup_follow_ldap_referral(nsdb_t *host) +{ + static unsigned int nest = 0; + FedFsStatus retval; + nsdb_t old, refer; + + old = *host; + if (!nsdb_follow_referrals(old)) { + xlog(L_ERROR, "LDAP referrals for NSDB %s:%u disallowed", + nsdb_hostname(old), nsdb_port(old)); + return FEDFS_ERR_NSDB_LDAP_REFERRAL_NOTFOLLOWED; + } + + if (nest++ > 10) { + xlog(L_ERROR, "Possible referral loop for NSDB %s:%u", + 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: + xlog(L_ERROR, "Encountered referral to unrecognized NSDB %s", + nsdb_referred_to(old)); + return FEDFS_ERR_NSDB_LDAP_REFERRAL_NOTFOLLOWED; + default: + xlog(L_ERROR, "Problem following referral: %s", + nsdb_display_fedfsstatus(retval)); + return retval; + } + + nsdb_close_nsdb(old); + nsdb_free_nsdb(old); + *host = refer; + return FEDFS_OK; +} + +/** * Display a list of FedFS fileset locations * * @param fsls list of FedFS fileset locations to display @@ -301,6 +347,7 @@ nfsref_lookup_resolve_fsn(const char *fsn_uuid, nsdb_t host) xlog(D_GENERAL, "%s: resolving FSN UUID %s with NSDB %s:%u", __func__, fsn_uuid, nsdb_hostname(host), nsdb_port(host)); +again: if (nsdb_open_nsdb(host, NULL, NULL, &ldap_err) != FEDFS_OK) return status; @@ -345,6 +392,12 @@ nfsref_lookup_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 = nfsref_lookup_follow_ldap_referral(&host); + if (retval != FEDFS_OK) + break; + goto again; + } xlog(L_ERROR, "%s: NSDB operation failed with %s", __func__, ldap_err2string(ldap_err)); break;