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: <ab1ee9d4-8cf6-46ae-8c97-56d9a27fbb32@fiberby.net>
Date: Fri, 5 Sep 2025 15:34:32 +0000
From: Asbjørn Sloth Tønnesen <ast@...erby.net>
To: Donald Hunter <donald.hunter@...il.com>
Cc: "Jason A. Donenfeld" <Jason@...c4.com>,
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Simon Horman <horms@...nel.org>, Jacob Keller <jacob.e.keller@...el.com>,
 Andrew Lunn <andrew+netdev@...n.ch>, wireguard@...ts.zx2c4.com,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 09/11] tools: ynl: encode indexed-array

Hi Donald,

Thanks for the reviews.

On 9/5/25 10:49 AM, Donald Hunter wrote:
> Asbjørn Sloth Tønnesen <ast@...erby.net> writes:
> 
>> This patch adds support for encoding indexed-array
>> attributes with sub-type nest in pyynl.
>>
>> Signed-off-by: Asbjørn Sloth Tønnesen <ast@...erby.net>
>> ---
>>   tools/net/ynl/pyynl/lib/ynl.py | 17 +++++++++++++++++
>>   1 file changed, 17 insertions(+)
>>
>> diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
>> index 4928b41c636a..a37294a751da 100644
>> --- a/tools/net/ynl/pyynl/lib/ynl.py
>> +++ b/tools/net/ynl/pyynl/lib/ynl.py
>> @@ -564,6 +564,11 @@ class YnlFamily(SpecFamily):
>>               nl_type |= Netlink.NLA_F_NESTED
>>               sub_space = attr['nested-attributes']
>>               attr_payload = self._add_nest_attrs(value, sub_space, search_attrs)
>> +        elif attr['type'] == 'indexed-array' and attr['sub-type'] == 'nest':
>> +            nl_type |= Netlink.NLA_F_NESTED
>> +            sub_space = attr['nested-attributes']
>> +            attr_payload = self._encode_indexed_array(value, sub_space,
>> +                                                      search_attrs)
>>           elif attr["type"] == 'flag':
>>               if not value:
>>                   # If value is absent or false then skip attribute creation.
>> @@ -617,6 +622,9 @@ class YnlFamily(SpecFamily):
>>           else:
>>               raise Exception(f'Unknown type at {space} {name} {value} {attr["type"]}')
>>   
>> +        return self._add_attr_raw(nl_type, attr_payload)
>> +
>> +    def _add_attr_raw(self, nl_type, attr_payload):
>>           pad = b'\x00' * ((4 - len(attr_payload) % 4) % 4)
>>           return struct.pack('HH', len(attr_payload) + 4, nl_type) + attr_payload + pad
>>   
>> @@ -628,6 +636,15 @@ class YnlFamily(SpecFamily):
>>                                              sub_attrs)
>>           return attr_payload
>>   
>> +    def _encode_indexed_array(self, vals, sub_space, search_attrs):
>> +        attr_payload = b''
>> +        nested_flag = Netlink.NLA_F_NESTED
> 
> This line is not doing anything, right?

Right, that line shouldn't be there, it is a remain of an early version, where
I didn't add the indexes, as NLA_NESTED_ARRAY is actually an unindexed-array.

The wireguard kernel code only sends zero types, and it doesn't care that user-
space sends an indexed array back, eg. when setting multiple allowed ips.

>> +        for i, val in enumerate(vals):
>> +            idx = i | Netlink.NLA_F_NESTED
>> +            val_payload = self._add_nest_attrs(val, sub_space, search_attrs)
>> +            attr_payload += self._add_attr_raw(idx, val_payload)
>> +        return attr_payload
>> +
>>       def _get_enum_or_unknown(self, enum, raw):
>>           try:
>>               name = enum.entries_by_val[raw].name

-- 
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ