@@ -4555,14 +4555,35 @@ nfsd4_encode_rename(struct nfsd4_compoundres *resp, __be32 nfserr,
4555
4555
return nfsd4_encode_change_info4 (xdr , & rename -> rn_tinfo );
4556
4556
}
4557
4557
4558
+ static __be32
4559
+ nfsd4_encode_rpcsec_gss_info (struct xdr_stream * xdr ,
4560
+ struct rpcsec_gss_info * info )
4561
+ {
4562
+ __be32 status ;
4563
+
4564
+ /* oid */
4565
+ if (xdr_stream_encode_opaque (xdr , info -> oid .data , info -> oid .len ) < 0 )
4566
+ return nfserr_resource ;
4567
+ /* qop */
4568
+ status = nfsd4_encode_qop4 (xdr , info -> qop );
4569
+ if (status != nfs_ok )
4570
+ return status ;
4571
+ /* service */
4572
+ if (xdr_stream_encode_u32 (xdr , info -> service ) != XDR_UNIT )
4573
+ return nfserr_resource ;
4574
+
4575
+ return nfs_ok ;
4576
+ }
4577
+
4558
4578
static __be32
4559
4579
nfsd4_do_encode_secinfo (struct xdr_stream * xdr , struct svc_export * exp )
4560
4580
{
4561
4581
u32 i , nflavs , supported ;
4562
4582
struct exp_flavor_info * flavs ;
4563
4583
struct exp_flavor_info def_flavs [2 ];
4564
- __be32 * p , * flavorsp ;
4565
4584
static bool report = true;
4585
+ __be32 * flavorsp ;
4586
+ __be32 status ;
4566
4587
4567
4588
if (exp -> ex_nflavors ) {
4568
4589
flavs = exp -> ex_flavors ;
@@ -4585,31 +4606,32 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp)
4585
4606
}
4586
4607
4587
4608
supported = 0 ;
4588
- p = xdr_reserve_space (xdr , 4 );
4589
- if (!p )
4609
+ flavorsp = xdr_reserve_space (xdr , XDR_UNIT );
4610
+ if (!flavorsp )
4590
4611
return nfserr_resource ;
4591
- flavorsp = p ++ ; /* to be backfilled later */
4592
4612
4593
4613
for (i = 0 ; i < nflavs ; i ++ ) {
4594
4614
rpc_authflavor_t pf = flavs [i ].pseudoflavor ;
4595
4615
struct rpcsec_gss_info info ;
4596
4616
4597
4617
if (rpcauth_get_gssinfo (pf , & info ) == 0 ) {
4598
4618
supported ++ ;
4599
- p = xdr_reserve_space (xdr , 4 + 4 +
4600
- XDR_LEN (info .oid .len ) + 4 + 4 );
4601
- if (!p )
4602
- return nfserr_resource ;
4603
- * p ++ = cpu_to_be32 (RPC_AUTH_GSS );
4604
- p = xdr_encode_opaque (p , info .oid .data , info .oid .len );
4605
- * p ++ = cpu_to_be32 (info .qop );
4606
- * p ++ = cpu_to_be32 (info .service );
4619
+
4620
+ /* flavor */
4621
+ status = nfsd4_encode_uint32_t (xdr , RPC_AUTH_GSS );
4622
+ if (status != nfs_ok )
4623
+ return status ;
4624
+ /* flavor_info */
4625
+ status = nfsd4_encode_rpcsec_gss_info (xdr , & info );
4626
+ if (status != nfs_ok )
4627
+ return status ;
4607
4628
} else if (pf < RPC_AUTH_MAXFLAVOR ) {
4608
4629
supported ++ ;
4609
- p = xdr_reserve_space (xdr , 4 );
4610
- if (!p )
4611
- return nfserr_resource ;
4612
- * p ++ = cpu_to_be32 (pf );
4630
+
4631
+ /* flavor */
4632
+ status = nfsd4_encode_uint32_t (xdr , pf );
4633
+ if (status != nfs_ok )
4634
+ return status ;
4613
4635
} else {
4614
4636
if (report )
4615
4637
pr_warn ("NFS: SECINFO: security flavor %u "
@@ -4619,7 +4641,7 @@ nfsd4_do_encode_secinfo(struct xdr_stream *xdr, struct svc_export *exp)
4619
4641
4620
4642
if (nflavs != supported )
4621
4643
report = false;
4622
- * flavorsp = htonl (supported );
4644
+ * flavorsp = cpu_to_be32 (supported );
4623
4645
return 0 ;
4624
4646
}
4625
4647
0 commit comments