@@ -849,7 +849,6 @@ fedfsd_prepare_fedfsfsl_array(const struct fedfs_fsl *fsls,
static void
fedfsd_svc_lookup_junction_1(SVCXPRT *xprt)
{
- unsigned int ldap_err = 0;
FedFsLookupRes result;
FedFsLookupResOk *resok = &result.FedFsLookupRes_u.resok;
FedFsLookupArgs args;
@@ -922,11 +921,11 @@ again:
if (result.status != FEDFS_OK)
break;
- result.status = nsdb_resolve_fsn_s(host, NULL, fsn_uuid,
- &fsls, &ldap_err);
+ result.status = nsdb_resolve_fsn_s(host, NULL, fsn_uuid, &fsls);
if (result.status == FEDFS_ERR_NSDB_LDAP_VAL) {
- if (ldap_err != LDAP_REFERRAL) {
- result.FedFsLookupRes_u.ldapResultCode = ldap_err;
+ if (nsdb_ldaperr(host) != LDAP_REFERRAL) {
+ result.FedFsLookupRes_u.ldapResultCode =
+ nsdb_ldaperr(host);
nsdb_close_nsdb(host);
break;
}
@@ -387,11 +387,9 @@ FedFsStatus nsdb_find_naming_context_s(nsdb_t host, const char *entry,
* Resolve an FSN (5.2.2)
*/
FedFsStatus nsdb_resolve_fsn_s(nsdb_t host, const char *nce,
- const char *fsn_uuid, struct fedfs_fsl **fsls,
- unsigned int *ldap_err);
+ const char *fsn_uuid, struct fedfs_fsl **fsls);
FedFsStatus nsdb_get_fsn_s(nsdb_t host, const char *nce,
- const char *fsn_uuid, struct fedfs_fsn **fsn,
- unsigned int *ldap_err);
+ const char *fsn_uuid, struct fedfs_fsn **fsn);
/**
** NSDB fileserver operations defined by this implementation
@@ -1165,7 +1165,6 @@ nsdb_resolve_fsn_parse_entry(LDAP *ld, LDAPMessage *entry,
* @param nce a NUL-terminated C string containing DN of NSDB container entry
* @param fsn_uuid a NUL-terminated C string containing FSN UUID
* @param fsls OUT: a list of fedfs_fsl structures
- * @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*
* ldapsearch equivalent:
@@ -1177,13 +1176,13 @@ nsdb_resolve_fsn_parse_entry(LDAP *ld, LDAPMessage *entry,
*/
static FedFsStatus
nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
- struct fedfs_fsl **fsls, unsigned int *ldap_err)
+ struct fedfs_fsl **fsls)
{
LDAPMessage *response, *message;
LDAP *ld = host->fn_ldap;
struct fedfs_fsl *tmp;
- int len, rc, entries;
FedFsStatus retval;
+ int len, entries;
char *filter;
filter = malloc(128);
@@ -1200,10 +1199,11 @@ nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid
return FEDFS_ERR_INVAL;
}
- rc = nsdb_search_nsdb_all_s(ld, nce, LDAP_SCOPE_SUBTREE,
- filter, &response);
+ host->fn_ldaperr = nsdb_search_nsdb_all_s(ld, nce,
+ LDAP_SCOPE_SUBTREE,
+ filter, &response);
free(filter);
- switch (rc) {
+ switch (host->fn_ldaperr) {
case LDAP_SUCCESS:
case LDAP_REFERRAL:
break;
@@ -1213,8 +1213,7 @@ nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid
return FEDFS_ERR_NSDB_NOFSN;
default:
xlog(D_GENERAL, "%s: LDAP search failed: %s",
- __func__, ldap_err2string(rc));
- *ldap_err = rc;
+ __func__, ldap_err2string(host->fn_ldaperr));
return FEDFS_ERR_NSDB_LDAP_VAL;
}
if (response == NULL) {
@@ -1243,7 +1242,7 @@ nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid
case LDAP_RES_SEARCH_RESULT:
retval = nsdb_parse_result(ld, message,
&host->fn_referrals,
- ldap_err);
+ &host->fn_ldaperr);
break;
default:
xlog(L_ERROR, "%s: Unrecognized LDAP message type",
@@ -1274,7 +1273,6 @@ nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid
* @param nce a NUL-terminated C string containing DN of NSDB container entry
* @param fsn_uuid a NUL-terminated C string containing FSN UUID
* @param fsls OUT: a list of fedfs_fsl structures
- * @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*
* If caller did not provide an NCE, discover one by querying the NSDB.
@@ -1283,7 +1281,7 @@ nsdb_resolve_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid
*/
FedFsStatus
nsdb_resolve_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
- struct fedfs_fsl **fsls, unsigned int *ldap_err)
+ struct fedfs_fsl **fsls)
{
char **contexts, **nce_list;
FedFsStatus retval;
@@ -1299,24 +1297,22 @@ nsdb_resolve_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
return FEDFS_ERR_INVAL;
}
- if (fsls == NULL || ldap_err == NULL) {
+ if (fsls == NULL) {
xlog(L_ERROR, "%s: Invalid parameter", __func__);
return FEDFS_ERR_INVAL;
}
if (nce != NULL)
return nsdb_resolve_fsn_find_entry_s(host, nce,
- fsn_uuid, fsls, ldap_err);
+ fsn_uuid, fsls);
/*
* Caller did not provide an nce. Generate a list
* of the server's NSDB container entries.
*/
retval = nsdb_get_naming_contexts_s(host, &contexts);
- if (retval != FEDFS_OK) {
- *ldap_err = (unsigned int)nsdb_ldaperr(host);
+ if (retval != FEDFS_OK)
return retval;
- }
for (i = 0; contexts[i] != NULL; i++);
nce_list = calloc(i + 1, sizeof(char *));
@@ -1338,8 +1334,7 @@ nsdb_resolve_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
for (j = 0; nce_list[j] != NULL; j++) {
retval = nsdb_resolve_fsn_find_entry_s(host, nce_list[j],
- fsn_uuid, fsls,
- ldap_err);
+ fsn_uuid, fsls);
if (retval == FEDFS_OK)
break;
}
@@ -1488,7 +1483,6 @@ nsdb_get_fsn_parse_entry(LDAP *ld, LDAPMessage *entry,
* @param nce a NUL-terminated C string containing DN of NSDB container entry
* @param fsn_uuid a NUL-terminated C string containing FSN UUID
* @param fsn OUT: a fedfs_fsn structures
- * @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*
* Caller must free the returned "fsn" using nsdb_free_fedfs_fsn().
@@ -1502,13 +1496,13 @@ nsdb_get_fsn_parse_entry(LDAP *ld, LDAPMessage *entry,
*/
static FedFsStatus
nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
- struct fedfs_fsn **fsn, unsigned int *ldap_err)
+ struct fedfs_fsn **fsn)
{
LDAPMessage *response, *message;
LDAP *ld = host->fn_ldap;
struct fedfs_fsn *tmp;
- int len, rc, entries;
FedFsStatus retval;
+ int len, entries;
char *filter;
filter = malloc(128);
@@ -1525,9 +1519,10 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
return FEDFS_ERR_INVAL;
}
- rc = nsdb_search_nsdb_all_s(ld, nce, LDAP_SCOPE_ONE, filter, &response);
+ host->fn_ldaperr = nsdb_search_nsdb_all_s(ld, nce, LDAP_SCOPE_ONE,
+ filter, &response);
free(filter);
- switch (rc) {
+ switch (host->fn_ldaperr) {
case LDAP_SUCCESS:
case LDAP_REFERRAL:
break;
@@ -1537,8 +1532,7 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
return FEDFS_ERR_NSDB_NOFSN;
default:
xlog(D_GENERAL, "%s: LDAP search failed: %s",
- __func__, ldap_err2string(rc));
- *ldap_err = rc;
+ __func__, ldap_err2string(host->fn_ldaperr));
return FEDFS_ERR_NSDB_LDAP_VAL;
}
if (response == NULL) {
@@ -1566,7 +1560,7 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
case LDAP_RES_SEARCH_RESULT:
retval = nsdb_parse_result(ld, message,
&host->fn_referrals,
- ldap_err);
+ &host->fn_ldaperr);
break;
default:
xlog(L_ERROR, "%s: Unrecognized LDAP message type",
@@ -1591,7 +1585,6 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
* @param nce a NUL-terminated C string containing DN of NSDB container entry
* @param fsn_uuid a NUL-terminated C string containing FSN UUID
* @param fsn OUT: a fedfs_fsn structures
- * @param ldap_err OUT: possibly an LDAP error code
* @return a FedFsStatus code
*
* If caller did not provide an NCE, discover one by querying the NSDB.
@@ -1600,7 +1593,7 @@ nsdb_get_fsn_find_entry_s(nsdb_t host, const char *nce, const char *fsn_uuid,
*/
FedFsStatus
nsdb_get_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
- struct fedfs_fsn **fsn, unsigned int *ldap_err)
+ struct fedfs_fsn **fsn)
{
char **contexts, **nce_list;
FedFsStatus retval;
@@ -1616,24 +1609,21 @@ nsdb_get_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
return FEDFS_ERR_INVAL;
}
- if (fsn == NULL || ldap_err == NULL) {
+ if (fsn == NULL) {
xlog(L_ERROR, "%s: Invalid parameter", __func__);
return FEDFS_ERR_INVAL;
}
if (nce != NULL)
- return nsdb_get_fsn_find_entry_s(host, nce, fsn_uuid,
- fsn, ldap_err);
+ return nsdb_get_fsn_find_entry_s(host, nce, fsn_uuid, fsn);
/*
* Caller did not provide an nce. Generate a list
* of the server's NSDB container entries.
*/
retval = nsdb_get_naming_contexts_s(host, &contexts);
- if (retval != FEDFS_OK) {
- *ldap_err = (unsigned int)nsdb_ldaperr(host);
+ if (retval != FEDFS_OK)
return retval;
- }
for (i = 0; contexts[i] != NULL; i++);
nce_list = calloc(i + 1, sizeof(char *));
@@ -1654,8 +1644,8 @@ nsdb_get_fsn_s(nsdb_t host, const char *nce, const char *fsn_uuid,
goto out;
for (j = 0; nce_list[j] != NULL; j++) {
- retval = nsdb_get_fsn_find_entry_s(host, nce_list[j], fsn_uuid,
- fsn, ldap_err);
+ retval = nsdb_get_fsn_find_entry_s(host, nce_list[j],
+ fsn_uuid, fsn);
if (retval == FEDFS_OK)
break;
}
@@ -345,7 +345,6 @@ nfsref_lookup_resolve_fsn(const char *fsn_uuid, nsdb_t host)
int status = EXIT_FAILURE;
struct fedfs_fsl *fsls;
struct fedfs_fsn *fsn;
- unsigned int ldap_err;
FedFsStatus retval;
int fsn_ttl;
@@ -378,7 +377,7 @@ again:
}
- retval = nsdb_get_fsn_s(host, NULL, fsn_uuid, &fsn, &ldap_err);
+ retval = nsdb_get_fsn_s(host, NULL, fsn_uuid, &fsn);
switch (retval) {
case FEDFS_OK:
fsn_ttl = fsn->fn_fsnttl;
@@ -390,7 +389,7 @@ again:
goto out_close;
case FEDFS_ERR_NSDB_LDAP_VAL:
xlog(L_ERROR, "%s: NSDB operation failed with %s",
- __func__, ldap_err2string(ldap_err));
+ __func__, nsdb_ldaperr2string(host));
goto out_close;
default:
xlog(L_ERROR, "%s: Failed to retrieve FSN %s: %s",
@@ -398,7 +397,7 @@ again:
goto out_close;
}
- retval = nsdb_resolve_fsn_s(host, NULL, fsn_uuid, &fsls, &ldap_err);
+ retval = nsdb_resolve_fsn_s(host, NULL, fsn_uuid, &fsls);
switch (retval) {
case FEDFS_OK:
printf("fedfsFsnUuid:\t%s\n", fsn_uuid);
@@ -419,7 +418,7 @@ again:
__func__, fsn_uuid);
break;
case FEDFS_ERR_NSDB_LDAP_VAL:
- switch (ldap_err) {
+ switch (nsdb_ldaperr(host)) {
case LDAP_REFERRAL:
retval = nfsref_lookup_follow_ldap_referral(&host);
if (retval == FEDFS_OK)
@@ -431,7 +430,7 @@ again:
break;
default:
xlog(L_ERROR, "%s: NSDB operation failed with %s",
- __func__, ldap_err2string(ldap_err));
+ __func__, nsdb_ldaperr2string(host));
}
break;
default:
@@ -114,12 +114,11 @@ static void
nsdb_list_resolve_and_display_fsn(nsdb_t host, const char *nce, const char *fsn_uuid)
{
struct fedfs_fsl *fsls;
- unsigned int ldap_err;
FedFsStatus retval;
printf(" FSN UUID: %s\n", fsn_uuid);
- retval = nsdb_resolve_fsn_s(host, nce, fsn_uuid, &fsls, &ldap_err);
+ retval = nsdb_resolve_fsn_s(host, nce, fsn_uuid, &fsls);
switch (retval) {
case FEDFS_OK:
nsdb_list_display_fsls(fsls);
@@ -130,7 +129,7 @@ nsdb_list_resolve_and_display_fsn(nsdb_t host, const char *nce, const char *fsn_
break;
case FEDFS_ERR_NSDB_LDAP_VAL:
fprintf(stderr, "NSDB LDAP error: %s\n",
- ldap_err2string(ldap_err));
+ nsdb_ldaperr2string(host));
break;
default:
fprintf(stderr, "Failed to resolve FSN UUID %s: %s\n",
@@ -250,7 +250,6 @@ main(int argc, char **argv)
unsigned short nsdbport;
struct fedfs_fsl *fsls;
struct fedfs_fsn *fsn;
- unsigned int ldap_err;
char *nce, *fsn_uuid;
FedFsStatus retval;
int fsn_ttl, arg;
@@ -358,7 +357,7 @@ again:
goto out_free;
}
- retval = nsdb_get_fsn_s(host, nce, fsn_uuid, &fsn, &ldap_err);
+ retval = nsdb_get_fsn_s(host, nce, fsn_uuid, &fsn);
switch (retval) {
case FEDFS_OK:
fsn_ttl = fsn->fn_fsnttl;
@@ -375,7 +374,7 @@ again:
fprintf(stderr, "Failed to find FSN %s\n", fsn_uuid);
goto out_close;
case FEDFS_ERR_NSDB_LDAP_VAL:
- switch (ldap_err) {
+ switch (nsdb_ldaperr(host)) {
case LDAP_REFERRAL:
retval = nsdb_resolve_fsn_follow_ldap_referral(&host);
if (retval == FEDFS_OK)
@@ -387,7 +386,7 @@ again:
break;
default:
fprintf(stderr, "NSDB LDAP error: %s\n",
- ldap_err2string(ldap_err));
+ nsdb_ldaperr2string(host));
}
goto out_close;
default:
@@ -397,7 +396,7 @@ again:
goto out_close;
}
- retval = nsdb_resolve_fsn_s(host, nce, fsn_uuid, &fsls, &ldap_err);
+ retval = nsdb_resolve_fsn_s(host, nce, fsn_uuid, &fsls);
switch (retval) {
case FEDFS_OK:
printf("For FSN UUID: %s\n", fsn_uuid);
@@ -421,14 +420,14 @@ again:
fprintf(stderr, "Failed to find FSN %s\n", fsn_uuid);
break;
case FEDFS_ERR_NSDB_LDAP_VAL:
- if (ldap_err == LDAP_REFERRAL) {
+ if (nsdb_ldaperr(host) == LDAP_REFERRAL) {
retval = nsdb_resolve_fsn_follow_ldap_referral(&host);
if (retval != FEDFS_OK)
break;
goto again;
}
fprintf(stderr, "NSDB LDAP error: %s\n",
- ldap_err2string(ldap_err));
+ nsdb_ldaperr2string(host));
break;
default:
fprintf(stderr, "FedFsStatus code "
@@ -390,7 +390,6 @@ nfs_jp_resolve_fsn(const char *fsn_uuid, nsdb_t host,
enum jp_status status = JP_NSDBREMOTE;
struct fedfs_fsl *fsls;
struct fedfs_fsn *fsn;
- unsigned int ldap_err;
FedFsStatus retval;
int fsn_ttl;
@@ -419,7 +418,7 @@ again:
return JP_NSDBLOCAL;
}
- retval = nsdb_get_fsn_s(host, NULL, fsn_uuid, &fsn, &ldap_err);
+ retval = nsdb_get_fsn_s(host, NULL, fsn_uuid, &fsn);
switch (retval) {
case FEDFS_OK:
fsn_ttl = fsn->fn_fsnttl;
@@ -434,7 +433,7 @@ again:
__func__, fsn_uuid);
goto out_close;
case FEDFS_ERR_NSDB_LDAP_VAL:
- switch (ldap_err) {
+ switch (nsdb_ldaperr(host)) {
case LDAP_REFERRAL:
retval = nfs_jp_follow_ldap_referral(&host);
if (retval == FEDFS_OK)
@@ -446,7 +445,7 @@ again:
break;
default:
nfs_jp_debug("%s: NSDB operation failed with %s\n",
- __func__, ldap_err2string(ldap_err));
+ __func__, nsdb_ldaperr2string(host));
}
goto out_close;
default:
@@ -455,7 +454,7 @@ again:
goto out_close;
}
- retval = nsdb_resolve_fsn_s(host, NULL, fsn_uuid, &fsls, &ldap_err);
+ retval = nsdb_resolve_fsn_s(host, NULL, fsn_uuid, &fsls);
switch (retval) {
case FEDFS_OK:
status = nfs_jp_convert_fedfs_fsls(fsls, new);
@@ -475,7 +474,7 @@ again:
break;
case FEDFS_ERR_NSDB_LDAP_VAL:
nfs_jp_debug("%s: NSDB operation failed with %s\n",
- __func__, ldap_err2string(ldap_err));
+ __func__, nsdb_ldaperr2string(host));
break;
default:
nfs_jp_debug("%s: Failed to resolve FSN %s: %s\n",
Simplify the FSN resolution API by removing the *ldaperr argument. When it is needed, the ldaperr value can be extracted with the new nsdb_ldaperr() function. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> --- src/fedfsd/svc.c | 9 +++--- src/include/nsdb.h | 6 +--- src/libnsdb/fileserver.c | 62 ++++++++++++++++++------------------------ src/nfsref/lookup.c | 11 +++---- src/nsdbc/nsdb-list.c | 5 +-- src/nsdbc/nsdb-resolve-fsn.c | 13 ++++----- src/plug-ins/nfs-plugin.c | 11 +++---- 7 files changed, 50 insertions(+), 67 deletions(-)