From 94c281d5e98921b7bfe5c9090f6355a30fffaa65 Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Tue, 12 May 2026 14:13:48 -0400 Subject: [PATCH] lockd: Use xdrgen XDR functions for the NLMv3 NULL procedure Hand-written XDR encoders and decoders are difficult to maintain and can diverge from protocol specifications. Migrating to xdrgen-generated code improves type safety and ensures the implementation matches the NLM version 3 protocol specification exactly. Convert the NULL procedure to use nlm_svc_decode_void and nlm_svc_encode_void, generated from Documentation/sunrpc/xdr/nlm3.x. NULL has no arguments or results, so it is the first procedure converted. NULL returns no XDR-encoded data, so pc_xdrressize is set to XDR_void. The argzero field is also set to zero since xdrgen decoders initialize all decoded values. Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever --- fs/lockd/svcproc.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index a79c9a46db60..ad37f3611eea 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -13,7 +13,16 @@ #include #include "lockd.h" + +/* + * xdr.h defines SM_PRIV_SIZE as a macro. nlm3xdr_gen.h defines + * it as an enum constant. Undefine the macro before including + * the generated header. + */ +#undef SM_PRIV_SIZE + #include "share.h" +#include "nlm3xdr_gen.h" #define NLMDBG_FACILITY NLMDBG_CLIENT @@ -120,13 +129,18 @@ nlmsvc_retrieve_args(struct svc_rqst *rqstp, struct lockd_args *argp, return nlm_lck_denied_nolocks; } -/* - * NULL: Test for presence of service +/** + * nlmsvc_proc_null - NULL: Test for presence of service + * @rqstp: RPC transaction context + * + * Return: + * %rpc_success: RPC executed successfully + * + * RPC synopsis: + * void NLM_NULL(void) = 0; */ -static __be32 -nlmsvc_proc_null(struct svc_rqst *rqstp) +static __be32 nlmsvc_proc_null(struct svc_rqst *rqstp) { - dprintk("lockd: NULL called\n"); return rpc_success; } @@ -568,15 +582,15 @@ struct nlm_void { int dummy; }; #define Rg 2 /* range - offset + size */ static const struct svc_procedure nlmsvc_procedures[24] = { - [NLMPROC_NULL] = { - .pc_func = nlmsvc_proc_null, - .pc_decode = nlmsvc_decode_void, - .pc_encode = nlmsvc_encode_void, - .pc_argsize = sizeof(struct nlm_void), - .pc_argzero = sizeof(struct nlm_void), - .pc_ressize = sizeof(struct nlm_void), - .pc_xdrressize = St, - .pc_name = "NULL", + [NLM_NULL] = { + .pc_func = nlmsvc_proc_null, + .pc_decode = nlm_svc_decode_void, + .pc_encode = nlm_svc_encode_void, + .pc_argsize = XDR_void, + .pc_argzero = 0, + .pc_ressize = 0, + .pc_xdrressize = XDR_void, + .pc_name = "NULL", }, [NLMPROC_TEST] = { .pc_func = nlmsvc_proc_test,