diff options
| author | Asbjørn Sloth Tønnesen <ast@fiberby.net> | 2025-09-15 17:42:47 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2025-09-16 18:15:48 +0300 |
| commit | d0bdfe36d77791a67f18d18e93f3fca9a2b10240 (patch) | |
| tree | eedb3b6c518cf4084b492bbf8d096ed6276989e8 /tools/net/ynl/pyynl/ynl_gen_c.py | |
| parent | 3ff5258b97813d83c12ad80b42a0c40f74dfb06b (diff) | |
| download | linux-d0bdfe36d77791a67f18d18e93f3fca9a2b10240.tar.xz | |
tools: ynl-gen: generate nested array policies
This patch adds support for NLA_POLICY_NESTED_ARRAY() policies.
Example spec (from future wireguard.yaml):
-
name: wgpeer
attributes:
-
name: allowedips
type: indexed-array
sub-type: nest
nested-attributes: wgallowedip
yields NLA_POLICY_NESTED_ARRAY(wireguard_wgallowedip_nl_policy).
This doesn't change any currently generated code, as it isn't
used in any specs currently used for generating code.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250915144301.725949-3-ast@fiberby.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net/ynl/pyynl/ynl_gen_c.py')
| -rwxr-xr-x | tools/net/ynl/pyynl/ynl_gen_c.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py index 498cfeee443e..08c727c064cf 100755 --- a/tools/net/ynl/pyynl/ynl_gen_c.py +++ b/tools/net/ynl/pyynl/ynl_gen_c.py @@ -815,6 +815,11 @@ class TypeArrayNest(Type): f'unsigned int n_{self.c_name}'] return super().arg_member(ri) + def _attr_policy(self, policy): + if self.attr['sub-type'] == 'nest': + return f'NLA_POLICY_NESTED_ARRAY({self.nested_render_name}_nl_policy)' + return super()._attr_policy(policy) + def _attr_typol(self): if self.attr['sub-type'] in scalars: return f'.type = YNL_PT_U{c_upper(self.sub_type[1:])}, ' |
