* [PATCH net-next 1/7] netlink: specs: add ignore-index flag for indexed-array
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
@ 2025-10-22 18:26 ` Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 2/7] tools: ynl: support ignore-index in indexed-array decoding Asbjørn Sloth Tønnesen
` (6 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
Add a new YNL attribute `ignore-index` as a way to indicate that a
given indexed-array attribute is really just used as an array, and
hence the nested attribute-type aka. the index is unimportant.
This means that the kernel never uses the index when processing
received netlink messages, and that it doesn't add any additional
information when sent by the kernel.
For backward compatibility reasons the kernel can continue to set
the index to a non-zero value in netlink messages, but it can safely
be disregarded by clients when `ignore-index` is set to true.
When the index is non-zero, it is often just an incremental iterator
value, which provides no additional value, as the order of the array
elements is already known based on the order in the netlink message.
`ignore-index` is not added for the genetlink protocol, as any new
families should use multi-attributes, unless they need the index.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
Documentation/netlink/genetlink-c.yaml | 6 ++++++
Documentation/netlink/genetlink-legacy.yaml | 6 ++++++
Documentation/netlink/netlink-raw.yaml | 6 ++++++
Documentation/userspace-api/netlink/genetlink-legacy.rst | 3 +++
4 files changed, 21 insertions(+)
diff --git a/Documentation/netlink/genetlink-c.yaml b/Documentation/netlink/genetlink-c.yaml
index 5a234e9b5fa2e..5d022772cdb61 100644
--- a/Documentation/netlink/genetlink-c.yaml
+++ b/Documentation/netlink/genetlink-c.yaml
@@ -184,6 +184,12 @@ properties:
nested-attributes:
description: Name of the space (sub-space) used inside the attribute.
type: string
+ ignore-index:
+ description: |
+ The indexed-array is just an array. The index, aka. the
+ nested attribute-type, can be disregarded, as it doesn't
+ contain anything interesting.
+ type: boolean
enum:
description: Name of the enum type used for the attribute.
type: string
diff --git a/Documentation/netlink/genetlink-legacy.yaml b/Documentation/netlink/genetlink-legacy.yaml
index 66fb8653a3442..f7991a3c5e2a3 100644
--- a/Documentation/netlink/genetlink-legacy.yaml
+++ b/Documentation/netlink/genetlink-legacy.yaml
@@ -233,6 +233,12 @@ properties:
nested-attributes:
description: Name of the space (sub-space) used inside the attribute.
type: string
+ ignore-index:
+ description: |
+ The indexed-array is just an array. The index, aka. the
+ nested attribute-type, can be disregarded, as it doesn't
+ contain anything interesting.
+ type: boolean
enum:
description: Name of the enum type used for the attribute.
type: string
diff --git a/Documentation/netlink/netlink-raw.yaml b/Documentation/netlink/netlink-raw.yaml
index 246fa07bccf68..1d2ff5f79cada 100644
--- a/Documentation/netlink/netlink-raw.yaml
+++ b/Documentation/netlink/netlink-raw.yaml
@@ -251,6 +251,12 @@ properties:
nested-attributes:
description: Name of the space (sub-space) used inside the attribute.
type: string
+ ignore-index:
+ description: |
+ The indexed-array is just an array. The index, aka. the
+ nested attribute-type, can be disregarded, as it doesn't
+ contain anything interesting.
+ type: boolean
enum:
description: Name of the enum type used for the attribute.
type: string
diff --git a/Documentation/userspace-api/netlink/genetlink-legacy.rst b/Documentation/userspace-api/netlink/genetlink-legacy.rst
index fa005989193a1..839b0095c9a80 100644
--- a/Documentation/userspace-api/netlink/genetlink-legacy.rst
+++ b/Documentation/userspace-api/netlink/genetlink-legacy.rst
@@ -53,6 +53,9 @@ indexed-array
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.
+When ``ignore-index`` is set to ``true``, then the ``indexed-array`` is
+just an array, and the index can be disregarded.
+
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::
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 2/7] tools: ynl: support ignore-index in indexed-array decoding
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 1/7] netlink: specs: " Asbjørn Sloth Tønnesen
@ 2025-10-22 18:26 ` Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 3/7] tools: ynl: support ignore-index in indexed-array encoding Asbjørn Sloth Tønnesen
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
When decoding indexed-arrays with `ignore-index` set, then
elide the index, aka. the nested attribute-type.
Previously the index was always preserved for sub-type nest,
but was elided for all other sub-types.
I have opted to reuse the existing `subattr` variable, as renaming
it will render the diff unreadable at least for this version.
Output if `rates` does NOT have `ignore-index` set:
$ ./tools/net/ynl/pyynl/cli.py --family nl80211 --dump get-wiphy
[...]
'rates': [{0: {'rate': 60}},
{1: {'rate': 90}},
{2: {'rate': 120}},
{3: {'rate': 180}},
{4: {'rate': 240}},
[...]
Output if `rates` has `ignore-index` set to true:
$ ./tools/net/ynl/pyynl/cli.py --family nl80211 --dump get-wiphy
[...]
'rates': [{'rate': 60},
{'rate': 90},
{'rate': 120},
{'rate': 180},
{'rate': 240},
[...]
If the above example had to be passed back though --json, then it
now aligns with the new output format, and would look like this:
--json '{"rates":[ {"rate":60}, {"rate":90}, ... ]}'
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
tools/net/ynl/pyynl/lib/ynl.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index 62383c70ebb95..14c7e51db6f5c 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -690,23 +690,26 @@ class YnlFamily(SpecFamily):
item = NlAttr(attr.raw, offset)
offset += item.full_len
+ subattr = None
if attr_spec["sub-type"] == 'nest':
- subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
- decoded.append({ item.type: subattrs })
+ subattr = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
elif attr_spec["sub-type"] == 'binary':
subattr = item.as_bin()
if attr_spec.display_hint:
subattr = self._formatted_string(subattr, attr_spec.display_hint)
- decoded.append(subattr)
elif attr_spec["sub-type"] in NlAttr.type_formats:
subattr = item.as_scalar(attr_spec['sub-type'], attr_spec.byte_order)
if 'enum' in attr_spec:
subattr = self._decode_enum(subattr, attr_spec)
elif attr_spec.display_hint:
subattr = self._formatted_string(subattr, attr_spec.display_hint)
- decoded.append(subattr)
else:
raise Exception(f'Unknown {attr_spec["sub-type"]} with name {attr_spec["name"]}')
+
+ if attr_spec.get('ignore-index', False):
+ decoded.append(subattr)
+ else:
+ decoded.append({ item.type: subattr })
return decoded
def _decode_nest_type_value(self, attr, attr_spec):
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 3/7] tools: ynl: support ignore-index in indexed-array encoding
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 1/7] netlink: specs: " Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 2/7] tools: ynl: support ignore-index in indexed-array decoding Asbjørn Sloth Tønnesen
@ 2025-10-22 18:26 ` Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 4/7] netlink: specs: nl80211: set ignore-index on indexed-arrays Asbjørn Sloth Tønnesen
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
When parsing indexed-array attributes to cli.py's --json, then
previously the index would always be set incrementally.
This patch adds support for setting arbitrary indexes, when
`ignore-index` is set to false or is unspecified.
When `ignore-index` is set to true, then it retains the current
input format, and it's alignment with the output from cli.py.
The below examples are fictive as `rates` is not used in requests.
The implementation have been tested with a newer version of the
previously posted wireguard spec[1].
When `rates` have `ignore-index` set to false (or unspecified):
--json '{"rates":[ [0,{"rate":60}], [42,{"rate":90}] ]}'
When `rates` have `ignore-index` set to true:
--json '{"rates":[ {"rate":60}, {"rate":90} ]}'
[1] https://lore.kernel.org/netdev/20250904-wg-ynl-rfc@fiberby.net/
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
tools/net/ynl/pyynl/lib/ynl.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/net/ynl/pyynl/lib/ynl.py b/tools/net/ynl/pyynl/lib/ynl.py
index 14c7e51db6f5c..a284bc2ad3440 100644
--- a/tools/net/ynl/pyynl/lib/ynl.py
+++ b/tools/net/ynl/pyynl/lib/ynl.py
@@ -566,8 +566,9 @@ class YnlFamily(SpecFamily):
elif attr['type'] == 'indexed-array' and attr['sub-type'] == 'nest':
nl_type |= Netlink.NLA_F_NESTED
sub_space = attr['nested-attributes']
+ ignore_idx = attr.get('ignore-index', False)
attr_payload = self._encode_indexed_array(value, sub_space,
- search_attrs)
+ search_attrs, ignore_idx)
elif attr["type"] == 'flag':
if not value:
# If value is absent or false then skip attribute creation.
@@ -635,9 +636,11 @@ class YnlFamily(SpecFamily):
sub_attrs)
return attr_payload
- def _encode_indexed_array(self, vals, sub_space, search_attrs):
+ def _encode_indexed_array(self, vals, sub_space, search_attrs, ignore_idx):
attr_payload = b''
for i, val in enumerate(vals):
+ if not ignore_idx:
+ i, val = val[0], val[1]
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)
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 4/7] netlink: specs: nl80211: set ignore-index on indexed-arrays
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
` (2 preceding siblings ...)
2025-10-22 18:26 ` [PATCH net-next 3/7] tools: ynl: support ignore-index in indexed-array encoding Asbjørn Sloth Tønnesen
@ 2025-10-22 18:26 ` Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 5/7] netlink: specs: nlctrl: " Asbjørn Sloth Tønnesen
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
The indexes in nl80211 indexed-arrays have no special meaning,
they are just written with an iterator index, which refers to
the order in which they have been packed into the netlink message.
Thus this patch sets ignore-index on these attributes.
Most of these are only used for dumping kernel state, and are
never parsed by the kernel.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━┳━━━━━━━━┓
┃ ┃ out/ ┃ input/ ┃ ignore ┃
┃ Attribute ┃ dump ┃ parsed ┃ -index ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━╇━━━━━━━━┩
│ NL80211_ATTR_SUPPORTED_COMMANDS │ 1++ │ - │ yes │
│ NL80211_ATTR_INTERFACE_COMBINATIONS │ 1++ │ - │ yes │
│ NL80211_BAND_ATTR_FREQS │ 0++ │ - │ yes │
│ NL80211_BAND_ATTR_RATES │ 0++ │ - │ yes │
│ NL80211_BAND_ATTR_IFTYPE_DATA │ 1++ │ - │ yes │
│ NL80211_FREQUENCY_ATTR_WMM │ 0++ │ - │ yes │
│ NL80211_IFACE_COMB_LIMITS │ 1++ │ - │ yes │
│ NL80211_SAR_ATTR_SPECS │ 1++ │ yes(2) │ yes │
└─────────────────────────────────────┴──────┴────────┴────────┘
Where:
0++) incrementing index starting from 0
1++) incrementing index starting from 1
2) NL80211_SAR_ATTR_SPECS is parsed in nl80211_set_sar_specs(),
which doesn't use the index. Additionally it also has a
NLA_POLICY_NESTED_ARRAY() policy, as defined in commit
1501d13596b9 ("netlink: add nested array policy validation"),
meaning that the index has no meaning, and can be disregarded.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
Documentation/netlink/specs/nl80211.yaml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/Documentation/netlink/specs/nl80211.yaml b/Documentation/netlink/specs/nl80211.yaml
index 802097128bdae..b93c612037e26 100644
--- a/Documentation/netlink/specs/nl80211.yaml
+++ b/Documentation/netlink/specs/nl80211.yaml
@@ -390,6 +390,7 @@ attribute-sets:
name: supported-commands
type: indexed-array
sub-type: u32
+ ignore-index: true
enum: commands
-
name: frame
@@ -608,6 +609,7 @@ attribute-sets:
name: interface-combinations
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: if-combination-attributes
-
name: software-iftypes
@@ -1307,11 +1309,13 @@ attribute-sets:
name: freqs
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: frequency-attrs
-
name: rates
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: bitrate-attrs
-
name: ht-mcs-set
@@ -1335,6 +1339,7 @@ attribute-sets:
name: iftype-data
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: iftype-data-attrs
-
name: edmg-channels
@@ -1418,6 +1423,7 @@ attribute-sets:
name: wmm
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: wmm-attrs
-
name: no-he
@@ -1474,6 +1480,7 @@ attribute-sets:
name: limits
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: iface-limit-attributes
-
name: maxnum
@@ -1613,6 +1620,7 @@ attribute-sets:
name: specs
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: sar-specs
-
name: sar-specs
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 5/7] netlink: specs: nlctrl: set ignore-index on indexed-arrays
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
` (3 preceding siblings ...)
2025-10-22 18:26 ` [PATCH net-next 4/7] netlink: specs: nl80211: set ignore-index on indexed-arrays Asbjørn Sloth Tønnesen
@ 2025-10-22 18:26 ` Asbjørn Sloth Tønnesen
2025-10-22 18:26 ` [PATCH net-next 6/7] netlink: specs: rt-link: " Asbjørn Sloth Tønnesen
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
The indexes in nlctrl indexed-arrays have no special meaning,
they are just written with an iterator index, which refers to
the order in which they have been packed into the netlink message.
Thus this patch sets ignore-index on these attributes.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━┳━━━━━━━━┓
┃ ┃ out/ ┃ input/ ┃ ignore ┃
┃ Attribute ┃ dump ┃ parsed ┃ -index ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━╇━━━━━━━━┩
│ CTRL_ATTR_OPS │ 1++ │ - │ yes │
│ CTRL_ATTR_MCAST_GROUPS │ 1++ │ - │ yes │
└─────────────────────────────────────┴──────┴────────┴────────┘
Where:
1++) incrementing index starting from 1
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
Documentation/netlink/specs/nlctrl.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/netlink/specs/nlctrl.yaml b/Documentation/netlink/specs/nlctrl.yaml
index 8b4472a6aa36a..753cf1b48c252 100644
--- a/Documentation/netlink/specs/nlctrl.yaml
+++ b/Documentation/netlink/specs/nlctrl.yaml
@@ -67,11 +67,13 @@ attribute-sets:
name: ops
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: op-attrs
-
name: mcast-groups
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: mcast-group-attrs
-
name: policy
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 6/7] netlink: specs: rt-link: set ignore-index on indexed-arrays
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
` (4 preceding siblings ...)
2025-10-22 18:26 ` [PATCH net-next 5/7] netlink: specs: nlctrl: " Asbjørn Sloth Tønnesen
@ 2025-10-22 18:26 ` Asbjørn Sloth Tønnesen
2025-10-22 18:27 ` [PATCH net-next 7/7] netlink: specs: tc: " Asbjørn Sloth Tønnesen
2025-10-23 1:45 ` [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Jakub Kicinski
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:26 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
Most of the indexes in rt-link indexed-arrays have no special meaning,
they are just written with an iterator index, which refers to the
order in which they have been packed into the netlink message.
Thus this patch sets ignore-index on these two attributes.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━┳━━━━━━━━┳━━━━━━━━┓
┃ ┃ out/ ┃ input/ ┃ ignore ┃
┃ Attribute ┃ dump ┃ parsed ┃ -index ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━╇━━━━━━━━╇━━━━━━━━┩
│ IFLA_BOND_ARP_IP_TARGET │ 0++ │ yes(1) │ yes │
│ IFLA_BOND_NS_IP6_TARGET │ 0++ │ yes(1) │ yes │
│ IFLA_OFFLOAD_XSTATS_HW_S_INFO │ (2) │ - │ no │
└─────────────────────────────────────┴──────┴────────┴────────┘
Where:
0++) incrementing index starting from 0
1) When parsed the index is unused.
2) IFLA_OFFLOAD_XSTATS_L3_STATS is used as index in
rtnl_offload_xstats_fill_hw_s_info().
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
Documentation/netlink/specs/rt-link.yaml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Documentation/netlink/specs/rt-link.yaml b/Documentation/netlink/specs/rt-link.yaml
index 2a23e9699c0b6..d2aaacd29f9f9 100644
--- a/Documentation/netlink/specs/rt-link.yaml
+++ b/Documentation/netlink/specs/rt-link.yaml
@@ -1256,6 +1256,7 @@ attribute-sets:
name: arp-ip-target
type: indexed-array
sub-type: u32
+ ignore-index: true
byte-order: big-endian
display-hint: ipv4
-
@@ -1330,6 +1331,7 @@ attribute-sets:
name: ns-ip6-target
type: indexed-array
sub-type: binary
+ ignore-index: true
display-hint: ipv6
checks:
exact-len: 16
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net-next 7/7] netlink: specs: tc: set ignore-index on indexed-arrays
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
` (5 preceding siblings ...)
2025-10-22 18:26 ` [PATCH net-next 6/7] netlink: specs: rt-link: " Asbjørn Sloth Tønnesen
@ 2025-10-22 18:27 ` Asbjørn Sloth Tønnesen
2025-10-23 1:45 ` [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Jakub Kicinski
7 siblings, 0 replies; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-22 18:27 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Asbjørn Sloth Tønnesen, Chia-Yu Chang, Chuck Lever,
Donald Hunter, Jonathan Corbet, Matthieu Baerts (NGI0),
Simon Horman, linux-doc, linux-kernel, netdev
The indexes in tc indexed-arrays are mostly used for defining
the priority winin an array of actions, and when parsed by the
kernel they must be unique, and not exceed TCA_ACT_MAX_PRIO (32).
Therefore this patch only sets ignore-index on a single
attribute TCA_CAKE_STATS_TIN_STATS, which is only used for
dumping statistics, and never ingested by the kernel.
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━┳━━━━━━━━┳━━━━━━━━┓
┃ ┃ out/ ┃ input/ ┃ ignore ┃
┃ Attribute ┃ dump ┃ parsed ┃ -index ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━╇━━━━━━━━╇━━━━━━━━┩
│ TCA_BASIC_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_BPF_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_CAKE_STATS_TIN_STATS │ 1++ (4) │ - │ yes │
│ TCA_CGROUP_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_FLOWER_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_FW_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_MATCHALL_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_ROUTE4_ACT │ 1++ (2) │ yes(3) │ no │
│ TCA_U32_ACT │ 1++ (2) │ yes(3) │ no │
└──────────────────────────────────┴─────────┴────────┴────────┘
Where:
1++) incrementing index starting from 1
2) All _ACT are dumped with tcf_exts_dump() calling tcf_action_dump().
3) Parsed in tcf_action_init().
4) Dumped in cake_dump_stats().
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
Documentation/netlink/specs/tc.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index b398f7a46dae1..24866fccb7d15 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -2188,6 +2188,7 @@ attribute-sets:
name: tin-stats
type: indexed-array
sub-type: nest
+ ignore-index: true
nested-attributes: cake-tin-stats-attrs
-
name: deficit
--
2.51.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array
2025-10-22 18:26 [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Asbjørn Sloth Tønnesen
` (6 preceding siblings ...)
2025-10-22 18:27 ` [PATCH net-next 7/7] netlink: specs: tc: " Asbjørn Sloth Tønnesen
@ 2025-10-23 1:45 ` Jakub Kicinski
2025-10-23 18:37 ` Asbjørn Sloth Tønnesen
7 siblings, 1 reply; 13+ messages in thread
From: Jakub Kicinski @ 2025-10-23 1:45 UTC (permalink / raw)
To: Asbjørn Sloth Tønnesen
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Chia-Yu Chang,
Chuck Lever, Donald Hunter, Jonathan Corbet,
Matthieu Baerts (NGI0), Simon Horman, linux-doc, linux-kernel,
netdev
On Wed, 22 Oct 2025 18:26:53 +0000 Asbjørn Sloth Tønnesen wrote:
> This patchset adds a way to mark if an indedex array is just an
> array, and the index is uninteresting, as previously discussed[1].
>
> Which is the case in most of the indexed-arrays in the current specs.
>
> As the name indexed-array kinda implies that the index is interesting,
> then I am using `ignore-index` to mark if the index is unused.
>
> This adds some noise to YNL, and as it's only few indexed-arrays which
> actually use the index, then if we can come up with some good naming,
> it may be better to reverse it so it's the default behaviour.
C code already does this, right? We just collect the attributes
completely ignoring the index. So why do we need to extend the
spec.
Have you found any case where the index matters and can be
non-contiguous (other than the known TC kerfuffle).
FWIW another concept is what TypeValue does.
"Inject" the index into the child nest as an extra member.
Most flexible but also prolly a PITA for user space to init those
for requests.
^ permalink raw reply [flat|nested] 13+ messages in thread* Re: [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array
2025-10-23 1:45 ` [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array Jakub Kicinski
@ 2025-10-23 18:37 ` Asbjørn Sloth Tønnesen
2025-10-24 0:03 ` Jakub Kicinski
0 siblings, 1 reply; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-23 18:37 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Chia-Yu Chang,
Chuck Lever, Donald Hunter, Jonathan Corbet,
Matthieu Baerts (NGI0), Simon Horman, linux-doc, linux-kernel,
netdev
On 10/23/25 1:45 AM, Jakub Kicinski wrote:
> On Wed, 22 Oct 2025 18:26:53 +0000 Asbjørn Sloth Tønnesen wrote:
>> This patchset adds a way to mark if an indedex array is just an
>> array, and the index is uninteresting, as previously discussed[1].
>>
>> Which is the case in most of the indexed-arrays in the current specs.
>>
>> As the name indexed-array kinda implies that the index is interesting,
>> then I am using `ignore-index` to mark if the index is unused.
>>
>> This adds some noise to YNL, and as it's only few indexed-arrays which
>> actually use the index, then if we can come up with some good naming,
>> it may be better to reverse it so it's the default behaviour.
>
> C code already does this, right? We just collect the attributes
> completely ignoring the index.
In the userspace C code, for sub-type nest the index is preserved
in struct member idx, and elided for other sub-types.
> So why do we need to extend the spec.
For me it's mostly the naming "indexed-array". Earlier it was
"array-nest", then we renamed it to "indexed-array" because
it doesn't always contain nests. I think it's counter-intuitive
to elide the index by default, for something called "indexed-array".
The majority of the families using it don't care about the index.
What if we called it "ordered-array", and then always counted from 1
(for families that cares) when packing in user-space code?
> Have you found any case where the index matters and can be
> non-contiguous (other than the known TC kerfuffle).
IFLA_OFFLOAD_XSTATS_HW_S_INFO could be re-defined as a nest,
IFLA_OFFLOAD_XSTATS_L3_STATS is the only index atm.
IFLA_INET_CONF / IFLA_INET6_CONF is on input, but those are
also special by having different types depending on direction.
I found a bunch of other ones, using a static index, but they
can also be defined as a multi-attr wrapped in an additional
outer nest, like IFLA_VF_VLAN_LIST already is.
> FWIW another concept is what TypeValue does.
> "Inject" the index into the child nest as an extra member.
> Most flexible but also prolly a PITA for user space to init those
> for requests.
Same as is done in the userspace C code for indexed-arrays with
sub-type nest. For most families it doesn't matter if the C code
inits the index or not.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array
2025-10-23 18:37 ` Asbjørn Sloth Tønnesen
@ 2025-10-24 0:03 ` Jakub Kicinski
2025-10-24 19:19 ` Asbjørn Sloth Tønnesen
0 siblings, 1 reply; 13+ messages in thread
From: Jakub Kicinski @ 2025-10-24 0:03 UTC (permalink / raw)
To: Asbjørn Sloth Tønnesen
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Chia-Yu Chang,
Chuck Lever, Donald Hunter, Jonathan Corbet,
Matthieu Baerts (NGI0), Simon Horman, linux-doc, linux-kernel,
netdev
On Thu, 23 Oct 2025 18:37:09 +0000 Asbjørn Sloth Tønnesen wrote:
> > C code already does this, right? We just collect the attributes
> > completely ignoring the index.
>
> In the userspace C code, for sub-type nest the index is preserved
> in struct member idx, and elided for other sub-types.
I see it now, I guess I added it for get but forgot to obey it
for put :(
> > So why do we need to extend the spec.
>
> For me it's mostly the naming "indexed-array". Earlier it was
> "array-nest", then we renamed it to "indexed-array" because
> it doesn't always contain nests. I think it's counter-intuitive
> to elide the index by default, for something called "indexed-array".
> The majority of the families using it don't care about the index.
>
> What if we called it "ordered-array", and then always counted from 1
> (for families that cares) when packing in user-space code?
>
> > Have you found any case where the index matters and can be
> > non-contiguous (other than the known TC kerfuffle).
>
> IFLA_OFFLOAD_XSTATS_HW_S_INFO could be re-defined as a nest,
> IFLA_OFFLOAD_XSTATS_L3_STATS is the only index atm.
Isn't that pretty much always true? If the index is significant
the whole thing could be redefined as a nest, with names provided
in the spec?
> IFLA_INET_CONF / IFLA_INET6_CONF is on input, but those are
> also special by having different types depending on direction.
>
> I found a bunch of other ones, using a static index, but they
> can also be defined as a multi-attr wrapped in an additional
> outer nest, like IFLA_VF_VLAN_LIST already is.
Multi-attr with an outer nest should at least solve your wg problem
I guess? If all the attrs have type of 0 we can make it a multi-attr.
> > FWIW another concept is what TypeValue does.
> > "Inject" the index into the child nest as an extra member.
> > Most flexible but also prolly a PITA for user space to init those
> > for requests.
>
> Same as is done in the userspace C code for indexed-arrays with
> sub-type nest. For most families it doesn't matter if the C code
> inits the index or not.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array
2025-10-24 0:03 ` Jakub Kicinski
@ 2025-10-24 19:19 ` Asbjørn Sloth Tønnesen
2025-10-24 23:52 ` Jakub Kicinski
0 siblings, 1 reply; 13+ messages in thread
From: Asbjørn Sloth Tønnesen @ 2025-10-24 19:19 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Chia-Yu Chang,
Chuck Lever, Donald Hunter, Jonathan Corbet,
Matthieu Baerts (NGI0), Simon Horman, linux-doc, linux-kernel,
netdev, Jason A. Donenfeld, Zahari Doychev
On 10/24/25 12:03 AM, Jakub Kicinski wrote:
> On Thu, 23 Oct 2025 18:37:09 +0000 Asbjørn Sloth Tønnesen wrote:
>> > C code already does this, right? We just collect the attributes
>> > completely ignoring the index.
>>
>> In the userspace C code, for sub-type nest the index is preserved
>> in struct member idx, and elided for other sub-types.
>
> I see it now, I guess I added it for get but forgot to obey it
> for put :(
I can fix that up in v2.
Do we wanna do the same for sub-type nest in the python client?
>> > So why do we need to extend the spec.
>>
>> For me it's mostly the naming "indexed-array". Earlier it was
>> "array-nest", then we renamed it to "indexed-array" because
>> it doesn't always contain nests. I think it's counter-intuitive
>> to elide the index by default, for something called "indexed-array".
>> The majority of the families using it don't care about the index.
>>
>> What if we called it "ordered-array", and then always counted from 1
>> (for families that cares) when packing in user-space code?
>>
>> > Have you found any case where the index matters and can be
>> > non-contiguous (other than the known TC kerfuffle).
>>
>> IFLA_OFFLOAD_XSTATS_HW_S_INFO could be re-defined as a nest,
>> IFLA_OFFLOAD_XSTATS_L3_STATS is the only index atm.
>
> Isn't that pretty much always true? If the index is significant
> the whole thing could be redefined as a nest, with names provided
> in the spec?
I guess it depends on the range of indexes, the aboveIFLA_OFFLOAD_XSTATS_L3_STATS is aka. 3, so the new nest policy would be
(0..2 = unused, 3 = .._L3_STATS}, which is fine, but for higher indexes
it might get a bit silly, but I haven't found any too high indexes.
NLBL_CIPSOV4_A_MLSCATLST has NLBL_CIPSOV4_A_MLSCAT which is 11, but that
corner seams very dusty, so I don't expect that to get YNL support.
Nest + multi-attr is great for the cases where we want per-attr typing,
like IFLA_PROP_LIST / IFLA_ALT_IFNAME, but a bit awkward if they all
are nests with the same policy.
>> IFLA_INET_CONF / IFLA_INET6_CONF is on input, but those are
>> also special by having different types depending on direction.
>>
>> I found a bunch of other ones, using a static index, but they
>> can also be defined as a multi-attr wrapped in an additional
>> outer nest, like IFLA_VF_VLAN_LIST already is.
>
> Multi-attr with an outer nest should at least solve your wg problem
> I guess? If all the attrs have type of 0 we can make it a multi-attr.
WG don't use the index, so it's fine with incrementing from 1.
Converting it to nest + multi-attr would require extra pollution in
the UAPI, so I don't think I can get that past Jason. It would also be
hard to shove in between the elements in the existing naming.
I am just trying to get the nits that came up in the previous discussions
handled, so they are fixed when I submit the WG spec again, so that I
don't have to go back and update it shortly after, as the WG/Jason
bandwidth seams pretty limited atm.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH net-next 0/7] ynl: add ignore-index flag for indexed-array
2025-10-24 19:19 ` Asbjørn Sloth Tønnesen
@ 2025-10-24 23:52 ` Jakub Kicinski
0 siblings, 0 replies; 13+ messages in thread
From: Jakub Kicinski @ 2025-10-24 23:52 UTC (permalink / raw)
To: Asbjørn Sloth Tønnesen
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Chia-Yu Chang,
Chuck Lever, Donald Hunter, Jonathan Corbet,
Matthieu Baerts (NGI0), Simon Horman, linux-doc, linux-kernel,
netdev, Jason A. Donenfeld, Zahari Doychev
On Fri, 24 Oct 2025 19:19:10 +0000 Asbjørn Sloth Tønnesen wrote:
> Do we wanna do the same for sub-type nest in the python client?
> as the WG/Jason bandwidth seams pretty limited atm.
Please focus on what's needed to get WG implemented.
My "bandwidth" for pondering cleanups that may not matter in practice
is also limited. Main goal for YNL is new families. Polishing the old
stuff is a huge time sink.
^ permalink raw reply [flat|nested] 13+ messages in thread