lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <17795933-a5ca-44c6-be4c-58ed2e573aff@gmail.com>
Date: Wed, 24 Jan 2024 10:12:02 +0100
From: Alessandro Marcolini <alessandromarcolini99@...il.com>
To: Donald Hunter <donald.hunter@...il.com>
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
 pabeni@...hat.com, sdf@...gle.com, chuck.lever@...cle.com,
 lorenzo@...nel.org, jacob.e.keller@...el.com, jiri@...nulli.us,
 netdev@...r.kernel.org
Subject: Re: [PATCH net-next 3/3] tools: ynl: add encoding support for
 'sub-message' to ynl

On 1/23/24 17:44, Donald Hunter wrote:
> Alessandro Marcolini <alessandromarcolini99@...il.com> writes:
>
>> Add encoding support for 'sub-message' attribute and for resolving
>> sub-message selectors at different nesting level from the key
>> attribute.
> I think the relevant patches in my series are:
>
> https://lore.kernel.org/netdev/20240123160538.172-3-donald.hunter@gmail.com/T/#u
> https://lore.kernel.org/netdev/20240123160538.172-5-donald.hunter@gmail.com/T/#u
I really like your idea of using ChainMap, I think it's better than mine and more concise.
>> Also, add encoding support for multi-attr attributes.
> This would be better as a separate patch since it is unrelated to the
> other changes.
You mean as a separate patch in this patchset or as an entirely new patch?
>> Signed-off-by: Alessandro Marcolini <alessandromarcolini99@...il.com>
>> ---
>>  tools/net/ynl/lib/ynl.py | 54 +++++++++++++++++++++++++++++++++++-----
>>  1 file changed, 48 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
>> index 1e10512b2117..f8c56944f7e7 100644
>> --- a/tools/net/ynl/lib/ynl.py
>> +++ b/tools/net/ynl/lib/ynl.py
>> @@ -449,7 +449,7 @@ class YnlFamily(SpecFamily):
>>          self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_ADD_MEMBERSHIP,
>>                               mcast_id)
>>  
>> -    def _add_attr(self, space, name, value):
>> +    def _add_attr(self, space, name, value, vals):
>>          try:
>>              attr = self.attr_sets[space][name]
>>          except KeyError:
>> @@ -458,8 +458,13 @@ class YnlFamily(SpecFamily):
>>          if attr["type"] == 'nest':
>>              nl_type |= Netlink.NLA_F_NESTED
>>              attr_payload = b''
>> -            for subname, subvalue in value.items():
>> -                attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue)
>> +            # Check if it's a list of values (i.e. it contains multi-attr elements)
>> +            for subname, subvalue in (
>> +                ((k, v) for item in value for k, v in item.items())
>> +                if isinstance(value, list)
>> +                else value.items()
>> +            ):
>> +                attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue, vals)
> Should really check whether multi-attr is true in the spec before
> processing the json input as a list of values.
Yes, you're right. Maybe I could resend this on top of your changes, what do you think?


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ