]> git.dujemihanovic.xyz Git - linux.git/commit
tools: Add xdrgen
authorChuck Lever <chuck.lever@oracle.com>
Fri, 13 Sep 2024 18:08:13 +0000 (14:08 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Fri, 20 Sep 2024 23:31:39 +0000 (19:31 -0400)
commit4b132aacb0768ac1e652cf517097ea6f237214b9
tree74a112db399fec7cfe72202bc092e0eb29695ced
parent45bb63ed20e02ae146336412889fe5450316a84f
tools: Add xdrgen

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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
153 files changed:
include/linux/sunrpc/xdrgen/_builtins.h [new file with mode: 0644]
include/linux/sunrpc/xdrgen/_defs.h [new file with mode: 0644]
tools/net/sunrpc/xdrgen/.gitignore [new file with mode: 0644]
tools/net/sunrpc/xdrgen/README [new file with mode: 0644]
tools/net/sunrpc/xdrgen/__init__.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/__init__.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/constant.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/enum.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/header_bottom.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/header_top.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/pointer.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/program.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/source_top.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/struct.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/typedef.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/generators/union.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/grammars/xdr.lark [new file with mode: 0644]
tools/net/sunrpc/xdrgen/subcmds/__init__.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/subcmds/declarations.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/subcmds/definitions.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/subcmds/lint.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/subcmds/source.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/constants/definition.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/enum/declaration/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/enum/definition/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/enum/definition/enumerator.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/enum/definition/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/header_bottom/declaration/header.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/header_bottom/definition/header.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/header_top/declaration/header.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/header_top/definition/header.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/declaration/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/definition/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/decoder/result.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/definition/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/definition/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/definition/procedure.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/encoder/argument.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/source_top/client.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/source_top/server.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/declaration/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/definition/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/declaration/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/definition/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/definition/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/definition/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/definition/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/definition/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/definition/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/definition/case_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/definition/default_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/definition/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/definition/switch_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2 [new file with mode: 0644]
tools/net/sunrpc/xdrgen/tests/test.x [new file with mode: 0644]
tools/net/sunrpc/xdrgen/xdr_ast.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/xdr_parse.py [new file with mode: 0644]
tools/net/sunrpc/xdrgen/xdrgen [new file with mode: 0755]