mbox series

[net-next,v2,00/11] tools/net/ynl: Add 'sub-message' support to ynl

Message ID 20231211164039.83034-1-donald.hunter@gmail.com (mailing list archive)
Headers show
Series tools/net/ynl: Add 'sub-message' support to ynl | expand

Message

Donald Hunter Dec. 11, 2023, 4:40 p.m. UTC
This patchset adds a 'sub-message' attribute type to the netlink-raw
schema and implements it in ynl. This provides support for kind-specific
options attributes as used in rt_link and tc raw netlink families.

A description of the new 'sub-message' attribute type and the
corresponding sub-message definitions is provided in patch 5.

The patchset includes updates to the rt_link spec and a new tc spec that
make use of the new 'sub-message' attribute type.

As mentioned in patch 7, encode support is not yet implemented in ynl
and support for sub-message selectors at a different nest level from the
key attribute is not yet supported. I plan to work on these in folloup
patches.

Patches 1-4 are cleanups and fixes in ynl
Patches 5-7 add sub-message support to the schema and ynl with
documentation updates.
Patch 8 adds binary and pad support to structs in netlink-raw.
Patches 9-10 contain specs that use the sub-message attribute type.
Patch 11 updates ynl-gen-rst to include sub-messages

Changes since v1: (all reported by Jakub Kicinski, thanks!)
 - Added cleanups for ynl and generated netlink docs
 - Describe sub-messages in netlink docs
 - Cleaned up unintended indent changes
 - Cleaned up rt-link sub-message definitions
 - Cleaned up array index expressions to follow python style
 - Added sub-messages to generated netlink spec docs

Donald Hunter (11):
  tools/net/ynl-gen-rst: Use bullet lists for attribute-set entries
  tools/net/ynl-gen-rst: Sort the index of generated netlink specs
  doc/netlink: Regenerate netlink .rst files if ynl-gen-rst changes
  tools/net/ynl: Use consistent array index expression formatting
  doc/netlink: Add sub-message support to netlink-raw
  doc/netlink: Document the sub-message format for netlink-raw
  tools/net/ynl: Add 'sub-message' attribute decoding to ynl
  tools/net/ynl: Add binary and pad support to structs for tc
  doc/netlink/specs: add sub-message type to rt_link family
  doc/netlink/specs: Add a spec for tc
  tools/net/ynl-gen-rst: Add sub-messages to generated docs

 Documentation/Makefile                        |    7 +-
 Documentation/netlink/netlink-raw.yaml        |   53 +-
 Documentation/netlink/specs/rt_link.yaml      |  436 +++-
 Documentation/netlink/specs/tc.yaml           | 2036 +++++++++++++++++
 .../userspace-api/netlink/netlink-raw.rst     |   75 +-
 tools/net/ynl/lib/nlspec.py                   |   55 +
 tools/net/ynl/lib/ynl.py                      |   94 +-
 tools/net/ynl/ynl-gen-rst.py                  |   27 +-
 8 files changed, 2748 insertions(+), 35 deletions(-)
 create mode 100644 Documentation/netlink/specs/tc.yaml

Comments

Jakub Kicinski Dec. 11, 2023, 11:32 p.m. UTC | #1
On Mon, 11 Dec 2023 16:40:28 +0000 Donald Hunter wrote:
> This patchset adds a 'sub-message' attribute type to the netlink-raw
> schema and implements it in ynl. This provides support for kind-specific
> options attributes as used in rt_link and tc raw netlink families.
> 
> A description of the new 'sub-message' attribute type and the
> corresponding sub-message definitions is provided in patch 5.
> 
> The patchset includes updates to the rt_link spec and a new tc spec that
> make use of the new 'sub-message' attribute type.
> 
> As mentioned in patch 7, encode support is not yet implemented in ynl
> and support for sub-message selectors at a different nest level from the
> key attribute is not yet supported. I plan to work on these in folloup
> patches.

Seems to break C codegen:

Traceback (most recent call last):
  File "net-next/tools/net/ynl/ynl-gen-c.py", line 2802, in <module>
    main()
  File "net-next/tools/net/ynl/ynl-gen-c.py", line 2531, in main
    parsed = Family(args.spec, exclude_ops)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "net-next/tools/net/ynl/ynl-gen-c.py", line 889, in __init__
    super().__init__(file_name, exclude_ops=exclude_ops)
  File "net-next/tools/net/ynl/lib/nlspec.py", line 481, in __init__
    raise last_exception
  File "net-next/tools/net/ynl/lib/nlspec.py", line 472, in __init__
    elem.resolve()
  File "net-next/tools/net/ynl/ynl-gen-c.py", line 907, in resolve
    self.resolve_up(super())
  File "net-next/tools/net/ynl/lib/nlspec.py", line 53, in resolve_up
    up.resolve()
  File "net-next/tools/net/ynl/lib/nlspec.py", line 583, in resolve
    for elem in self.yaml['sub-messages']:
                ~~~~~~~~~^^^^^^^^^^^^^^^^
Donald Hunter Dec. 12, 2023, 11:38 a.m. UTC | #2
Jakub Kicinski <kuba@kernel.org> writes:

> On Mon, 11 Dec 2023 16:40:28 +0000 Donald Hunter wrote:
>> This patchset adds a 'sub-message' attribute type to the netlink-raw
>> schema and implements it in ynl. This provides support for kind-specific
>> options attributes as used in rt_link and tc raw netlink families.
>> 
>> A description of the new 'sub-message' attribute type and the
>> corresponding sub-message definitions is provided in patch 5.
>> 
>> The patchset includes updates to the rt_link spec and a new tc spec that
>> make use of the new 'sub-message' attribute type.
>> 
>> As mentioned in patch 7, encode support is not yet implemented in ynl
>> and support for sub-message selectors at a different nest level from the
>> key attribute is not yet supported. I plan to work on these in folloup
>> patches.
>
> Seems to break C codegen:

Ick. Sorry about that. How do you test/validate the C codegen?

> Traceback (most recent call last):
>   File "net-next/tools/net/ynl/ynl-gen-c.py", line 2802, in <module>
>     main()
>   File "net-next/tools/net/ynl/ynl-gen-c.py", line 2531, in main
>     parsed = Family(args.spec, exclude_ops)
>              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "net-next/tools/net/ynl/ynl-gen-c.py", line 889, in __init__
>     super().__init__(file_name, exclude_ops=exclude_ops)
>   File "net-next/tools/net/ynl/lib/nlspec.py", line 481, in __init__
>     raise last_exception
>   File "net-next/tools/net/ynl/lib/nlspec.py", line 472, in __init__
>     elem.resolve()
>   File "net-next/tools/net/ynl/ynl-gen-c.py", line 907, in resolve
>     self.resolve_up(super())
>   File "net-next/tools/net/ynl/lib/nlspec.py", line 53, in resolve_up
>     up.resolve()
>   File "net-next/tools/net/ynl/lib/nlspec.py", line 583, in resolve
>     for elem in self.yaml['sub-messages']:
>                 ~~~~~~~~~^^^^^^^^^^^^^^^^
Jakub Kicinski Dec. 12, 2023, 4:14 p.m. UTC | #3
On Tue, 12 Dec 2023 11:38:07 +0000 Donald Hunter wrote:
> > Seems to break C codegen:  
> 
> Ick. Sorry about that. How do you test/validate the C codegen?

make -C tools/net/ynl -j 8