@@ -2575,6 +2575,19 @@ nfsd4_encode_change_info4(struct xdr_stream *xdr, const struct nfsd4_change_info
2575
2575
return nfsd4_encode_changeid4 (xdr , c -> after_change );
2576
2576
}
2577
2577
2578
+ static __be32 nfsd4_encode_netaddr4 (struct xdr_stream * xdr ,
2579
+ const struct nfs42_netaddr * addr )
2580
+ {
2581
+ __be32 status ;
2582
+
2583
+ /* na_r_netid */
2584
+ status = nfsd4_encode_opaque (xdr , addr -> netid , addr -> netid_len );
2585
+ if (status != nfs_ok )
2586
+ return status ;
2587
+ /* na_r_addr */
2588
+ return nfsd4_encode_opaque (xdr , addr -> addr , addr -> addr_len );
2589
+ }
2590
+
2578
2591
/* Encode as an array of strings the string given with components
2579
2592
* separated @sep, escaped with esc_enter and esc_exit.
2580
2593
*/
@@ -5132,43 +5145,42 @@ nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr,
5132
5145
}
5133
5146
5134
5147
static __be32
5135
- nfsd42_encode_nl4_server (struct nfsd4_compoundres * resp , struct nl4_server * ns )
5148
+ nfsd4_encode_netloc4 (struct xdr_stream * xdr , const struct nl4_server * ns )
5136
5149
{
5137
- struct xdr_stream * xdr = resp -> xdr ;
5138
- struct nfs42_netaddr * addr ;
5139
- __be32 * p ;
5140
-
5141
- p = xdr_reserve_space (xdr , 4 );
5142
- * p ++ = cpu_to_be32 (ns -> nl4_type );
5150
+ __be32 status ;
5143
5151
5152
+ if (xdr_stream_encode_u32 (xdr , ns -> nl4_type ) != XDR_UNIT )
5153
+ return nfserr_resource ;
5144
5154
switch (ns -> nl4_type ) {
5145
5155
case NL4_NETADDR :
5146
- addr = & ns -> u .nl4_addr ;
5147
-
5148
- /* netid_len, netid, uaddr_len, uaddr (port included
5149
- * in RPCBIND_MAXUADDRLEN)
5150
- */
5151
- p = xdr_reserve_space (xdr ,
5152
- 4 /* netid len */ +
5153
- (XDR_QUADLEN (addr -> netid_len ) * 4 ) +
5154
- 4 /* uaddr len */ +
5155
- (XDR_QUADLEN (addr -> addr_len ) * 4 ));
5156
- if (!p )
5157
- return nfserr_resource ;
5158
-
5159
- * p ++ = cpu_to_be32 (addr -> netid_len );
5160
- p = xdr_encode_opaque_fixed (p , addr -> netid ,
5161
- addr -> netid_len );
5162
- * p ++ = cpu_to_be32 (addr -> addr_len );
5163
- p = xdr_encode_opaque_fixed (p , addr -> addr ,
5164
- addr -> addr_len );
5156
+ /* nl_addr */
5157
+ status = nfsd4_encode_netaddr4 (xdr , & ns -> u .nl4_addr );
5165
5158
break ;
5166
5159
default :
5167
- WARN_ON_ONCE (ns -> nl4_type != NL4_NETADDR );
5168
- return nfserr_inval ;
5160
+ status = nfserr_serverfault ;
5169
5161
}
5162
+ return status ;
5163
+ }
5170
5164
5171
- return 0 ;
5165
+ static __be32
5166
+ nfsd4_encode_copy_notify (struct nfsd4_compoundres * resp , __be32 nfserr ,
5167
+ union nfsd4_op_u * u )
5168
+ {
5169
+ struct nfsd4_copy_notify * cn = & u -> copy_notify ;
5170
+ struct xdr_stream * xdr = resp -> xdr ;
5171
+
5172
+ /* cnr_lease_time */
5173
+ nfserr = nfsd4_encode_nfstime4 (xdr , & cn -> cpn_lease_time );
5174
+ if (nfserr )
5175
+ return nfserr ;
5176
+ /* cnr_stateid */
5177
+ nfserr = nfsd4_encode_stateid4 (xdr , & cn -> cpn_cnr_stateid );
5178
+ if (nfserr )
5179
+ return nfserr ;
5180
+ /* cnr_source_server<> */
5181
+ if (xdr_stream_encode_u32 (xdr , 1 ) != XDR_UNIT )
5182
+ return nfserr_resource ;
5183
+ return nfsd4_encode_netloc4 (xdr , cn -> cpn_src );
5172
5184
}
5173
5185
5174
5186
static __be32
@@ -5261,42 +5273,6 @@ nfsd4_encode_read_plus(struct nfsd4_compoundres *resp, __be32 nfserr,
5261
5273
return nfserr ;
5262
5274
}
5263
5275
5264
- static __be32
5265
- nfsd4_encode_copy_notify (struct nfsd4_compoundres * resp , __be32 nfserr ,
5266
- union nfsd4_op_u * u )
5267
- {
5268
- struct nfsd4_copy_notify * cn = & u -> copy_notify ;
5269
- struct xdr_stream * xdr = resp -> xdr ;
5270
- __be32 * p ;
5271
-
5272
- if (nfserr )
5273
- return nfserr ;
5274
-
5275
- /* 8 sec, 4 nsec */
5276
- p = xdr_reserve_space (xdr , 12 );
5277
- if (!p )
5278
- return nfserr_resource ;
5279
-
5280
- /* cnr_lease_time */
5281
- p = xdr_encode_hyper (p , cn -> cpn_sec );
5282
- * p ++ = cpu_to_be32 (cn -> cpn_nsec );
5283
-
5284
- /* cnr_stateid */
5285
- nfserr = nfsd4_encode_stateid4 (xdr , & cn -> cpn_cnr_stateid );
5286
- if (nfserr )
5287
- return nfserr ;
5288
-
5289
- /* cnr_src.nl_nsvr */
5290
- p = xdr_reserve_space (xdr , 4 );
5291
- if (!p )
5292
- return nfserr_resource ;
5293
-
5294
- * p ++ = cpu_to_be32 (1 );
5295
-
5296
- nfserr = nfsd42_encode_nl4_server (resp , cn -> cpn_src );
5297
- return nfserr ;
5298
- }
5299
-
5300
5276
static __be32
5301
5277
nfsd4_encode_seek (struct nfsd4_compoundres * resp , __be32 nfserr ,
5302
5278
union nfsd4_op_u * u )
0 commit comments