mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
ynl: rename array-nest to indexed-array
Some implementations, like bonding, has nest array with same attr type. To support all kinds of entries under one nest array. As discussed[1], let's rename array-nest to indexed-array, and assuming the value is a nest by passing the type via sub-type. [1] https://lore.kernel.org/netdev/20240312100105.16a59086@kernel.org/ Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://lore.kernel.org/r/20240404063114.1221532-2-liuhangbin@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
f410cbea9f
commit
aa6485d813
@@ -631,15 +631,18 @@ class YnlFamily(SpecFamily):
|
||||
decoded = self._formatted_string(decoded, attr_spec.display_hint)
|
||||
return decoded
|
||||
|
||||
def _decode_array_nest(self, attr, attr_spec):
|
||||
def _decode_array_attr(self, attr, attr_spec):
|
||||
decoded = []
|
||||
offset = 0
|
||||
while offset < len(attr.raw):
|
||||
item = NlAttr(attr.raw, offset)
|
||||
offset += item.full_len
|
||||
|
||||
subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
|
||||
decoded.append({ item.type: subattrs })
|
||||
if attr_spec["sub-type"] == 'nest':
|
||||
subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
|
||||
decoded.append({ item.type: subattrs })
|
||||
else:
|
||||
raise Exception(f'Unknown {attr_spec["sub-type"]} with name {attr_spec["name"]}')
|
||||
return decoded
|
||||
|
||||
def _decode_nest_type_value(self, attr, attr_spec):
|
||||
@@ -733,8 +736,8 @@ class YnlFamily(SpecFamily):
|
||||
decoded = attr.as_scalar(attr_spec['type'], attr_spec.byte_order)
|
||||
if 'enum' in attr_spec:
|
||||
decoded = self._decode_enum(decoded, attr_spec)
|
||||
elif attr_spec["type"] == 'array-nest':
|
||||
decoded = self._decode_array_nest(attr, attr_spec)
|
||||
elif attr_spec["type"] == 'indexed-array':
|
||||
decoded = self._decode_array_attr(attr, attr_spec)
|
||||
elif attr_spec["type"] == 'bitfield32':
|
||||
value, selector = struct.unpack("II", attr.raw)
|
||||
if 'enum' in attr_spec:
|
||||
|
||||
Reference in New Issue
Block a user