diff options
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 91 |
1 files changed, 47 insertions, 44 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3f559700788f..578d809e85ec 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -462,26 +462,28 @@ copy_cred(struct svc_cred *target, struct svc_cred *source) { | |||
462 | } | 462 | } |
463 | 463 | ||
464 | static inline int | 464 | static inline int |
465 | same_name(const char *n1, const char *n2) { | 465 | same_name(const char *n1, const char *n2) |
466 | { | ||
466 | return 0 == memcmp(n1, n2, HEXDIR_LEN); | 467 | return 0 == memcmp(n1, n2, HEXDIR_LEN); |
467 | } | 468 | } |
468 | 469 | ||
469 | static int | 470 | static int |
470 | cmp_verf(nfs4_verifier *v1, nfs4_verifier *v2) { | 471 | same_verf(nfs4_verifier *v1, nfs4_verifier *v2) |
471 | return(!memcmp(v1->data,v2->data,sizeof(v1->data))); | 472 | { |
473 | return 0 == memcmp(v1->data, v2->data, sizeof(v1->data)); | ||
472 | } | 474 | } |
473 | 475 | ||
474 | static int | 476 | static int |
475 | cmp_clid(clientid_t * cl1, clientid_t * cl2) { | 477 | same_clid(clientid_t *cl1, clientid_t *cl2) |
476 | return((cl1->cl_boot == cl2->cl_boot) && | 478 | { |
477 | (cl1->cl_id == cl2->cl_id)); | 479 | return (cl1->cl_boot == cl2->cl_boot) && (cl1->cl_id == cl2->cl_id); |
478 | } | 480 | } |
479 | 481 | ||
480 | /* XXX what about NGROUP */ | 482 | /* XXX what about NGROUP */ |
481 | static int | 483 | static int |
482 | cmp_creds(struct svc_cred *cr1, struct svc_cred *cr2){ | 484 | same_creds(struct svc_cred *cr1, struct svc_cred *cr2) |
483 | return(cr1->cr_uid == cr2->cr_uid); | 485 | { |
484 | 486 | return cr1->cr_uid == cr2->cr_uid; | |
485 | } | 487 | } |
486 | 488 | ||
487 | static void | 489 | static void |
@@ -546,7 +548,7 @@ find_confirmed_client(clientid_t *clid) | |||
546 | unsigned int idhashval = clientid_hashval(clid->cl_id); | 548 | unsigned int idhashval = clientid_hashval(clid->cl_id); |
547 | 549 | ||
548 | list_for_each_entry(clp, &conf_id_hashtbl[idhashval], cl_idhash) { | 550 | list_for_each_entry(clp, &conf_id_hashtbl[idhashval], cl_idhash) { |
549 | if (cmp_clid(&clp->cl_clientid, clid)) | 551 | if (same_clid(&clp->cl_clientid, clid)) |
550 | return clp; | 552 | return clp; |
551 | } | 553 | } |
552 | return NULL; | 554 | return NULL; |
@@ -559,7 +561,7 @@ find_unconfirmed_client(clientid_t *clid) | |||
559 | unsigned int idhashval = clientid_hashval(clid->cl_id); | 561 | unsigned int idhashval = clientid_hashval(clid->cl_id); |
560 | 562 | ||
561 | list_for_each_entry(clp, &unconf_id_hashtbl[idhashval], cl_idhash) { | 563 | list_for_each_entry(clp, &unconf_id_hashtbl[idhashval], cl_idhash) { |
562 | if (cmp_clid(&clp->cl_clientid, clid)) | 564 | if (same_clid(&clp->cl_clientid, clid)) |
563 | return clp; | 565 | return clp; |
564 | } | 566 | } |
565 | return NULL; | 567 | return NULL; |
@@ -753,7 +755,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
753 | * or different ip_address | 755 | * or different ip_address |
754 | */ | 756 | */ |
755 | status = nfserr_clid_inuse; | 757 | status = nfserr_clid_inuse; |
756 | if (!cmp_creds(&conf->cl_cred, &rqstp->rq_cred) | 758 | if (!same_creds(&conf->cl_cred, &rqstp->rq_cred) |
757 | || conf->cl_addr != sin->sin_addr.s_addr) { | 759 | || conf->cl_addr != sin->sin_addr.s_addr) { |
758 | dprintk("NFSD: setclientid: string in use by client" | 760 | dprintk("NFSD: setclientid: string in use by client" |
759 | "at %u.%u.%u.%u\n", NIPQUAD(conf->cl_addr)); | 761 | "at %u.%u.%u.%u\n", NIPQUAD(conf->cl_addr)); |
@@ -779,7 +781,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
779 | gen_confirm(new); | 781 | gen_confirm(new); |
780 | gen_callback(new, setclid); | 782 | gen_callback(new, setclid); |
781 | add_to_unconfirmed(new, strhashval); | 783 | add_to_unconfirmed(new, strhashval); |
782 | } else if (cmp_verf(&conf->cl_verifier, &clverifier)) { | 784 | } else if (same_verf(&conf->cl_verifier, &clverifier)) { |
783 | /* | 785 | /* |
784 | * CASE 1: | 786 | * CASE 1: |
785 | * cl_name match, confirmed, principal match | 787 | * cl_name match, confirmed, principal match |
@@ -830,7 +832,7 @@ nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
830 | gen_confirm(new); | 832 | gen_confirm(new); |
831 | gen_callback(new, setclid); | 833 | gen_callback(new, setclid); |
832 | add_to_unconfirmed(new, strhashval); | 834 | add_to_unconfirmed(new, strhashval); |
833 | } else if (!cmp_verf(&conf->cl_confirm, &unconf->cl_confirm)) { | 835 | } else if (!same_verf(&conf->cl_confirm, &unconf->cl_confirm)) { |
834 | /* | 836 | /* |
835 | * CASE3: | 837 | * CASE3: |
836 | * confirmed found (name, principal match) | 838 | * confirmed found (name, principal match) |
@@ -910,16 +912,16 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
910 | goto out; | 912 | goto out; |
911 | 913 | ||
912 | if ((conf && unconf) && | 914 | if ((conf && unconf) && |
913 | (cmp_verf(&unconf->cl_confirm, &confirm)) && | 915 | (same_verf(&unconf->cl_confirm, &confirm)) && |
914 | (cmp_verf(&conf->cl_verifier, &unconf->cl_verifier)) && | 916 | (same_verf(&conf->cl_verifier, &unconf->cl_verifier)) && |
915 | (same_name(conf->cl_recdir,unconf->cl_recdir)) && | 917 | (same_name(conf->cl_recdir,unconf->cl_recdir)) && |
916 | (!cmp_verf(&conf->cl_confirm, &unconf->cl_confirm))) { | 918 | (!same_verf(&conf->cl_confirm, &unconf->cl_confirm))) { |
917 | /* CASE 1: | 919 | /* CASE 1: |
918 | * unconf record that matches input clientid and input confirm. | 920 | * unconf record that matches input clientid and input confirm. |
919 | * conf record that matches input clientid. | 921 | * conf record that matches input clientid. |
920 | * conf and unconf records match names, verifiers | 922 | * conf and unconf records match names, verifiers |
921 | */ | 923 | */ |
922 | if (!cmp_creds(&conf->cl_cred, &unconf->cl_cred)) | 924 | if (!same_creds(&conf->cl_cred, &unconf->cl_cred)) |
923 | status = nfserr_clid_inuse; | 925 | status = nfserr_clid_inuse; |
924 | else { | 926 | else { |
925 | /* XXX: We just turn off callbacks until we can handle | 927 | /* XXX: We just turn off callbacks until we can handle |
@@ -933,7 +935,7 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
933 | } | 935 | } |
934 | } else if ((conf && !unconf) || | 936 | } else if ((conf && !unconf) || |
935 | ((conf && unconf) && | 937 | ((conf && unconf) && |
936 | (!cmp_verf(&conf->cl_verifier, &unconf->cl_verifier) || | 938 | (!same_verf(&conf->cl_verifier, &unconf->cl_verifier) || |
937 | !same_name(conf->cl_recdir, unconf->cl_recdir)))) { | 939 | !same_name(conf->cl_recdir, unconf->cl_recdir)))) { |
938 | /* CASE 2: | 940 | /* CASE 2: |
939 | * conf record that matches input clientid. | 941 | * conf record that matches input clientid. |
@@ -941,18 +943,18 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
941 | * unconf->cl_name or unconf->cl_verifier don't match the | 943 | * unconf->cl_name or unconf->cl_verifier don't match the |
942 | * conf record. | 944 | * conf record. |
943 | */ | 945 | */ |
944 | if (!cmp_creds(&conf->cl_cred,&rqstp->rq_cred)) | 946 | if (!same_creds(&conf->cl_cred, &rqstp->rq_cred)) |
945 | status = nfserr_clid_inuse; | 947 | status = nfserr_clid_inuse; |
946 | else | 948 | else |
947 | status = nfs_ok; | 949 | status = nfs_ok; |
948 | } else if (!conf && unconf | 950 | } else if (!conf && unconf |
949 | && cmp_verf(&unconf->cl_confirm, &confirm)) { | 951 | && same_verf(&unconf->cl_confirm, &confirm)) { |
950 | /* CASE 3: | 952 | /* CASE 3: |
951 | * conf record not found. | 953 | * conf record not found. |
952 | * unconf record found. | 954 | * unconf record found. |
953 | * unconf->cl_confirm matches input confirm | 955 | * unconf->cl_confirm matches input confirm |
954 | */ | 956 | */ |
955 | if (!cmp_creds(&unconf->cl_cred, &rqstp->rq_cred)) { | 957 | if (!same_creds(&unconf->cl_cred, &rqstp->rq_cred)) { |
956 | status = nfserr_clid_inuse; | 958 | status = nfserr_clid_inuse; |
957 | } else { | 959 | } else { |
958 | unsigned int hash = | 960 | unsigned int hash = |
@@ -967,8 +969,8 @@ nfsd4_setclientid_confirm(struct svc_rqst *rqstp, | |||
967 | conf = unconf; | 969 | conf = unconf; |
968 | status = nfs_ok; | 970 | status = nfs_ok; |
969 | } | 971 | } |
970 | } else if ((!conf || (conf && !cmp_verf(&conf->cl_confirm, &confirm))) | 972 | } else if ((!conf || (conf && !same_verf(&conf->cl_confirm, &confirm))) |
971 | && (!unconf || (unconf && !cmp_verf(&unconf->cl_confirm, | 973 | && (!unconf || (unconf && !same_verf(&unconf->cl_confirm, |
972 | &confirm)))) { | 974 | &confirm)))) { |
973 | /* CASE 4: | 975 | /* CASE 4: |
974 | * conf record not found, or if conf, conf->cl_confirm does not | 976 | * conf record not found, or if conf, conf->cl_confirm does not |
@@ -1207,10 +1209,12 @@ move_to_close_lru(struct nfs4_stateowner *sop) | |||
1207 | } | 1209 | } |
1208 | 1210 | ||
1209 | static int | 1211 | static int |
1210 | cmp_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner, clientid_t *clid) { | 1212 | same_owner_str(struct nfs4_stateowner *sop, struct xdr_netobj *owner, |
1211 | return ((sop->so_owner.len == owner->len) && | 1213 | clientid_t *clid) |
1212 | !memcmp(sop->so_owner.data, owner->data, owner->len) && | 1214 | { |
1213 | (sop->so_client->cl_clientid.cl_id == clid->cl_id)); | 1215 | return (sop->so_owner.len == owner->len) && |
1216 | 0 == memcmp(sop->so_owner.data, owner->data, owner->len) && | ||
1217 | (sop->so_client->cl_clientid.cl_id == clid->cl_id); | ||
1214 | } | 1218 | } |
1215 | 1219 | ||
1216 | static struct nfs4_stateowner * | 1220 | static struct nfs4_stateowner * |
@@ -1219,7 +1223,7 @@ find_openstateowner_str(unsigned int hashval, struct nfsd4_open *open) | |||
1219 | struct nfs4_stateowner *so = NULL; | 1223 | struct nfs4_stateowner *so = NULL; |
1220 | 1224 | ||
1221 | list_for_each_entry(so, &ownerstr_hashtbl[hashval], so_strhash) { | 1225 | list_for_each_entry(so, &ownerstr_hashtbl[hashval], so_strhash) { |
1222 | if (cmp_owner_str(so, &open->op_owner, &open->op_clientid)) | 1226 | if (same_owner_str(so, &open->op_owner, &open->op_clientid)) |
1223 | return so; | 1227 | return so; |
1224 | } | 1228 | } |
1225 | return NULL; | 1229 | return NULL; |
@@ -2181,21 +2185,20 @@ nfs4_preprocess_seqid_op(struct svc_fh *current_fh, u32 seqid, stateid_t *statei | |||
2181 | lkflg = setlkflg(lock->lk_type); | 2185 | lkflg = setlkflg(lock->lk_type); |
2182 | 2186 | ||
2183 | if (lock->lk_is_new) { | 2187 | if (lock->lk_is_new) { |
2184 | if (!sop->so_is_open_owner) | 2188 | if (!sop->so_is_open_owner) |
2185 | return nfserr_bad_stateid; | 2189 | return nfserr_bad_stateid; |
2186 | if (!cmp_clid(&clp->cl_clientid, lockclid)) | 2190 | if (!same_clid(&clp->cl_clientid, lockclid)) |
2187 | return nfserr_bad_stateid; | 2191 | return nfserr_bad_stateid; |
2188 | /* stp is the open stateid */ | 2192 | /* stp is the open stateid */ |
2189 | status = nfs4_check_openmode(stp, lkflg); | 2193 | status = nfs4_check_openmode(stp, lkflg); |
2190 | if (status) | 2194 | if (status) |
2191 | return status; | 2195 | return status; |
2192 | } else { | 2196 | } else { |
2193 | /* stp is the lock stateid */ | 2197 | /* stp is the lock stateid */ |
2194 | status = nfs4_check_openmode(stp->st_openstp, lkflg); | 2198 | status = nfs4_check_openmode(stp->st_openstp, lkflg); |
2195 | if (status) | 2199 | if (status) |
2196 | return status; | 2200 | return status; |
2197 | } | 2201 | } |
2198 | |||
2199 | } | 2202 | } |
2200 | 2203 | ||
2201 | if ((flags & CHECK_FH) && nfs4_check_fh(current_fh, stp)) { | 2204 | if ((flags & CHECK_FH) && nfs4_check_fh(current_fh, stp)) { |
@@ -2561,7 +2564,7 @@ find_lockstateowner_str(struct inode *inode, clientid_t *clid, | |||
2561 | struct nfs4_stateowner *op; | 2564 | struct nfs4_stateowner *op; |
2562 | 2565 | ||
2563 | list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) { | 2566 | list_for_each_entry(op, &lock_ownerstr_hashtbl[hashval], so_strhash) { |
2564 | if (cmp_owner_str(op, owner, clid)) | 2567 | if (same_owner_str(op, owner, clid)) |
2565 | return op; | 2568 | return op; |
2566 | } | 2569 | } |
2567 | return NULL; | 2570 | return NULL; |
@@ -3025,7 +3028,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp, | |||
3025 | INIT_LIST_HEAD(&matches); | 3028 | INIT_LIST_HEAD(&matches); |
3026 | for (i = 0; i < LOCK_HASH_SIZE; i++) { | 3029 | for (i = 0; i < LOCK_HASH_SIZE; i++) { |
3027 | list_for_each_entry(sop, &lock_ownerid_hashtbl[i], so_idhash) { | 3030 | list_for_each_entry(sop, &lock_ownerid_hashtbl[i], so_idhash) { |
3028 | if (!cmp_owner_str(sop, owner, clid)) | 3031 | if (!same_owner_str(sop, owner, clid)) |
3029 | continue; | 3032 | continue; |
3030 | list_for_each_entry(stp, &sop->so_stateids, | 3033 | list_for_each_entry(stp, &sop->so_stateids, |
3031 | st_perstateowner) { | 3034 | st_perstateowner) { |