Re: [PATCH v2 1/2] tools: Add xdrgen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2024-08-27 at 12:27 -0400, cel@xxxxxxxxxx wrote:
> From: Chuck Lever <chuck.lever@xxxxxxxxxx>
> 
> 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.
> 
> Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
> ---
>  include/linux/sunrpc/xdrgen-builtins.h        | 256 +++++++++
>  tools/net/sunrpc/xdrgen/.gitignore            |   2 +
>  tools/net/sunrpc/xdrgen/README                | 249 +++++++++
>  tools/net/sunrpc/xdrgen/__init__.py           |   2 +
>  .../net/sunrpc/xdrgen/generators/__init__.py  |  49 ++
>  .../sunrpc/xdrgen/generators/boilerplate.py   |  58 +++
>  .../net/sunrpc/xdrgen/generators/constant.py  |  20 +
>  tools/net/sunrpc/xdrgen/generators/enum.py    |  41 ++
>  tools/net/sunrpc/xdrgen/generators/pointer.py | 283 ++++++++++
>  tools/net/sunrpc/xdrgen/generators/program.py | 141 +++++
>  tools/net/sunrpc/xdrgen/generators/struct.py  | 283 ++++++++++
>  tools/net/sunrpc/xdrgen/generators/typedef.py | 225 ++++++++
>  tools/net/sunrpc/xdrgen/generators/union.py   | 238 +++++++++
>  tools/net/sunrpc/xdrgen/grammars/xdr.lark     | 119 +++++
>  tools/net/sunrpc/xdrgen/subcmds/__init__.py   |   2 +
>  tools/net/sunrpc/xdrgen/subcmds/header.py     |  88 ++++
>  tools/net/sunrpc/xdrgen/subcmds/lint.py       |  33 ++
>  tools/net/sunrpc/xdrgen/subcmds/source.py     | 121 +++++
>  .../templates/C/boilerplate/header_bottom.j2  |   3 +
>  .../templates/C/boilerplate/header_top.j2     |  11 +
>  .../templates/C/boilerplate/source_top.j2     |   5 +
>  .../templates/C/constants/definition.j2       |   3 +
>  .../xdrgen/templates/C/enum/decoder/enum.j2   |  19 +
>  .../templates/C/enum/definition/close.j2      |   7 +
>  .../templates/C/enum/definition/enumerator.j2 |   2 +
>  .../templates/C/enum/definition/open.j2       |   3 +
>  .../xdrgen/templates/C/enum/encoder/enum.j2   |  14 +
>  .../templates/C/pointer/decoder/basic.j2      |   6 +
>  .../templates/C/pointer/decoder/close.j2      |   3 +
>  .../C/pointer/decoder/fixed_length_array.j2   |   8 +
>  .../C/pointer/decoder/fixed_length_opaque.j2  |   6 +
>  .../templates/C/pointer/decoder/open.j2       |  22 +
>  .../C/pointer/decoder/optional_data.j2        |   6 +
>  .../pointer/decoder/variable_length_array.j2  |  13 +
>  .../pointer/decoder/variable_length_opaque.j2 |   6 +
>  .../pointer/decoder/variable_length_string.j2 |   6 +
>  .../templates/C/pointer/definition/basic.j2   |   5 +
>  .../templates/C/pointer/definition/close.j2   |   7 +
>  .../pointer/definition/fixed_length_array.j2  |   5 +
>  .../pointer/definition/fixed_length_opaque.j2 |   5 +
>  .../templates/C/pointer/definition/open.j2    |   6 +
>  .../C/pointer/definition/optional_data.j2     |   5 +
>  .../definition/variable_length_array.j2       |   8 +
>  .../definition/variable_length_opaque.j2      |   5 +
>  .../definition/variable_length_string.j2      |   5 +
>  .../templates/C/pointer/encoder/basic.j2      |  10 +
>  .../templates/C/pointer/encoder/close.j2      |   3 +
>  .../C/pointer/encoder/fixed_length_array.j2   |  12 +
>  .../C/pointer/encoder/fixed_length_opaque.j2  |   6 +
>  .../templates/C/pointer/encoder/open.j2       |  20 +
>  .../C/pointer/encoder/optional_data.j2        |   6 +
>  .../pointer/encoder/variable_length_array.j2  |  15 +
>  .../pointer/encoder/variable_length_opaque.j2 |   8 +
>  .../pointer/encoder/variable_length_string.j2 |   8 +
>  .../C/program/declaration/argument.j2         |   2 +
>  .../templates/C/program/declaration/result.j2 |   2 +
>  .../templates/C/program/decoder/argument.j2   |  21 +
>  .../templates/C/program/decoder/result.j2     |  22 +
>  .../templates/C/program/encoder/argument.j2   |  16 +
>  .../templates/C/program/encoder/result.j2     |  21 +
>  .../templates/C/struct/decoder/basic.j2       |   6 +
>  .../templates/C/struct/decoder/close.j2       |   3 +
>  .../C/struct/decoder/fixed_length_array.j2    |   8 +
>  .../C/struct/decoder/fixed_length_opaque.j2   |   6 +
>  .../xdrgen/templates/C/struct/decoder/open.j2 |  12 +
>  .../C/struct/decoder/optional_data.j2         |   6 +
>  .../C/struct/decoder/variable_length_array.j2 |  13 +
>  .../struct/decoder/variable_length_opaque.j2  |   6 +
>  .../struct/decoder/variable_length_string.j2  |   6 +
>  .../templates/C/struct/definition/basic.j2    |   5 +
>  .../templates/C/struct/definition/close.j2    |   7 +
>  .../C/struct/definition/fixed_length_array.j2 |   5 +
>  .../struct/definition/fixed_length_opaque.j2  |   5 +
>  .../templates/C/struct/definition/open.j2     |   6 +
>  .../C/struct/definition/optional_data.j2      |   5 +
>  .../definition/variable_length_array.j2       |   8 +
>  .../definition/variable_length_opaque.j2      |   5 +
>  .../definition/variable_length_string.j2      |   5 +
>  .../templates/C/struct/encoder/basic.j2       |  10 +
>  .../templates/C/struct/encoder/close.j2       |   3 +
>  .../C/struct/encoder/fixed_length_array.j2    |  12 +
>  .../C/struct/encoder/fixed_length_opaque.j2   |   6 +
>  .../xdrgen/templates/C/struct/encoder/open.j2 |  12 +
>  .../C/struct/encoder/optional_data.j2         |   6 +
>  .../C/struct/encoder/variable_length_array.j2 |  15 +
>  .../struct/encoder/variable_length_opaque.j2  |   8 +
>  .../struct/encoder/variable_length_string.j2  |   8 +
>  .../templates/C/typedef/decoder/basic.j2      |  17 +
>  .../C/typedef/decoder/fixed_length_array.j2   |  25 +
>  .../C/typedef/decoder/fixed_length_opaque.j2  |  17 +
>  .../typedef/decoder/variable_length_array.j2  |  26 +
>  .../typedef/decoder/variable_length_opaque.j2 |  17 +
>  .../typedef/decoder/variable_length_string.j2 |  17 +
>  .../templates/C/typedef/definition/basic.j2   |  15 +
>  .../typedef/definition/fixed_length_array.j2  |  11 +
>  .../typedef/definition/fixed_length_opaque.j2 |  11 +
>  .../definition/variable_length_array.j2       |  14 +
>  .../definition/variable_length_opaque.j2      |  11 +
>  .../definition/variable_length_string.j2      |  11 +
>  .../templates/C/typedef/encoder/basic.j2      |  21 +
>  .../C/typedef/encoder/fixed_length_array.j2   |  25 +
>  .../C/typedef/encoder/fixed_length_opaque.j2  |  17 +
>  .../typedef/encoder/variable_length_array.j2  |  30 ++
>  .../typedef/encoder/variable_length_opaque.j2 |  17 +
>  .../typedef/encoder/variable_length_string.j2 |  17 +
>  .../xdrgen/templates/C/union/decoder/basic.j2 |   6 +
>  .../xdrgen/templates/C/union/decoder/break.j2 |   2 +
>  .../templates/C/union/decoder/case_spec.j2    |   2 +
>  .../xdrgen/templates/C/union/decoder/close.j2 |   4 +
>  .../templates/C/union/decoder/default_spec.j2 |   2 +
>  .../xdrgen/templates/C/union/decoder/open.j2  |  12 +
>  .../C/union/decoder/optional_data.j2          |   6 +
>  .../templates/C/union/decoder/switch_spec.j2  |   7 +
>  .../C/union/decoder/variable_length_array.j2  |  13 +
>  .../C/union/decoder/variable_length_opaque.j2 |   6 +
>  .../C/union/decoder/variable_length_string.j2 |   6 +
>  .../xdrgen/templates/C/union/decoder/void.j2  |   3 +
>  .../templates/C/union/definition/case_spec.j2 |   2 +
>  .../templates/C/union/definition/close.j2     |   8 +
>  .../C/union/definition/default_spec.j2        |   2 +
>  .../templates/C/union/definition/open.j2      |   6 +
>  .../C/union/definition/switch_spec.j2         |   3 +
>  .../xdrgen/templates/C/union/encoder/basic.j2 |  10 +
>  .../xdrgen/templates/C/union/encoder/break.j2 |   2 +
>  .../templates/C/union/encoder/case_spec.j2    |   2 +
>  .../xdrgen/templates/C/union/encoder/close.j2 |   4 +
>  .../templates/C/union/encoder/default_spec.j2 |   2 +
>  .../xdrgen/templates/C/union/encoder/open.j2  |  12 +
>  .../templates/C/union/encoder/switch_spec.j2  |   7 +
>  .../xdrgen/templates/C/union/encoder/void.j2  |   3 +
>  tools/net/sunrpc/xdrgen/tests/test.x          |  36 ++
>  tools/net/sunrpc/xdrgen/xdr_ast.py            | 485 ++++++++++++++++++
>  tools/net/sunrpc/xdrgen/xdr_parse.py          |  36 ++
>  tools/net/sunrpc/xdrgen/xdrgen                | 111 ++++
>  134 files changed, 3892 insertions(+)
>  create mode 100644 include/linux/sunrpc/xdrgen-builtins.h
>  create mode 100644 tools/net/sunrpc/xdrgen/.gitignore
>  create mode 100644 tools/net/sunrpc/xdrgen/README
>  create mode 100644 tools/net/sunrpc/xdrgen/__init__.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/__init__.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/boilerplate.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/constant.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/enum.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/pointer.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/program.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/struct.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/typedef.py
>  create mode 100644 tools/net/sunrpc/xdrgen/generators/union.py
>  create mode 100644 tools/net/sunrpc/xdrgen/grammars/xdr.lark
>  create mode 100644 tools/net/sunrpc/xdrgen/subcmds/__init__.py
>  create mode 100644 tools/net/sunrpc/xdrgen/subcmds/header.py
>  create mode 100644 tools/net/sunrpc/xdrgen/subcmds/lint.py
>  create mode 100644 tools/net/sunrpc/xdrgen/subcmds/source.py
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_bottom.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/header_top.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/boilerplate/source_top.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/constants/definition.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/decoder/enum.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/definition/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/definition/enumerator.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/definition/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/enum/encoder/enum.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/decoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/definition/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/pointer/encoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/argument.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/declaration/result.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/decoder/result.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/argument.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/decoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/definition/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/struct/encoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/decoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definition/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definition/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definition/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definition/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definition/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/definition/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/fixed_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/typedef/encoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/break.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/case_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/default_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/optional_data.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/switch_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_array.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_opaque.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/variable_length_string.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/decoder/void.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/case_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/default_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/definition/switch_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/basic.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/break.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/case_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/close.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/default_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/open.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/switch_spec.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/templates/C/union/encoder/void.j2
>  create mode 100644 tools/net/sunrpc/xdrgen/tests/test.x
>  create mode 100644 tools/net/sunrpc/xdrgen/xdr_ast.py
>  create mode 100644 tools/net/sunrpc/xdrgen/xdr_parse.py
>  create mode 100755 tools/net/sunrpc/xdrgen/xdrgen
> 

[...]

> diff --git a/tools/net/sunrpc/xdrgen/README b/tools/net/sunrpc/xdrgen/README
> new file mode 100644
> index 000000000000..a1a2454a5edf
> --- /dev/null
> +++ b/tools/net/sunrpc/xdrgen/README
> @@ -0,0 +1,249 @@
> +xdrgen - Linux Kernel XDR code generator
> +
> +Introduction
> +------------
> +
> +SunRPC programs are typically specified using a language defined by
> +RFC 4506. In fact, all IETF-published NFS specifications provide a
> +description of the specified protocol using this language.
> +
> +Since the 1990's, user space consumers of SunRPC have had access to
> +a tool that could read such XDR specifications and then generate C
> +code that implements the RPC portions of that protocol. This tool is
> +called rpcgen.
> +
> +This RPC-level code is code that handles input directly from the
> +network, and thus a high degree of memory safety and sanity checking
> +is needed to help ensure proper levels of security. Bugs in this
> +code can have significant impact on security and performance.
> +
> +However, it is code that is repetitive and tedious to write by hand.
> +
> +The C code generated by rpcgen makes extensive use of the facilities
> +of the user space TI-RPC library and libc. Furthermore, the dialect
> +of the generated code is very traditional K&R C.
> +
> +The Linux kernel's implementation of SunRPC-based protocols hand-roll
> +their XDR implementation. There are two main reasons for this:
> +
> +1. libtirpc (and its predecessors) operate only in user space. The
> +   kernel's RPC implementation and its API are significantly
> +   different than libtirpc.
> +
> +2. rpcgen-generated code is believed to be less efficient than code
> +   that is hand-written.
> +
> +These days, gcc and its kin are capable of optimizing code better
> +than human authors. There are only a few instances where writing
> +XDR code by hand will make a measurable performance different.
> +
> +In addition, the current hand-written code in the Linux kernel is
> +difficult to audit and prove that it implements exactly what is in
> +the protocol specification.
> +
> +In order to accrue the benefits of machine-generated XDR code in the
> +kernel, a tool is needed that will output C code that works against
> +the kernel's SunRPC implementation rather than libtirpc.
> +
> +Enter xdrgen.
> +
> +
> +Dependencies
> +------------
> +
> +These dependencies are typically packaged by Linux distributions:
> +
> +- python3
> +- python3-lark
> +- python3-jinja2
> +
> +These dependencies are available via PyPi:
> +
> +- pip install 'lark[interegular]'
> +
> +
> +XDR Specifications
> +------------------
> +
> +When adding a new protocol implementation to the kernel, the XDR
> +specification can be derived by feeding a .txt copy of the RFC to
> +the script located in tools/net/sunrpc/extract.sh.
> +
> +   $ extract.sh < rfc0001.txt > new2.x
> +

I just noticed that the above blurb is in the README, but there is no
extract.sh script in this patch (or any later one). We should either
remove this (or preferably?) add the appropriate extract.sh script.


-- 
Jeff Layton <jlayton@xxxxxxxxxx>





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux