Skip to content

Commit cee4db1

Browse files
committed
SUNRPC: Refactor RPC server dispatch method
Currently, svcauth_gss_accept() pre-reserves response buffer space for the RPC payload length and GSS sequence number before returning to the dispatcher, which then adds the header's accept_stat field. The problem is the accept_stat field is supposed to go before the length and seq_num fields. So svcauth_gss_release() has to relocate the accept_stat value (see svcauth_gss_prepare_to_wrap()). To enable these fields to be added to the response buffer in the correct (final) order, the pointer to the accept_stat has to be made available to svcauth_gss_accept() so that it can set it before reserving space for the length and seq_num fields. As a first step, move the pointer to the location of the accept_stat field into struct svc_rqst. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 5df2567 commit cee4db1

File tree

7 files changed

+16
-15
lines changed

7 files changed

+16
-15
lines changed

fs/lockd/svc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,15 +685,15 @@ module_exit(exit_nlm);
685685
/**
686686
* nlmsvc_dispatch - Process an NLM Request
687687
* @rqstp: incoming request
688-
* @statp: pointer to location of accept_stat field in RPC Reply buffer
689688
*
690689
* Return values:
691690
* %0: Processing complete; do not send a Reply
692691
* %1: Processing complete; send Reply in rqstp->rq_res
693692
*/
694-
static int nlmsvc_dispatch(struct svc_rqst *rqstp, __be32 *statp)
693+
static int nlmsvc_dispatch(struct svc_rqst *rqstp)
695694
{
696695
const struct svc_procedure *procp = rqstp->rq_procinfo;
696+
__be32 *statp = rqstp->rq_accept_statp;
697697

698698
if (!procp->pc_decode(rqstp, &rqstp->rq_arg_stream))
699699
goto out_decode_err;

fs/nfs/callback_xdr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,11 +980,11 @@ static __be32 nfs4_callback_compound(struct svc_rqst *rqstp)
980980
}
981981

982982
static int
983-
nfs_callback_dispatch(struct svc_rqst *rqstp, __be32 *statp)
983+
nfs_callback_dispatch(struct svc_rqst *rqstp)
984984
{
985985
const struct svc_procedure *procp = rqstp->rq_procinfo;
986986

987-
*statp = procp->pc_func(rqstp);
987+
*rqstp->rq_accept_statp = procp->pc_func(rqstp);
988988
return 1;
989989
}
990990

fs/nfsd/nfscache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ int nfsd_cache_lookup(struct svc_rqst *rqstp)
509509
* nfsd_cache_update - Update an entry in the duplicate reply cache.
510510
* @rqstp: svc_rqst with a finished Reply
511511
* @cachetype: which cache to update
512-
* @statp: Reply's status code
512+
* @statp: pointer to Reply's NFS status code, or NULL
513513
*
514514
* This is called from nfsd_dispatch when the procedure has been
515515
* executed and the complete reply is in rqstp->rq_res.

fs/nfsd/nfsd.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ bool nfssvc_encode_voidres(struct svc_rqst *rqstp,
8686
* Function prototypes.
8787
*/
8888
int nfsd_svc(int nrservs, struct net *net, const struct cred *cred);
89-
int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp);
89+
int nfsd_dispatch(struct svc_rqst *rqstp);
9090

9191
int nfsd_nrthreads(struct net *);
9292
int nfsd_nrpools(struct net *);

fs/nfsd/nfssvc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,17 +1022,17 @@ nfsd(void *vrqstp)
10221022
/**
10231023
* nfsd_dispatch - Process an NFS or NFSACL Request
10241024
* @rqstp: incoming request
1025-
* @statp: pointer to location of accept_stat field in RPC Reply buffer
10261025
*
10271026
* This RPC dispatcher integrates the NFS server's duplicate reply cache.
10281027
*
10291028
* Return values:
10301029
* %0: Processing complete; do not send a Reply
10311030
* %1: Processing complete; send Reply in rqstp->rq_res
10321031
*/
1033-
int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp)
1032+
int nfsd_dispatch(struct svc_rqst *rqstp)
10341033
{
10351034
const struct svc_procedure *proc = rqstp->rq_procinfo;
1035+
__be32 *statp = rqstp->rq_accept_statp;
10361036

10371037
/*
10381038
* Give the xdr decoder a chance to change this if it wants

include/linux/sunrpc/svc.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ struct svc_rqst {
251251

252252
void * rq_argp; /* decoded arguments */
253253
void * rq_resp; /* xdr'd results */
254+
__be32 *rq_accept_statp;
254255
void * rq_auth_data; /* flavor-specific data */
255256
__be32 rq_auth_stat; /* authentication status */
256257
int rq_auth_slack; /* extra space xdr code
@@ -337,7 +338,7 @@ struct svc_deferred_req {
337338

338339
struct svc_process_info {
339340
union {
340-
int (*dispatch)(struct svc_rqst *, __be32 *);
341+
int (*dispatch)(struct svc_rqst *rqstp);
341342
struct {
342343
unsigned int lovers;
343344
unsigned int hivers;
@@ -389,7 +390,7 @@ struct svc_version {
389390
bool vs_need_cong_ctrl;
390391

391392
/* Dispatch function */
392-
int (*vs_dispatch)(struct svc_rqst *, __be32 *);
393+
int (*vs_dispatch)(struct svc_rqst *rqstp);
393394
};
394395

395396
/*

net/sunrpc/svc.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,9 +1232,9 @@ svc_process_common(struct svc_rqst *rqstp)
12321232
const struct svc_procedure *procp = NULL;
12331233
struct svc_serv *serv = rqstp->rq_server;
12341234
struct svc_process_info process;
1235-
__be32 *p, *statp;
12361235
int auth_res, rc;
12371236
unsigned int aoffset;
1237+
__be32 *p;
12381238

12391239
/* Will be turned off by GSS integrity and privacy services */
12401240
set_bit(RQ_SPLICE_OK, &rqstp->rq_flags);
@@ -1314,8 +1314,8 @@ svc_process_common(struct svc_rqst *rqstp)
13141314
trace_svc_process(rqstp, progp->pg_name);
13151315

13161316
aoffset = xdr_stream_pos(xdr);
1317-
statp = xdr_reserve_space(&rqstp->rq_res_stream, XDR_UNIT);
1318-
*statp = rpc_success;
1317+
rqstp->rq_accept_statp = xdr_reserve_space(&rqstp->rq_res_stream, XDR_UNIT);
1318+
*rqstp->rq_accept_statp = rpc_success;
13191319

13201320
/* un-reserve some of the out-queue now that we have a
13211321
* better idea of reply size
@@ -1324,15 +1324,15 @@ svc_process_common(struct svc_rqst *rqstp)
13241324
svc_reserve_auth(rqstp, procp->pc_xdrressize<<2);
13251325

13261326
/* Call the function that processes the request. */
1327-
rc = process.dispatch(rqstp, statp);
1327+
rc = process.dispatch(rqstp);
13281328
if (procp->pc_release)
13291329
procp->pc_release(rqstp);
13301330
if (!rc)
13311331
goto dropit;
13321332
if (rqstp->rq_auth_stat != rpc_auth_ok)
13331333
goto err_bad_auth;
13341334

1335-
if (*statp != rpc_success)
1335+
if (*rqstp->rq_accept_statp != rpc_success)
13361336
xdr_truncate_encode(xdr, aoffset);
13371337

13381338
if (procp->pc_encode == NULL)

0 commit comments

Comments
 (0)