Message ID | 20250105012523.1722231-2-kuba@kernel.org (mailing list archive) |
---|---|
State | New |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | tools: ynl: decode link types present in tests | expand |
Jakub Kicinski <kuba@kernel.org> 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/20231004171350.1f59cd1d@kernel.org/ > > Signed-off-by: Jakub Kicinski <kuba@kernel.org> I guess we're okay with requiring Python >= 3.9 for combining dicts with | Reviewed-by: Donald Hunter <donald.hunter@gmail.com> > --- > 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
On Mon, 06 Jan 2025 13:27:49 +0000 Donald Hunter wrote: > > 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/20231004171350.1f59cd1d@kernel.org/ > > > > Signed-off-by: Jakub Kicinski <kuba@kernel.org> > > I guess we're okay with requiring Python >= 3.9 for combining > dicts with | Ah, I didn't realize. Does YNL work on older versions today? I thought we already narrowed down to 3.9+. That may have been tests not YNL itself. The "oldest" OS I have is CentOS 9(-derived) and has 3.9, so from my selfish perspective 3.9+ is perfectly fine :)
On Mon, 6 Jan 2025 at 15:36, Jakub Kicinski <kuba@kernel.org> wrote: > > On Mon, 06 Jan 2025 13:27:49 +0000 Donald Hunter wrote: > > > 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/20231004171350.1f59cd1d@kernel.org/ > > > > > > Signed-off-by: Jakub Kicinski <kuba@kernel.org> > > > > I guess we're okay with requiring Python >= 3.9 for combining > > dicts with | > > Ah, I didn't realize. Does YNL work on older versions today? > I thought we already narrowed down to 3.9+. That may have > been tests not YNL itself. You're right, we may already be committed to 3.9+ > The "oldest" OS I have is CentOS 9(-derived) and has 3.9, > so from my selfish perspective 3.9+ is perfectly fine :) To be fair, on a previous commit you mentioned that it affected CentOS 8 which EOLed back in May 2024 so we shouldn't feel compelled to support it any more. https://lore.kernel.org/all/20230524170712.2036128-1-kuba@kernel.org/
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
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/20231004171350.1f59cd1d@kernel.org/ Signed-off-by: Jakub Kicinski <kuba@kernel.org> --- tools/net/ynl/lib/nlspec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)