[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250904220156.1006541-6-ast@fiberby.net>
Date: Thu, 4 Sep 2025 22:01:29 +0000
From: Asbjørn Sloth Tønnesen <ast@...erby.net>
To: "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>
Cc: Asbjørn Sloth Tønnesen <ast@...erby.net>,
Donald Hunter <donald.hunter@...il.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: [PATCH net-next 06/11] tools: ynl-gen: don't validate nested array attribute types
In nested arrays don't require that the intermediate
attribute type should be a valid attribute type, it
might just be an index or simple 0, it is often not
even used.
See include/net/netlink.h about NLA_NESTED_ARRAY:
> The difference to NLA_NESTED is the structure:
> NLA_NESTED has the nested attributes directly inside
> while an array has the nested attributes at another
> level down and the attribute types directly in the
> nesting don't matter.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@...erby.net>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index e6a84e13ec0a..3c0b158c4da8 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -834,11 +834,12 @@ class TypeArrayNest(Type):
def _attr_get(self, ri, var):
local_vars = ['const struct nlattr *attr2;']
get_lines = [f'attr_{self.c_name} = attr;',
- 'ynl_attr_for_each_nested(attr2, attr) {',
- '\tif (ynl_attr_validate(yarg, attr2))',
- '\t\treturn YNL_PARSE_CB_ERROR;',
- f'\tn_{self.c_name}++;',
- '}']
+ 'ynl_attr_for_each_nested(attr2, attr) {']
+ if self.attr['sub-type'] != 'nest':
+ get_lines.append('\tif (ynl_attr_validate(yarg, attr2))')
+ get_lines.append('\t\treturn YNL_PARSE_CB_ERROR;')
+ get_lines.append(f'\tn_{self.c_name}++;')
+ get_lines.append('}')
return get_lines, None, local_vars
def attr_put(self, ri, var):
--
2.51.0
Powered by blists - more mailing lists