]> www.infradead.org Git - users/jedix/linux-maple.git/commit
tools: ynl-gen: submsg: support parsing and rendering sub-messages
authorJakub Kicinski <kuba@kernel.org>
Thu, 15 May 2025 23:16:47 +0000 (16:16 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 16 May 2025 23:32:06 +0000 (16:32 -0700)
commitb9e03e263610a8d872c753bc882676d3cba1797b
tree288fe189eb630074a69d7cea7e63c290d584264f
parent6366d267788fd9dba20d6dff61e3e05d48ddb0b8
tools: ynl-gen: submsg: support parsing and rendering sub-messages

Adjust parsing and rendering appropriately to make sub-messages work.
Rendering is pretty trivial, as the submsg -> netlink conversion looks
like rendering a nest in which only one attr was set. Only trick
is that we use the enum value of the sub-message rather than the nest
as the type, and effectively skip one layer of nesting. A real double
nested struct would look like this:

  [SELECTOR]
  [SUBMSG]
    [NEST]
      [MSG1-ATTR]

A submsg "is" the nest so by skipping I mean:

  [SELECTOR]
  [SUBMSG]
    [MSG1-ATTR]

There is no extra validation in YNL if caller has set the selector
matching the submsg type (e.g. link type = "macvlan" but the nest
attrs are set to carry "veth"). Let the kernel handle that.

Parsing side is a little more specialized as we need to render and
insert a new kind of function which switches between what to parse
based on the selector. But code isn't too complicated.

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://patch.msgid.link/20250515231650.1325372-7-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/lib/ynl-priv.h
tools/net/ynl/lib/ynl.c
tools/net/ynl/lib/ynl.h
tools/net/ynl/pyynl/ynl_gen_c.py