@@ -1227,13 +1227,14 @@ EXPORT_SYMBOL_GPL(svc_generic_init_request);
1227
1227
static int
1228
1228
svc_process_common (struct svc_rqst * rqstp , struct kvec * resv )
1229
1229
{
1230
+ struct xdr_stream * xdr = & rqstp -> rq_res_stream ;
1230
1231
struct svc_program * progp ;
1231
1232
const struct svc_procedure * procp = NULL ;
1232
1233
struct svc_serv * serv = rqstp -> rq_server ;
1233
1234
struct svc_process_info process ;
1234
1235
__be32 * p , * statp ;
1235
1236
int auth_res , rc ;
1236
- __be32 * reply_statp ;
1237
+ unsigned int aoffset ;
1237
1238
1238
1239
/* Will be turned off by GSS integrity and privacy services */
1239
1240
set_bit (RQ_SPLICE_OK , & rqstp -> rq_flags );
@@ -1242,17 +1243,17 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
1242
1243
clear_bit (RQ_DROPME , & rqstp -> rq_flags );
1243
1244
1244
1245
/* Construct the first words of the reply: */
1245
- svc_putu32 ( resv , rqstp -> rq_xid );
1246
- svc_putnl ( resv , RPC_REPLY );
1247
- reply_statp = resv -> iov_base + resv -> iov_len ;
1246
+ svcxdr_init_encode ( rqstp );
1247
+ xdr_stream_encode_be32 ( xdr , rqstp -> rq_xid );
1248
+ xdr_stream_encode_be32 ( xdr , rpc_reply ) ;
1248
1249
1249
1250
p = xdr_inline_decode (& rqstp -> rq_arg_stream , XDR_UNIT * 4 );
1250
1251
if (unlikely (!p ))
1251
1252
goto err_short_len ;
1252
1253
if (* p ++ != cpu_to_be32 (RPC_VERSION ))
1253
1254
goto err_bad_rpc ;
1254
1255
1255
- svc_putnl ( resv , 0 ); /* ACCEPT */
1256
+ xdr_stream_encode_be32 ( xdr , rpc_msg_accepted );
1256
1257
1257
1258
rqstp -> rq_prog = be32_to_cpup (p ++ );
1258
1259
rqstp -> rq_vers = be32_to_cpup (p ++ );
@@ -1262,8 +1263,6 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
1262
1263
if (rqstp -> rq_prog == progp -> pg_prog )
1263
1264
break ;
1264
1265
1265
- svcxdr_init_encode (rqstp );
1266
-
1267
1266
/*
1268
1267
* Decode auth data, and add verifier to reply buffer.
1269
1268
* We do this before anything else in order to get a decent
@@ -1314,6 +1313,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
1314
1313
serv -> sv_stats -> rpccnt ++ ;
1315
1314
trace_svc_process (rqstp , progp -> pg_name );
1316
1315
1316
+ aoffset = xdr_stream_pos (xdr );
1317
1317
statp = xdr_reserve_space (& rqstp -> rq_res_stream , XDR_UNIT );
1318
1318
* statp = rpc_success ;
1319
1319
@@ -1332,9 +1332,8 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
1332
1332
if (rqstp -> rq_auth_stat != rpc_auth_ok )
1333
1333
goto err_bad_auth ;
1334
1334
1335
- /* Check RPC status result */
1336
1335
if (* statp != rpc_success )
1337
- resv -> iov_len = (( void * ) statp ) - resv -> iov_base + 4 ;
1336
+ xdr_truncate_encode ( xdr , aoffset ) ;
1338
1337
1339
1338
if (procp -> pc_encode == NULL )
1340
1339
goto dropit ;
@@ -1364,56 +1363,57 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *resv)
1364
1363
1365
1364
err_bad_rpc :
1366
1365
serv -> sv_stats -> rpcbadfmt ++ ;
1367
- svc_putnl (resv , 1 ); /* REJECT */
1368
- svc_putnl (resv , 0 ); /* RPC_MISMATCH */
1369
- svc_putnl (resv , 2 ); /* Only RPCv2 supported */
1370
- svc_putnl (resv , 2 );
1366
+ xdr_stream_encode_u32 (xdr , RPC_MSG_DENIED );
1367
+ xdr_stream_encode_u32 (xdr , RPC_MISMATCH );
1368
+ /* Only RPCv2 supported */
1369
+ xdr_stream_encode_u32 (xdr , RPC_VERSION );
1370
+ xdr_stream_encode_u32 (xdr , RPC_VERSION );
1371
1371
goto sendit ;
1372
1372
1373
1373
err_bad_auth :
1374
1374
dprintk ("svc: authentication failed (%d)\n" ,
1375
1375
be32_to_cpu (rqstp -> rq_auth_stat ));
1376
1376
serv -> sv_stats -> rpcbadauth ++ ;
1377
- /* Restore write pointer to location of accept status: */
1378
- xdr_ressize_check ( rqstp , reply_statp );
1379
- svc_putnl ( resv , 1 ); /* REJECT */
1380
- svc_putnl ( resv , 1 ); /* AUTH_ERROR */
1381
- svc_putu32 ( resv , rqstp -> rq_auth_stat ); /* status */
1377
+ /* Restore write pointer to location of reply status: */
1378
+ xdr_truncate_encode ( xdr , XDR_UNIT * 2 );
1379
+ xdr_stream_encode_u32 ( xdr , RPC_MSG_DENIED );
1380
+ xdr_stream_encode_u32 ( xdr , RPC_AUTH_ERROR );
1381
+ xdr_stream_encode_be32 ( xdr , rqstp -> rq_auth_stat );
1382
1382
goto sendit ;
1383
1383
1384
1384
err_bad_prog :
1385
1385
dprintk ("svc: unknown program %d\n" , rqstp -> rq_prog );
1386
1386
serv -> sv_stats -> rpcbadfmt ++ ;
1387
- svc_putnl ( resv , RPC_PROG_UNAVAIL );
1387
+ xdr_stream_encode_u32 ( xdr , RPC_PROG_UNAVAIL );
1388
1388
goto sendit ;
1389
1389
1390
1390
err_bad_vers :
1391
1391
svc_printk (rqstp , "unknown version (%d for prog %d, %s)\n" ,
1392
1392
rqstp -> rq_vers , rqstp -> rq_prog , progp -> pg_name );
1393
1393
1394
1394
serv -> sv_stats -> rpcbadfmt ++ ;
1395
- svc_putnl ( resv , RPC_PROG_MISMATCH );
1396
- svc_putnl ( resv , process .mismatch .lovers );
1397
- svc_putnl ( resv , process .mismatch .hivers );
1395
+ xdr_stream_encode_u32 ( xdr , RPC_PROG_MISMATCH );
1396
+ xdr_stream_encode_u32 ( xdr , process .mismatch .lovers );
1397
+ xdr_stream_encode_u32 ( xdr , process .mismatch .hivers );
1398
1398
goto sendit ;
1399
1399
1400
1400
err_bad_proc :
1401
1401
svc_printk (rqstp , "unknown procedure (%d)\n" , rqstp -> rq_proc );
1402
1402
1403
1403
serv -> sv_stats -> rpcbadfmt ++ ;
1404
- svc_putnl ( resv , RPC_PROC_UNAVAIL );
1404
+ xdr_stream_encode_u32 ( xdr , RPC_PROC_UNAVAIL );
1405
1405
goto sendit ;
1406
1406
1407
1407
err_garbage_args :
1408
1408
svc_printk (rqstp , "failed to decode RPC header\n" );
1409
1409
1410
1410
serv -> sv_stats -> rpcbadfmt ++ ;
1411
- svc_putnl ( resv , RPC_GARBAGE_ARGS );
1411
+ xdr_stream_encode_u32 ( xdr , RPC_GARBAGE_ARGS );
1412
1412
goto sendit ;
1413
1413
1414
1414
err_system_err :
1415
1415
serv -> sv_stats -> rpcbadfmt ++ ;
1416
- svc_putnl ( resv , RPC_SYSTEM_ERR );
1416
+ xdr_stream_encode_u32 ( xdr , RPC_SYSTEM_ERR );
1417
1417
goto sendit ;
1418
1418
}
1419
1419
0 commit comments