Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <neilb@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>

+34 -31
+34 -31
fs/nfsd/nfs4xdr.c
··· 4614 4614 } 4615 4615 4616 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 + 4645 + static __be32 4617 4646 nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp) 4618 4647 { 4619 4648 u32 i, nflavs, supported; 4620 4649 struct exp_flavor_info *flavs; 4621 4650 struct exp_flavor_info def_flavs[2]; 4622 - static bool report = true; 4623 4651 __be32 *flavorsp; 4624 4652 __be32 status; 4625 4653 ··· 4671 4643 } 4672 4644 } 4673 4645 4674 - supported = 0; 4675 4646 flavorsp = xdr_reserve_space(xdr, XDR_UNIT); 4676 4647 if (!flavorsp) 4677 4648 return nfserr_resource; 4678 4649 4679 - for (i = 0; i < nflavs; i++) { 4680 - rpc_authflavor_t pf = flavs[i].pseudoflavor; 4681 - struct rpcsec_gss_info info; 4682 - 4683 - if (rpcauth_get_gssinfo(pf, &info) == 0) { 4684 - supported++; 4685 - 4686 - /* flavor */ 4687 - status = nfsd4_encode_uint32_t(xdr, RPC_AUTH_GSS); 4688 - if (status != nfs_ok) 4689 - return status; 4690 - /* flavor_info */ 4691 - status = nfsd4_encode_rpcsec_gss_info(xdr, &info); 4692 - if (status != nfs_ok) 4693 - return status; 4694 - } else if (pf < RPC_AUTH_MAXFLAVOR) { 4695 - supported++; 4696 - 4697 - /* flavor */ 4698 - status = nfsd4_encode_uint32_t(xdr, pf); 4699 - if (status != nfs_ok) 4700 - return status; 4701 - } else { 4702 - if (report) 4703 - pr_warn("NFS: SECINFO: security flavor %u " 4704 - "is not supported\n", pf); 4705 - } 4650 + for (i = 0, supported = 0; i < nflavs; i++) { 4651 + status = nfsd4_encode_secinfo4(xdr, flavs[i].pseudoflavor, 4652 + &supported); 4653 + if (status != nfs_ok) 4654 + return status; 4706 4655 } 4707 4656 4708 - if (nflavs != supported) 4709 - report = false; 4710 4657 *flavorsp = cpu_to_be32(supported); 4711 4658 return 0; 4712 4659 }