SUNRPC: Move svcxdr_init_encode() into ->accept methods
authorChuck Lever <chuck.lever@oracle.com>
Sun, 8 Jan 2023 16:29:51 +0000 (11:29 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 20 Feb 2023 14:20:28 +0000 (09:20 -0500)
Refactor: So that the overhaul of each ->accept method can be done
in separate smaller patches, temporarily move the
svcxdr_init_encode() call into those methods.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/auth_gss/svcauth_gss.c
net/sunrpc/svc.c
net/sunrpc/svcauth_unix.c

index 6ef4f1e..5c41c34 100644 (file)
@@ -1250,6 +1250,7 @@ svcauth_gss_legacy_init(struct svc_rqst *rqstp,
                goto out;
 
        ret = SVC_COMPLETE;
+       svcxdr_init_encode(rqstp);
 out:
        cache_put(&rsip->h, sn->rsi_cache);
        return ret;
@@ -1378,6 +1379,7 @@ static int svcauth_gss_proxy_init(struct svc_rqst *rqstp,
                goto out;
 
        ret = SVC_COMPLETE;
+       svcxdr_init_encode(rqstp);
 out:
        gss_free_in_token_pages(&ud.in_token);
        gssp_free_upcall_data(&ud);
@@ -1680,6 +1682,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp)
                rqstp->rq_auth_stat = rpc_autherr_badcred;
                switch (gc->gc_svc) {
                case RPC_GSS_SVC_NONE:
+                       svcxdr_init_encode(rqstp);
                        break;
                case RPC_GSS_SVC_INTEGRITY:
                        /* placeholders for length and seq. number: */
@@ -1689,6 +1692,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp)
                                                     rsci->mechctx))
                                goto garbage_args;
                        rqstp->rq_auth_slack = RPC_MAX_AUTH_SIZE;
+                       svcxdr_init_encode(rqstp);
                        break;
                case RPC_GSS_SVC_PRIVACY:
                        /* placeholders for length and seq. number: */
@@ -1698,6 +1702,7 @@ svcauth_gss_accept(struct svc_rqst *rqstp)
                                                    rsci->mechctx))
                                goto garbage_args;
                        rqstp->rq_auth_slack = RPC_MAX_AUTH_SIZE * 2;
+                       svcxdr_init_encode(rqstp);
                        break;
                default:
                        goto auth_err;
index ce75db5..dc23fe4 100644 (file)
@@ -1312,16 +1312,14 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
        serv->sv_stats->rpccnt++;
        trace_svc_process(rqstp, progp->pg_name);
 
-       /* Build the reply header. */
-       statp = resv->iov_base +resv->iov_len;
-       svc_putnl(resv, RPC_SUCCESS);
+       statp = xdr_reserve_space(&rqstp->rq_res_stream, XDR_UNIT);
+       *statp = rpc_success;
 
        /* un-reserve some of the out-queue now that we have a
         * better idea of reply size
         */
        if (procp->pc_xdrressize)
                svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
-       svcxdr_init_encode(rqstp);
 
        /* Call the function that processes the request. */
        rc = process.dispatch(rqstp, statp);
index f09a148..6281d23 100644 (file)
@@ -778,6 +778,7 @@ svcauth_null_accept(struct svc_rqst *rqstp)
        svc_putnl(resv, 0);
 
        rqstp->rq_cred.cr_flavor = RPC_AUTH_NULL;
+       svcxdr_init_encode(rqstp);
        return SVC_OK;
 }
 
@@ -865,6 +866,7 @@ svcauth_tls_accept(struct svc_rqst *rqstp)
                svc_putnl(resv, 0);
 
        rqstp->rq_cred.cr_flavor = RPC_AUTH_TLS;
+       svcxdr_init_encode(rqstp);
        return SVC_OK;
 }
 
@@ -960,6 +962,7 @@ svcauth_unix_accept(struct svc_rqst *rqstp)
        svc_putnl(resv, 0);
 
        rqstp->rq_cred.cr_flavor = RPC_AUTH_UNIX;
+       svcxdr_init_encode(rqstp);
        return SVC_OK;
 
 badcred: