Message ID | 9399f6f7bda6c845194419952dfbcf0d42142652.1706882196.git.alessandromarcolini99@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Add support for encoding multi-attr to ynl | expand |
Alessandro Marcolini <alessandromarcolini99@gmail.com> writes: > Multi-attr elements could not be encoded because of missing logic in the > ynl code. Enable encoding of these attributes by checking if the > attribute is a multi-attr and if the value to be processed is a list. > > This has been tested both with the taprio and ets qdisc which contain > this kind of attributes. > > Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail.com> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> > --- > tools/net/ynl/lib/ynl.py | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py > index 0f4193cc2e3b..d5779d023b10 100644 > --- a/tools/net/ynl/lib/ynl.py > +++ b/tools/net/ynl/lib/ynl.py > @@ -444,6 +444,11 @@ class YnlFamily(SpecFamily): > except KeyError: > raise Exception(f"Space '{space}' has no attribute '{name}'") > nl_type = attr.value > + if attr.is_multi and isinstance(value, list): > + attr_payload = b'' > + for subvalue in value: > + attr_payload += self._add_attr(space, name, subvalue, search_attrs) > + return attr_payload > if attr["type"] == 'nest': > nl_type |= Netlink.NLA_F_NESTED > attr_payload = b''
On Fri, 2 Feb 2024 15:00:05 +0100 Alessandro Marcolini wrote: > nl_type = attr.value > + if attr.is_multi and isinstance(value, list): > + attr_payload = b'' > + for subvalue in value: > + attr_payload += self._add_attr(space, name, subvalue, search_attrs) > + return attr_payload > if attr["type"] == 'nest': nit: would you mind adding an empty line before and after the new block? It's logically separate from the other code, sort of an alternative to the "actual" handling, as well as finding the attr set. Also agreed on adding an example to the cover letter (either one or both). With that feel free to add: Reviewed-by: Jakub Kicinski <kuba@kernel.org> on all 3 patches in v4.
On 2/3/24 03:17, Jakub Kicinski wrote: > On Fri, 2 Feb 2024 15:00:05 +0100 Alessandro Marcolini wrote: >> nl_type = attr.value >> + if attr.is_multi and isinstance(value, list): >> + attr_payload = b'' >> + for subvalue in value: >> + attr_payload += self._add_attr(space, name, subvalue, search_attrs) >> + return attr_payload >> if attr["type"] == 'nest': > nit: would you mind adding an empty line before and after the new > block? It's logically separate from the other code, sort of an > alternative to the "actual" handling, as well as finding the attr set. This makes sense. > Also agreed on adding an example to the cover letter (either one or > both). > > With that feel free to add: > > Reviewed-by: Jakub Kicinski <kuba@kernel.org> > > on all 3 patches in v4. Perfect, I'll post the v4 soon with both the examples. Thanks!
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index 0f4193cc2e3b..d5779d023b10 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -444,6 +444,11 @@ class YnlFamily(SpecFamily): except KeyError: raise Exception(f"Space '{space}' has no attribute '{name}'") nl_type = attr.value + if attr.is_multi and isinstance(value, list): + attr_payload = b'' + for subvalue in value: + attr_payload += self._add_attr(space, name, subvalue, search_attrs) + return attr_payload if attr["type"] == 'nest': nl_type |= Netlink.NLA_F_NESTED attr_payload = b''
Multi-attr elements could not be encoded because of missing logic in the ynl code. Enable encoding of these attributes by checking if the attribute is a multi-attr and if the value to be processed is a list. This has been tested both with the taprio and ets qdisc which contain this kind of attributes. Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail.com> --- tools/net/ynl/lib/ynl.py | 5 +++++ 1 file changed, 5 insertions(+)