Skip to content

Commit 825562b

Browse files
committed
NFSD: Refactor nfsd4_do_encode_secinfo() again
Extract the code that encodes the secinfo4 union data type to clarify the logic. The removed warning is pretty well obscured and thus probably not terribly useful. Reviewed-by: NeilBrown <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 201cb20 commit 825562b

File tree

1 file changed

+34
-31
lines changed

1 file changed

+34
-31
lines changed

fs/nfsd/nfs4xdr.c

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4613,13 +4613,41 @@ nfsd4_encode_rpcsec_gss_info(struct xdr_stream *xdr,
46134613
return nfs_ok;
46144614
}
46154615

4616+
static __be32
4617+
nfsd4_encode_secinfo4(struct xdr_stream *xdr, rpc_authflavor_t pf,
4618+
u32 *supported)
4619+
{
4620+
struct rpcsec_gss_info info;
4621+
__be32 status;
4622+
4623+
if (rpcauth_get_gssinfo(pf, &info) == 0) {
4624+
(*supported)++;
4625+
4626+
/* flavor */
4627+
status = nfsd4_encode_uint32_t(xdr, RPC_AUTH_GSS);
4628+
if (status != nfs_ok)
4629+
return status;
4630+
/* flavor_info */
4631+
status = nfsd4_encode_rpcsec_gss_info(xdr, &info);
4632+
if (status != nfs_ok)
4633+
return status;
4634+
} else if (pf < RPC_AUTH_MAXFLAVOR) {
4635+
(*supported)++;
4636+
4637+
/* flavor */
4638+
status = nfsd4_encode_uint32_t(xdr, pf);
4639+
if (status != nfs_ok)
4640+
return status;
4641+
}
4642+
return nfs_ok;
4643+
}
4644+
46164645
static __be32
46174646
nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp)
46184647
{
46194648
u32 i, nflavs, supported;
46204649
struct exp_flavor_info *flavs;
46214650
struct exp_flavor_info def_flavs[2];
4622-
static bool report = true;
46234651
__be32 *flavorsp;
46244652
__be32 status;
46254653

@@ -4643,42 +4671,17 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp)
46434671
}
46444672
}
46454673

4646-
supported = 0;
46474674
flavorsp = xdr_reserve_space(xdr, XDR_UNIT);
46484675
if (!flavorsp)
46494676
return nfserr_resource;
46504677

4651-
for (i = 0; i < nflavs; i++) {
4652-
rpc_authflavor_t pf = flavs[i].pseudoflavor;
4653-
struct rpcsec_gss_info info;
4654-
4655-
if (rpcauth_get_gssinfo(pf, &info) == 0) {
4656-
supported++;
4657-
4658-
/* flavor */
4659-
status = nfsd4_encode_uint32_t(xdr, RPC_AUTH_GSS);
4660-
if (status != nfs_ok)
4661-
return status;
4662-
/* flavor_info */
4663-
status = nfsd4_encode_rpcsec_gss_info(xdr, &info);
4664-
if (status != nfs_ok)
4665-
return status;
4666-
} else if (pf < RPC_AUTH_MAXFLAVOR) {
4667-
supported++;
4668-
4669-
/* flavor */
4670-
status = nfsd4_encode_uint32_t(xdr, pf);
4671-
if (status != nfs_ok)
4672-
return status;
4673-
} else {
4674-
if (report)
4675-
pr_warn("NFS: SECINFO: security flavor %u "
4676-
"is not supported\n", pf);
4677-
}
4678+
for (i = 0, supported = 0; i < nflavs; i++) {
4679+
status = nfsd4_encode_secinfo4(xdr, flavs[i].pseudoflavor,
4680+
&supported);
4681+
if (status != nfs_ok)
4682+
return status;
46784683
}
46794684

4680-
if (nflavs != supported)
4681-
report = false;
46824685
*flavorsp = cpu_to_be32(supported);
46834686
return 0;
46844687
}

0 commit comments

Comments
 (0)