]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
lockd: Use xdrgen XDR functions for the NLMv3 NULL procedure
authorChuck Lever <chuck.lever@oracle.com>
Tue, 12 May 2026 18:13:48 +0000 (14:13 -0400)
committerChuck Lever <cel@kernel.org>
Tue, 9 Jun 2026 20:32:59 +0000 (16:32 -0400)
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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svcproc.c

index a79c9a46db600a5e0ebd77d184c4c79084cac552..ad37f3611eeae11aba9f4673324411fb96c12b8b 100644 (file)
 #include <linux/sunrpc/svc_xprt.h>
 
 #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 @@ no_locks:
        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,