aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHangbin Liu <liuhangbin@gmail.com>2024-04-04 14:31:12 +0800
committerJakub Kicinski <kuba@kernel.org>2024-04-05 22:32:49 -0700
commitaa6485d813ad6d884d23e1e9cf3913be29a1f229 (patch)
tree673695b5e1b1500a49b331b4476d23c81fb6a77f
parentf410cbea9f3d2675b4c8e52af1d1985b11b387d1 (diff)
downloadnet-next-aa6485d813ad6d884d23e1e9cf3913be29a1f229.tar.gz
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>
-rw-r--r--Documentation/netlink/genetlink-c.yaml2
-rw-r--r--Documentation/netlink/genetlink-legacy.yaml2
-rw-r--r--Documentation/netlink/genetlink.yaml2
-rw-r--r--Documentation/netlink/netlink-raw.yaml2
-rw-r--r--Documentation/netlink/specs/nlctrl.yaml6
-rw-r--r--Documentation/netlink/specs/rt_link.yaml3
-rw-r--r--Documentation/netlink/specs/tc.yaml21
-rw-r--r--Documentation/userspace-api/netlink/genetlink-legacy.rst12
-rw-r--r--tools/net/ynl/lib/ynl.py13
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py18
10 files changed, 53 insertions, 28 deletions
diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml
index 4dfd899a1661ce..4f803eaac6d8ba 100644
--- a/Documentation/netlink/genetlink-c.yaml
+++ b/Documentation/netlink/genetlink-c.yaml
@@ -158,7 +158,7 @@ properties:
type: &attr-type
enum: [ unused, pad, flag, binary,
uint, sint, u8, u16, u32, u64, s32, s64,
- string, nest, array-nest, nest-type-value ]
+ string, nest, indexed-array, nest-type-value ]
doc:
description: Documentation of the attribute.
type: string
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index b48ad3b1cc32e2..8db0e22fa72c7a 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -201,7 +201,7 @@ properties:
description: The netlink attribute type
enum: [ unused, pad, flag, binary, bitfield32,
uint, sint, u8, u16, u32, u64, s32, s64,
- string, nest, array-nest, nest-type-value ]
+ string, nest, indexed-array, nest-type-value ]
doc:
description: Documentation of the attribute.
type: string
diff --git a/Documentation/netlink/genetlink.yaml b/Documentation/netlink/genetlink.yaml
index ebd6ee743fccc2..b036227b46f1ba 100644
--- a/Documentation/netlink/genetlink.yaml
+++ b/Documentation/netlink/genetlink.yaml
@@ -124,7 +124,7 @@ properties:
type: &attr-type
enum: [ unused, pad, flag, binary,
uint, sint, u8, u16, u32, u64, s32, s64,
- string, nest, array-nest, nest-type-value ]
+ string, nest, indexed-array, nest-type-value ]
doc:
description: Documentation of the attribute.
type: string
diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
index a76e54cbadbc44..914aa1c0a27364 100644
--- a/Documentation/netlink/netlink-raw.yaml
+++ b/Documentation/netlink/netlink-raw.yaml
@@ -222,7 +222,7 @@ properties:
description: The netlink attribute type
enum: [ unused, pad, flag, binary, bitfield32,
u8, u16, u32, u64, s8, s16, s32, s64,
- string, nest, array-nest, nest-type-value,
+ string, nest, indexed-array, nest-type-value,
sub-message ]
doc:
description: Documentation of the attribute.
diff --git a/Documentation/netlink/specs/nlctrl.yaml b/Documentation/netlink/specs/nlctrl.yaml
index b1632b95f725fe..a36535350bdb23 100644
--- a/Documentation/netlink/specs/nlctrl.yaml
+++ b/Documentation/netlink/specs/nlctrl.yaml
@@ -65,11 +65,13 @@ attribute-sets:
type: u32
-
name: ops
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: op-attrs
-
name: mcast-groups
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: mcast-group-attrs
-
name: policy
diff --git a/Documentation/netlink/specs/rt_link.yaml b/Documentation/netlink/specs/rt_link.yaml
index 81a5a3d1b04d95..e5dcb2cf1724f5 100644
--- a/Documentation/netlink/specs/rt_link.yaml
+++ b/Documentation/netlink/specs/rt_link.yaml
@@ -1690,7 +1690,8 @@ attribute-sets:
type: binary
-
name: hw-s-info
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: hw-s-info-one
-
name: l3-stats
diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index 6068c105c5ee2a..8c01e4e1319543 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -1988,7 +1988,8 @@ attribute-sets:
nested-attributes: tc-ematch-attrs
-
name: act
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-act-attrs
-
name: police
@@ -2128,7 +2129,8 @@ attribute-sets:
type: u32
-
name: tin-stats
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-cake-tin-stats-attrs
-
name: deficit
@@ -2348,7 +2350,8 @@ attribute-sets:
type: string
-
name: act
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-act-attrs
-
name: key-eth-dst
@@ -2849,7 +2852,8 @@ attribute-sets:
type: string
-
name: act
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-act-attrs
-
name: mask
@@ -3002,7 +3006,8 @@ attribute-sets:
type: u32
-
name: act
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-act-attrs
-
name: flags
@@ -3375,7 +3380,8 @@ attribute-sets:
nested-attributes: tc-police-attrs
-
name: act
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-act-attrs
-
name: tc-taprio-attrs
@@ -3593,7 +3599,8 @@ attribute-sets:
nested-attributes: tc-police-attrs
-
name: act
- type: array-nest
+ type: indexed-array
+ sub-type: nest
nested-attributes: tc-act-attrs
-
name: indev
diff --git a/Documentation/userspace-api/netlink/genetlink-legacy.rst b/Documentation/userspace-api/netlink/genetlink-legacy.rst
index 70a77387f6c431..54e8fb25e09309 100644
--- a/Documentation/userspace-api/netlink/genetlink-legacy.rst
+++ b/Documentation/userspace-api/netlink/genetlink-legacy.rst
@@ -46,10 +46,16 @@ For reference the ``multi-attr`` array may look like this::
where ``ARRAY-ATTR`` is the array entry type.
-array-nest
-~~~~~~~~~~
+indexed-array
+~~~~~~~~~~~~~
+
+``indexed-array`` wraps the entire array in an extra attribute (hence
+limiting its size to 64kB). The ``ENTRY`` nests are special and have the
+index of the entry as their type instead of normal attribute type.
-``array-nest`` creates the following structure::
+A ``sub-type`` is needed to describe what type in the ``ENTRY``. A ``nest``
+``sub-type`` means there are nest arrays in the ``ENTRY``, with the structure
+looks like::
[SOME-OTHER-ATTR]
[ARRAY-ATTR]
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index b30210f537f76d..d671efea808a3e 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -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:
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index a451cbfbd781d9..c0b90c104d92d7 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -841,8 +841,11 @@ class AttrSet(SpecAttrSet):
t = TypeBitfield32(self.family, self, elem, value)
elif elem['type'] == 'nest':
t = TypeNest(self.family, self, elem, value)
- elif elem['type'] == 'array-nest':
- t = TypeArrayNest(self.family, self, elem, value)
+ elif elem['type'] == 'indexed-array' and 'sub-type' in elem:
+ if elem["sub-type"] == 'nest':
+ t = TypeArrayNest(self.family, self, elem, value)
+ else:
+ raise Exception(f'new_attr: unsupported sub-type {elem["sub-type"]}')
elif elem['type'] == 'nest-type-value':
t = TypeNestTypeValue(self.family, self, elem, value)
else:
@@ -1055,7 +1058,7 @@ class Family(SpecFamily):
if nested in self.root_sets:
raise Exception("Inheriting members to a space used as root not supported")
inherit.update(set(spec['type-value']))
- elif spec['type'] == 'array-nest':
+ elif spec['type'] == 'indexed-array':
inherit.add('idx')
self.pure_nested_structs[nested].set_inherited(inherit)
@@ -1619,9 +1622,12 @@ def _multi_parse(ri, struct, init_lines, local_vars):
multi_attrs = set()
needs_parg = False
for arg, aspec in struct.member_list():
- if aspec['type'] == 'array-nest':
- local_vars.append(f'const struct nlattr *attr_{aspec.c_name};')
- array_nests.add(arg)
+ if aspec['type'] == 'indexed-array' and 'sub-type' in aspec:
+ if aspec["sub-type"] == 'nest':
+ local_vars.append(f'const struct nlattr *attr_{aspec.c_name};')
+ array_nests.add(arg)
+ else:
+ raise Exception(f'Not supported sub-type {aspec["sub-type"]}')
if 'multi-attr' in aspec:
multi_attrs.add(arg)
needs_parg |= 'nested-attributes' in aspec