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: <20251106151529.453026-4-zahari.doychev@linux.com>
Date: Thu,  6 Nov 2025 16:15:29 +0100
From: Zahari Doychev <zahari.doychev@...ux.com>
To: donald.hunter@...il.com,
	kuba@...nel.org
Cc: davem@...emloft.net,
	edumazet@...gle.com,
	pabeni@...hat.com,
	horms@...nel.org,
	jacob.e.keller@...el.com,
	ast@...erby.net,
	matttbe@...nel.org,
	netdev@...r.kernel.org,
	jhs@...atatu.com,
	xiyou.wangcong@...il.com,
	jiri@...nulli.us,
	johannes@...solutions.net,
	zahari.doychev@...ux.com
Subject: [PATCH v2 3/3] tools: ynl: ignore index 0 for indexed-arrays

Linux tc actions expect the action order to start from index one.
To accommodate this, update the code generation so array indexing
begins at 1 for tc actions.

This results in the following change:

        array = ynl_attr_nest_start(nlh, TCA_FLOWER_ACT);
        for (i = 0; i < obj->_count.act; i++)
-               tc_act_attrs_put(nlh, i, &obj->act[i]);
+               tc_act_attrs_put(nlh, i + 1, &obj->act[i]);
        ynl_attr_nest_end(nlh, array);

This change does not impact other indexed array attributes at
the moment, as analyzed in [1].

[1]: https://lore.kernel.org/netdev/20251022182701.250897-1-ast@fiberby.net/

Signed-off-by: Zahari Doychev <zahari.doychev@...ux.com>
---
 Documentation/netlink/specs/tc.yaml | 8 ++++++++
 tools/net/ynl/pyynl/ynl_gen_c.py    | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/netlink/specs/tc.yaml b/Documentation/netlink/specs/tc.yaml
index b398f7a46dae..3e3da477dd5d 100644
--- a/Documentation/netlink/specs/tc.yaml
+++ b/Documentation/netlink/specs/tc.yaml
@@ -2044,6 +2044,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: police
         type: nest
@@ -2064,6 +2065,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: police
         type: nest
@@ -2303,6 +2305,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: police
         type: nest
@@ -2493,6 +2496,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: key-eth-dst
         type: binary
@@ -3020,6 +3024,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: mask
         type: u32
@@ -3180,6 +3185,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: flags
         type: u32
@@ -3566,6 +3572,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
   -
     name: taprio-attrs
     name-prefix: tca-taprio-attr-
@@ -3798,6 +3805,7 @@ attribute-sets:
         type: indexed-array
         sub-type: nest
         nested-attributes: act-attrs
+        doc: Index 0 is ignored and array starts from index 1.
       -
         name: indev
         type: string
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index aadeb3abcad8..d01ef8fa5497 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -852,7 +852,7 @@ class TypeIndexedArray(Type):
             ri.cw.p(f"ynl_attr_put(nlh, i, {var}->{self.c_name}[i], {self.checks['exact-len']});")
         elif self.sub_type == 'nest':
             ri.cw.p(f'for (i = 0; i < {var}->_count.{self.c_name}; i++)')
-            ri.cw.p(f"{self.nested_render_name}_put(nlh, i, &{var}->{self.c_name}[i]);")
+            ri.cw.p(f"{self.nested_render_name}_put(nlh, i + 1, &{var}->{self.c_name}[i]);")
         else:
             raise Exception(f"Put for IndexedArray sub-type {self.attr['sub-type']} not supported, yet")
         ri.cw.p('ynl_attr_nest_end(nlh, array);')
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ