Subject: Re: [PATCH net-next 1/3] tools: ynl: correctly handle overrides of fields in subset

From: Donald Hunter <[email-masked]>
Date: Mon, 06 Jan 2025 13:27:49 +0000

Jakub Kicinski <[email-masked]> writes:

> We stated in documentation [1] and previous discussions [2]
> that the need for overriding fields in members of subsets
> is anticipated. Implement it.
>
> [1] https://docs.kernel.org/next/userspace-api/netlink/specs.html#subset-of
> [2] https://lore.kernel.org/netdev/[email-masked]/
>
> Signed-off-by: Jakub Kicinski <[email-masked]>

I guess we're okay with requiring Python >= 3.9 for combining
dicts with |

Reviewed-by: Donald Hunter <[email-masked]>

> ---
>  tools/net/ynl/lib/nlspec.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/net/ynl/lib/nlspec.py b/tools/net/ynl/lib/nlspec.py
> index a745739655ad..314ec8007496 100644
> --- a/tools/net/ynl/lib/nlspec.py
> +++ b/tools/net/ynl/lib/nlspec.py
> @@ -219,7 +219,10 @@ jsonschema = None
>          else:
>              real_set = family.attr_sets[self.subset_of]
>              for elem in self.yaml['attributes']:
> -                attr = real_set[elem['name']]
> +                real_attr = real_set[elem['name']]
> +                combined_elem = real_attr.yaml | elem
> +                attr = self.new_attr(combined_elem, real_attr.value)
> +
>                  self.attrs[attr.name] = attr
>                  self.attrs_by_val[attr.value] = attr