From: Asbjørn Sloth Tønnesen Date: Mon, 15 Sep 2025 14:42:47 +0000 (+0000) Subject: tools: ynl-gen: generate nested array policies X-Git-Tag: v6.18-rc1~132^2~152^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d0bdfe36d77791a67f18d18e93f3fca9a2b10240;p=thirdparty%2Flinux.git 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 Reviewed-by: Donald Hunter Reviewed-by: Jakub Kicinski Link: https://patch.msgid.link/20250915144301.725949-3-ast@fiberby.net Signed-off-by: Jakub Kicinski --- diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py index 498cfeee443e5..08c727c064cf0 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:])}, '