提交 8695b90a 编写于 作者: J J. Bruce Fields

nfsd4: fix error return in non-matching-creds case

Note CLID_INUSE is for the case where two clients are trying to use the
same client-provided long-form client identifiers.  But what we're
looking at here is the server-returned shorthand client id--if those
clash there's a bug somewhere.

Fix the error return, pull the check out into common code, and do the
check unconditionally in all cases.
Signed-off-by: NJ. Bruce Fields <bfields@redhat.com>
上级 788c1eba
...@@ -2229,59 +2229,49 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, ...@@ -2229,59 +2229,49 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp,
if (STALE_CLIENTID(clid)) if (STALE_CLIENTID(clid))
return nfserr_stale_clientid; return nfserr_stale_clientid;
/*
* XXX The Duplicate Request Cache (DRC) has been checked (??)
* We get here on a DRC miss.
*/
nfs4_lock_state(); nfs4_lock_state();
conf = find_confirmed_client(clid); conf = find_confirmed_client(clid);
unconf = find_unconfirmed_client(clid); unconf = find_unconfirmed_client(clid);
/*
* We try hard to give out unique clientid's, so if we get an
* attempt to confirm the same clientid with a different cred,
* there's a bug somewhere. Let's charitably assume it's our
* bug.
*/
status = nfserr_serverfault;
if (unconf && !same_creds(&unconf->cl_cred, &rqstp->rq_cred))
goto out;
if (conf && !same_creds(&conf->cl_cred, &rqstp->rq_cred))
goto out;
/* cases below refer to rfc 3530 section 14.2.34: */ /* cases below refer to rfc 3530 section 14.2.34: */
status = nfserr_clid_inuse;
if (conf && unconf && same_verf(&confirm, &unconf->cl_confirm)) { if (conf && unconf && same_verf(&confirm, &unconf->cl_confirm)) {
/* case 1: callback update */ /* case 1: callback update */
if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)) nfsd4_change_callback(conf, &unconf->cl_cb_conn);
status = nfserr_clid_inuse; nfsd4_probe_callback(conf);
else { expire_client(unconf);
nfsd4_change_callback(conf, &unconf->cl_cb_conn); status = nfs_ok;
nfsd4_probe_callback(conf);
expire_client(unconf);
status = nfs_ok;
}
} else if (conf && !unconf) { } else if (conf && !unconf) {
/* case 2: probable retransmit: */ status = nfs_ok;
if (!same_creds(&conf->cl_cred, &rqstp->rq_cred))
status = nfserr_clid_inuse;
else
status = nfs_ok;
} else if (!conf && unconf } else if (!conf && unconf
&& same_verf(&unconf->cl_confirm, &confirm)) { && same_verf(&unconf->cl_confirm, &confirm)) {
/* case 3: normal case; new or rebooted client */ /* case 3: normal case; new or rebooted client */
if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred)) { unsigned int hash = clientstr_hashval(unconf->cl_recdir);
status = nfserr_clid_inuse; conf = find_confirmed_client_by_str(unconf->cl_recdir, hash);
} else { if (conf) {
unsigned int hash = nfsd4_client_record_remove(conf);
clientstr_hashval(unconf->cl_recdir); expire_client(conf);
conf = find_confirmed_client_by_str(unconf->cl_recdir,
hash);
if (conf) {
nfsd4_client_record_remove(conf);
expire_client(conf);
}
move_to_confirmed(unconf);
conf = unconf;
nfsd4_probe_callback(conf);
status = nfs_ok;
} }
move_to_confirmed(unconf);
conf = unconf;
nfsd4_probe_callback(conf);
status = nfs_ok;
} else if ((!conf || !same_verf(&conf->cl_confirm, &confirm)) } else if ((!conf || !same_verf(&conf->cl_confirm, &confirm))
&& (!unconf || !same_verf(&unconf->cl_confirm, &confirm))) { && (!unconf || !same_verf(&unconf->cl_confirm, &confirm))) {
/* case 4: client hasn't noticed we rebooted yet? */ /* case 4: client hasn't noticed we rebooted yet? */
status = nfserr_stale_clientid; status = nfserr_stale_clientid;
} }
out:
nfs4_unlock_state(); nfs4_unlock_state();
return status; return status;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册