Skip to content

Commit 137e05e

Browse files
chuckleverJ. Bruce Fields
authored andcommitted
lockd: Update the NLMv1 SM_NOTIFY arguments decoder to use struct xdr_stream
Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 16ddcab commit 137e05e

File tree

1 file changed

+26
-13
lines changed

1 file changed

+26
-13
lines changed

fs/lockd/xdr.c

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,32 @@ nlmsvc_decode_res(struct svc_rqst *rqstp, __be32 *p)
313313
return 1;
314314
}
315315

316+
int
317+
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
318+
{
319+
struct xdr_stream *xdr = &rqstp->rq_arg_stream;
320+
struct nlm_reboot *argp = rqstp->rq_argp;
321+
u32 len;
322+
323+
if (xdr_stream_decode_u32(xdr, &len) < 0)
324+
return 0;
325+
if (len > SM_MAXSTRLEN)
326+
return 0;
327+
p = xdr_inline_decode(xdr, len);
328+
if (!p)
329+
return 0;
330+
argp->len = len;
331+
argp->mon = (char *)p;
332+
if (xdr_stream_decode_u32(xdr, &argp->state) < 0)
333+
return 0;
334+
p = xdr_inline_decode(xdr, SM_PRIV_SIZE);
335+
if (!p)
336+
return 0;
337+
memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
338+
339+
return 1;
340+
}
341+
316342
int
317343
nlmsvc_encode_testres(struct svc_rqst *rqstp, __be32 *p)
318344
{
@@ -380,19 +406,6 @@ nlmsvc_decode_notify(struct svc_rqst *rqstp, __be32 *p)
380406
return xdr_argsize_check(rqstp, p);
381407
}
382408

383-
int
384-
nlmsvc_decode_reboot(struct svc_rqst *rqstp, __be32 *p)
385-
{
386-
struct nlm_reboot *argp = rqstp->rq_argp;
387-
388-
if (!(p = xdr_decode_string_inplace(p, &argp->mon, &argp->len, SM_MAXSTRLEN)))
389-
return 0;
390-
argp->state = ntohl(*p++);
391-
memcpy(&argp->priv.data, p, sizeof(argp->priv.data));
392-
p += XDR_QUADLEN(SM_PRIV_SIZE);
393-
return xdr_argsize_check(rqstp, p);
394-
}
395-
396409
int
397410
nlmsvc_encode_void(struct svc_rqst *rqstp, __be32 *p)
398411
{

0 commit comments

Comments
 (0)