Skip to content

Commit d5497fc

Browse files
author
J. Bruce Fields
committed
nfsd4: move rq_flavor into svc_cred
Move the rq_flavor into struct svc_cred, and use it in setclientid and exchange_id comparisons as well. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
1 parent 8fbba96 commit d5497fc

8 files changed

Lines changed: 13 additions & 13 deletions

File tree

‎fs/nfsd/auth.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
1010
struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;
1111

1212
for (f = exp->ex_flavors; f < end; f++) {
13-
if (f->pseudoflavor == rqstp->rq_flavor)
13+
if (f->pseudoflavor == rqstp->rq_cred.cr_flavor)
1414
return f->flags;
1515
}
1616
return exp->ex_flags;

‎fs/nfsd/export.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -904,13 +904,13 @@ __be32 check_nfsd_access(struct svc_export *exp, struct svc_rqst *rqstp)
904904
return 0;
905905
/* ip-address based client; check sec= export option: */
906906
for (f = exp->ex_flavors; f < end; f++) {
907-
if (f->pseudoflavor == rqstp->rq_flavor)
907+
if (f->pseudoflavor == rqstp->rq_cred.cr_flavor)
908908
return 0;
909909
}
910910
/* defaults in absence of sec= options: */
911911
if (exp->ex_nflavors == 0) {
912-
if (rqstp->rq_flavor == RPC_AUTH_NULL ||
913-
rqstp->rq_flavor == RPC_AUTH_UNIX)
912+
if (rqstp->rq_cred.cr_flavor == RPC_AUTH_NULL ||
913+
rqstp->rq_cred.cr_flavor == RPC_AUTH_UNIX)
914914
return 0;
915915
}
916916
return nfserr_wrongsec;

‎fs/nfsd/nfs4idmap.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ numeric_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namel
605605
static __be32
606606
do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, uid_t *id)
607607
{
608-
if (nfs4_disable_idmapping && rqstp->rq_flavor < RPC_AUTH_GSS)
608+
if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
609609
if (numeric_name_to_id(rqstp, type, name, namelen, id))
610610
return 0;
611611
/*
@@ -618,7 +618,7 @@ do_name_to_id(struct svc_rqst *rqstp, int type, const char *name, u32 namelen, u
618618
static int
619619
do_id_to_name(struct svc_rqst *rqstp, int type, uid_t id, char *name)
620620
{
621-
if (nfs4_disable_idmapping && rqstp->rq_flavor < RPC_AUTH_GSS)
621+
if (nfs4_disable_idmapping && rqstp->rq_cred.cr_flavor < RPC_AUTH_GSS)
622622
return sprintf(name, "%u", id);
623623
return idmap_id_to_name(rqstp, type, id, name);
624624
}

‎fs/nfsd/nfs4state.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,7 @@ static int copy_cred(struct svc_cred *target, struct svc_cred *source)
11771177
return -ENOMEM;
11781178
} else
11791179
target->cr_principal = NULL;
1180+
target->cr_flavor = source->cr_flavor;
11801181
target->cr_uid = source->cr_uid;
11811182
target->cr_gid = source->cr_gid;
11821183
target->cr_group_info = source->cr_group_info;
@@ -1213,11 +1214,11 @@ static bool groups_equal(struct group_info *g1, struct group_info *g2)
12131214
return true;
12141215
}
12151216

1216-
/* XXX what about NGROUP */
12171217
static int
12181218
same_creds(struct svc_cred *cr1, struct svc_cred *cr2)
12191219
{
1220-
if ((cr1->cr_uid != cr2->cr_uid)
1220+
if ((cr1->cr_flavor != cr2->cr_flavor)
1221+
|| (cr1->cr_uid != cr2->cr_uid)
12211222
|| (cr1->cr_gid != cr2->cr_gid)
12221223
|| !groups_equal(cr1->cr_group_info, cr2->cr_group_info))
12231224
return false;
@@ -1299,7 +1300,6 @@ static struct nfs4_client *create_client(struct xdr_netobj name, char *recdir,
12991300
rpc_init_wait_queue(&clp->cl_cb_waitq, "Backchannel slot table");
13001301
copy_verf(clp, verf);
13011302
rpc_copy_addr((struct sockaddr *) &clp->cl_addr, sa);
1302-
clp->cl_flavor = rqstp->rq_flavor;
13031303
gen_confirm(clp);
13041304
clp->cl_cb_session = NULL;
13051305
return clp;

‎include/linux/sunrpc/svc.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ struct svc_rqst {
232232
struct svc_pool * rq_pool; /* thread pool */
233233
struct svc_procedure * rq_procinfo; /* procedure info */
234234
struct auth_ops * rq_authop; /* authentication flavour */
235-
u32 rq_flavor; /* pseudoflavor */
236235
struct svc_cred rq_cred; /* auth info */
237236
void * rq_xprt_ctxt; /* transport specific context ptr */
238237
struct svc_deferred_req*rq_deferred; /* deferred request we are replaying */

‎include/linux/sunrpc/svcauth.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct svc_cred {
2121
uid_t cr_uid;
2222
gid_t cr_gid;
2323
struct group_info *cr_group_info;
24+
u32 cr_flavor; /* pseudoflavor */
2425
char *cr_principal; /* for gss */
2526
};
2627

‎net/sunrpc/auth_gss/svcauth_gss.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1202,7 +1202,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp, __be32 *authp)
12021202
}
12031203
svcdata->rsci = rsci;
12041204
cache_get(&rsci->h);
1205-
rqstp->rq_flavor = gss_svc_to_pseudoflavor(
1205+
rqstp->rq_cred.cr_flavor = gss_svc_to_pseudoflavor(
12061206
rsci->mechctx->mech_type, gc->gc_svc);
12071207
ret = SVC_OK;
12081208
goto out;

‎net/sunrpc/svcauth_unix.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ svcauth_null_accept(struct svc_rqst *rqstp, __be32 *authp)
768768
svc_putnl(resv, RPC_AUTH_NULL);
769769
svc_putnl(resv, 0);
770770

771-
rqstp->rq_flavor = RPC_AUTH_NULL;
771+
rqstp->rq_cred.cr_flavor = RPC_AUTH_NULL;
772772
return SVC_OK;
773773
}
774774

@@ -839,7 +839,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp, __be32 *authp)
839839
svc_putnl(resv, RPC_AUTH_NULL);
840840
svc_putnl(resv, 0);
841841

842-
rqstp->rq_flavor = RPC_AUTH_UNIX;
842+
rqstp->rq_cred.cr_flavor = RPC_AUTH_UNIX;
843843
return SVC_OK;
844844

845845
badcred:

0 commit comments

Comments
 (0)