diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2023-01-02 12:07:20 -0500 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2023-02-20 09:20:17 -0500 |
commit | 6734706bc0b834c334aed2551ad046bf5b6a50d4 (patch) | |
tree | 69998cd6ffb715f395230cd577e83ce452787754 | |
parent | 0653028e8f1c97fec30710813a001ad8a2ec34f4 (diff) |
SUNRPC: Clean up svcauth_gss_accept's NULL procedure check
Micro-optimizations:
1. The value of rqstp->rq_auth_stat is replaced no matter which
arm of the switch is taken, so the initial assignment can be
safely removed.
2. Avoid checking the value of gc->gc_proc twice in the I/O
(RPC_GSS_PROC_DATA) path.
The cost is a little extra code redundancy.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
-rw-r--r-- | net/sunrpc/auth_gss/svcauth_gss.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index ecd38d2bbf7a..76d2e4e04d59 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -1608,17 +1608,19 @@ svcauth_gss_accept(struct svc_rqst *rqstp) if (crlen != round_up_to_quad(gc->gc_ctx.len) + 5 * 4) goto auth_err; - if ((gc->gc_proc != RPC_GSS_PROC_DATA) && (rqstp->rq_proc != 0)) - goto auth_err; - svcxdr_init_decode(rqstp); - rqstp->rq_auth_stat = rpc_autherr_badverf; + switch (gc->gc_proc) { case RPC_GSS_PROC_INIT: case RPC_GSS_PROC_CONTINUE_INIT: + if (rqstp->rq_proc != 0) + goto auth_err; return svcauth_gss_proc_init(rqstp, gc); - case RPC_GSS_PROC_DATA: case RPC_GSS_PROC_DESTROY: + if (rqstp->rq_proc != 0) + goto auth_err; + fallthrough; + case RPC_GSS_PROC_DATA: /* Look up the context, and check the verifier: */ rqstp->rq_auth_stat = rpcsec_gsserr_credproblem; rsci = gss_svc_searchbyctx(sn->rsc_cache, &gc->gc_ctx); @@ -1634,6 +1636,8 @@ svcauth_gss_accept(struct svc_rqst *rqstp) } break; default: + if (rqstp->rq_proc != 0) + goto auth_err; rqstp->rq_auth_stat = rpc_autherr_rejectedcred; goto auth_err; } |