]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
lockd: Use xdrgen XDR functions for the NLMv4 NULL procedure
authorChuck Lever <chuck.lever@oracle.com>
Tue, 17 Feb 2026 22:06:54 +0000 (17:06 -0500)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 30 Mar 2026 01:25:09 +0000 (21:25 -0400)
Hand-written XDR encoders and decoders are difficult to maintain
and can inadvertently diverge from protocol specifications. By
migrating to xdrgen-generated code, we improve type safety and
ensure the implementation exactly matches the NLM version 4
protocol specification.

This patch begins the migration by converting the NULL procedure
to use nlm4_svc_decode_void and nlm4_svc_encode_void generated
from Documentation/sunrpc/xdr/nlm4.x. The NULL procedure is
straightforward as it has no arguments or results, making it an
ideal starting point for this series.

The pc_xdrressize field is set to XDR_void (zero) to reflect
that this procedure returns no XDR-encoded data. The argzero
field is also set to zero since xdrgen decoders reliably
initialize all decoded values.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/lockd/svc4proc.c

index c99f192bce77c3d6300fb99aa66fde114c568acd..4fcd66beb4dfc7b943e9bf76455a83de8a61ed86 100644 (file)
 #include <linux/sunrpc/svc_xprt.h>
 
 #include "lockd.h"
+
+/*
+ * xdr.h defines SM_MAXSTRLEN and SM_PRIV_SIZE as macros.
+ * nlm4xdr_gen.h defines them as enum constants. Undefine the
+ * macros to allow the xdrgen enum definitions to be used.
+ */
+#undef SM_MAXSTRLEN
+#undef SM_PRIV_SIZE
+
 #include "share.h"
+#include "nlm4xdr_gen.h"
 #include "xdr4.h"
 
 #define NLMDBG_FACILITY                NLMDBG_CLIENT
@@ -92,13 +102,19 @@ no_locks:
        }
 }
 
-/*
- * NULL: Test for presence of service
+/**
+ * nlm4svc_proc_null - NULL: Test for presence of service
+ * @rqstp: RPC transaction context
+ *
+ * Returns:
+ *   %rpc_success:             RPC executed successfully
+ *
+ * RPC synopsis:
+ *   void NLMPROC4_NULL(void) = 0;
  */
 static __be32
 nlm4svc_proc_null(struct svc_rqst *rqstp)
 {
-       dprintk("lockd: NULL          called\n");
        return rpc_success;
 }
 
@@ -531,15 +547,15 @@ struct nlm_void                   { int dummy; };
 #define        Rg      4                                       /* range (offset + length) */
 
 static const struct svc_procedure nlm4svc_procedures[24] = {
-       [NLMPROC_NULL] = {
-               .pc_func = nlm4svc_proc_null,
-               .pc_decode = nlm4svc_decode_void,
-               .pc_encode = nlm4svc_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",
+       [NLMPROC4_NULL] = {
+               .pc_func        = nlm4svc_proc_null,
+               .pc_decode      = nlm4_svc_decode_void,
+               .pc_encode      = nlm4_svc_encode_void,
+               .pc_argsize     = XDR_void,
+               .pc_argzero     = 0,
+               .pc_ressize     = 0,
+               .pc_xdrressize  = XDR_void,
+               .pc_name        = "NULL",
        },
        [NLMPROC_TEST] = {
                .pc_func = nlm4svc_proc_test,