<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/tools/net/sunrpc/xdrgen/generators/enum.py, branch master</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=master</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2026-01-26T15:10:58Z</updated>
<entry>
<title>xdrgen: Add enum value validation to generated decoders</title>
<updated>2026-01-26T15:10:58Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2025-12-26T15:19:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5288993c4d1a8e59310e007aa68cf9b856551cc6'/>
<id>urn:sha1:5288993c4d1a8e59310e007aa68cf9b856551cc6</id>
<content type='text'>
XDR enum decoders generated by xdrgen do not verify that incoming
values are valid members of the enum. Incoming out-of-range values
from malicious or buggy peers propagate through the system
unchecked.

Add validation logic to generated enum decoders using a switch
statement that explicitly lists valid enumerator values. The
compiler optimizes this to a simple range check when enum values
are dense (contiguous), while correctly rejecting invalid values
for sparse enums with gaps in their value ranges.

The --no-enum-validation option on the source subcommand disables
this validation when not needed.

The minimum and maximum fields in _XdrEnum, which were previously
unused placeholders for a range-based validation approach, have
been removed since the switch-based validation handles both dense
and sparse enums correctly.

Because the new mechanism results in substantive changes to
generated code, existing .x files are regenerated. Unrelated white
space and semicolon changes in the generated code are due to recent
commit 1c873a2fd110 ("xdrgen: Don't generate unnecessary semicolon")
and commit 38c4df91242b ("xdrgen: Address some checkpatch whitespace
complaints").

Reviewed-by: NeilBrown &lt;neil@brown.name&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>xdrgen: Add generator code for XDR width macros</title>
<updated>2024-11-11T18:42:05Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2024-10-03T18:54:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e9e1e7e75acd737cf41c6ee64d62da6ea0c10036'/>
<id>urn:sha1:e9e1e7e75acd737cf41c6ee64d62da6ea0c10036</id>
<content type='text'>
Introduce logic in the code generators to emit maxsize (XDR
width) definitions. In C, these are pre-processor macros.

Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>xdrgen: Implement big-endian enums</title>
<updated>2024-11-11T18:42:00Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2024-09-30T00:50:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b376d519bd142c65ba9bba35db12b6be95b46893'/>
<id>urn:sha1:b376d519bd142c65ba9bba35db12b6be95b46893</id>
<content type='text'>
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>xdrgen: Rename enum's declaration Jinja2 template</title>
<updated>2024-11-11T18:41:59Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2024-09-30T00:50:14Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c060f8168bdf22aa986970955af99702d142dfbe'/>
<id>urn:sha1:c060f8168bdf22aa986970955af99702d142dfbe</id>
<content type='text'>
"close.j2" is a confusing name.

Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
<entry>
<title>tools: Add xdrgen</title>
<updated>2024-09-20T23:31:39Z</updated>
<author>
<name>Chuck Lever</name>
</author>
<published>2024-09-13T18:08:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4b132aacb0768ac1e652cf517097ea6f237214b9'/>
<id>urn:sha1:4b132aacb0768ac1e652cf517097ea6f237214b9</id>
<content type='text'>
Add a Python-based tool for translating XDR specifications into XDR
encoder and decoder functions written in the Linux kernel's C coding
style. The generator attempts to match the usual C coding style of
the Linux kernel's SunRPC consumers.

This approach is similar to the netlink code generator in
tools/net/ynl .

The maintainability benefits of machine-generated XDR code include:

- Stronger type checking
- Reduces the number of bugs introduced by human error
- Makes the XDR code easier to audit and analyze
- Enables rapid prototyping of new RPC-based protocols
- Hardens the layering between protocol logic and marshaling
- Makes it easier to add observability on demand
- Unit tests might be built for both the tool and (automatically)
  for the generated code

In addition, converting the XDR layer to use memory-safe languages
such as Rust will be easier if much of the code can be converted
automatically.

Tested-by: Jeff Layton &lt;jlayton@kernel.org&gt;
Signed-off-by: Chuck Lever &lt;chuck.lever@oracle.com&gt;
</content>
</entry>
</feed>
