Commit c175b83c authored by J. Bruce Fields's avatar J. Bruce Fields

knfsd: remove code duplication in nfsd4_setclientid()

Each branch of this if-then-else has a bunch of duplicated code that we
could just put at the end.
Signed-off-by: default avatar"J. Bruce Fields" <bfields@citi.umich.edu>
Acked-by: default avatarNeil Brown <neilb@suse.de>
parent 246d95ba
...@@ -774,13 +774,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -774,13 +774,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
new = create_client(clname, dname); new = create_client(clname, dname);
if (new == NULL) if (new == NULL)
goto out; goto out;
copy_verf(new, &clverifier);
new->cl_addr = sin->sin_addr.s_addr;
copy_cred(&new->cl_cred,&rqstp->rq_cred);
gen_clid(new); gen_clid(new);
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new, strhashval);
} else if (same_verf(&conf->cl_verifier, &clverifier)) { } else if (same_verf(&conf->cl_verifier, &clverifier)) {
/* /*
* CASE 1: * CASE 1:
...@@ -806,13 +800,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -806,13 +800,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
new = create_client(clname, dname); new = create_client(clname, dname);
if (new == NULL) if (new == NULL)
goto out; goto out;
copy_verf(new,&conf->cl_verifier);
new->cl_addr = sin->sin_addr.s_addr;
copy_cred(&new->cl_cred,&rqstp->rq_cred);
copy_clid(new, conf); copy_clid(new, conf);
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new,strhashval);
} else if (!unconf) { } else if (!unconf) {
/* /*
* CASE 2: * CASE 2:
...@@ -825,13 +813,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -825,13 +813,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
new = create_client(clname, dname); new = create_client(clname, dname);
if (new == NULL) if (new == NULL)
goto out; goto out;
copy_verf(new,&clverifier);
new->cl_addr = sin->sin_addr.s_addr;
copy_cred(&new->cl_cred,&rqstp->rq_cred);
gen_clid(new); gen_clid(new);
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new, strhashval);
} else if (!same_verf(&conf->cl_confirm, &unconf->cl_confirm)) { } else if (!same_verf(&conf->cl_confirm, &unconf->cl_confirm)) {
/* /*
* CASE3: * CASE3:
...@@ -852,19 +834,19 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -852,19 +834,19 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
new = create_client(clname, dname); new = create_client(clname, dname);
if (new == NULL) if (new == NULL)
goto out; goto out;
copy_verf(new,&clverifier);
new->cl_addr = sin->sin_addr.s_addr;
copy_cred(&new->cl_cred,&rqstp->rq_cred);
gen_clid(new); gen_clid(new);
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new, strhashval);
} else { } else {
/* No cases hit !!! */ /* No cases hit !!! */
status = nfserr_inval; status = nfserr_inval;
goto out; goto out;
} }
copy_verf(new, &clverifier);
new->cl_addr = sin->sin_addr.s_addr;
copy_cred(&new->cl_cred, &rqstp->rq_cred);
gen_confirm(new);
gen_callback(new, setclid);
add_to_unconfirmed(new, strhashval);
setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot; setclid->se_clientid.cl_boot = new->cl_clientid.cl_boot;
setclid->se_clientid.cl_id = new->cl_clientid.cl_id; setclid->se_clientid.cl_id = new->cl_clientid.cl_id;
memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data)); memcpy(setclid->se_confirm.data, new->cl_confirm.data, sizeof(setclid->se_confirm.data));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment