summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChuck Lever <cel@kernel.org>2026-07-12 15:31:19 -0400
committerChuck Lever <cel@kernel.org>2026-08-10 09:54:35 -0400
commit0cfead4c11bd7557b7e10f62e78342fe62b97c52 (patch)
tree5cea3bb5b4cb5d9582364984bf6a6dc6f3dfe930 /tools
parentec5a7c2dceb09caf36262ecbd633eb7d4f9e4d3d (diff)
xdrgen: Share void RPC procedure handlers across programs
The generated server-side decoder and encoder for a void procedure argument or result are named after the RPC program (for example, nfs_svc_decode_void). xdrgen derives that prefix from the program name alone, not the version, so two versions of one program built into the same module emit the identical symbol. NFSv2 and NFSv3 both declare program NFS_PROGRAM; once both are converted, fs/nfsd fails to link with multiple definitions of nfs_svc_decode_void and nfs_svc_encode_void. A void handler carries no program- or version-specific behavior: each merely forwards to xdrgen_decode_void() or xdrgen_encode_void(). Define one shared pair, xdrgen_svc_decode_void() and xdrgen_svc_encode_void(), in the xdrgen builtins, and stop the program generator from emitting a per-program void handler. lockd is the one in-tree consumer that already emits per-program void handlers, so regenerate the NLMv3 and NLMv4 XDR code to drop nlm_svc_{decode,encode}_void() and nlm4_svc_{decode,encode}_void() and point both procedure tables at the shared handlers. The shared handlers are identical to the generated ones they replace, so no wire behavior changes. Only the server (svc) handlers are affected. The client-side void stubs remain static and per-program, so they do not collide. Link: https://patch.msgid.link/20260712193122.116845-3-cel@kernel.org Signed-off-by: Chuck Lever <cel@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/net/sunrpc/xdrgen/generators/program.py8
-rw-r--r--tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j24
-rw-r--r--tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j24
3 files changed, 8 insertions, 8 deletions
diff --git a/tools/net/sunrpc/xdrgen/generators/program.py b/tools/net/sunrpc/xdrgen/generators/program.py
index c0cb3f6d3319..37f9655c83fe 100644
--- a/tools/net/sunrpc/xdrgen/generators/program.py
+++ b/tools/net/sunrpc/xdrgen/generators/program.py
@@ -38,6 +38,8 @@ def emit_version_declarations(
arguments = dict.fromkeys([])
for procedure in version.procedures:
if procedure.name not in excluded_apis:
+ if procedure.argument.type_name == "void":
+ continue
arguments[procedure.argument.type_name] = None
if len(arguments) > 0:
print("")
@@ -48,6 +50,8 @@ def emit_version_declarations(
results = dict.fromkeys([])
for procedure in version.procedures:
if procedure.name not in excluded_apis:
+ if procedure.result.type_name == "void":
+ continue
results[procedure.result.type_name] = None
if len(results) > 0:
print("")
@@ -63,6 +67,8 @@ def emit_version_argument_decoders(
arguments = dict.fromkeys([])
for procedure in version.procedures:
if procedure.name not in excluded_apis:
+ if procedure.argument.type_name == "void":
+ continue
arguments[procedure.argument.type_name] = None
template = environment.get_template("decoder/argument.j2")
@@ -105,6 +111,8 @@ def emit_version_result_encoders(
results = dict.fromkeys([])
for procedure in version.procedures:
if procedure.name not in excluded_apis:
+ if procedure.result.type_name == "void":
+ continue
results[procedure.result.type_name] = None
template = environment.get_template("encoder/result.j2")
diff --git a/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 b/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
index 19b219dd276d..096d553b2a1e 100644
--- a/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
+++ b/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
@@ -11,9 +11,6 @@
*/
bool {{ program }}_svc_decode_{{ argument }}(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
-{% if argument == 'void' %}
- return xdrgen_decode_void(xdr);
-{% else %}
{% if argument in structs %}
struct {{ argument }} *argp = rqstp->rq_argp;
{% else %}
@@ -21,5 +18,4 @@ bool {{ program }}_svc_decode_{{ argument }}(struct svc_rqst *rqstp, struct xdr_
{% endif %}
return xdrgen_decode_{{ argument }}(xdr, argp);
-{% endif %}
}
diff --git a/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 b/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
index 746592cfda56..4243d91966fd 100644
--- a/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
+++ b/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
@@ -11,9 +11,6 @@
*/
bool {{ program }}_svc_encode_{{ result }}(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
-{% if result == 'void' %}
- return xdrgen_encode_void(xdr);
-{% else %}
{% if result in structs %}
struct {{ result }} *resp = rqstp->rq_resp;
@@ -23,5 +20,4 @@ bool {{ program }}_svc_encode_{{ result }}(struct svc_rqst *rqstp, struct xdr_st
return xdrgen_encode_{{ result }}(xdr, *resp);
{% endif %}
-{% endif %}
}