Commit 8df78d97 authored by Asbjørn Sloth Tønnesen's avatar Asbjørn Sloth Tønnesen Committed by Jakub Kicinski
Browse files

tools: ynl-gen: add sub-type check



Add a check to verify that the sub-type is "nest", and throw an
exception if no policy could be generated, as a guard to prevent
against generating a bad policy.

This is a trivial patch with no behavioural changes intended.

Signed-off-by: default avatarAsbjørn Sloth Tønnesen <ast@fiberby.net>
Reviewed-by: default avatarDonald Hunter <donald.hunter@gmail.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Reviewed-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Link: https://patch.msgid.link/20250915144301.725949-4-ast@fiberby.net


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent d0bdfe36
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -825,8 +825,10 @@ class TypeArrayNest(Type):
            return f'.type = YNL_PT_U{c_upper(self.sub_type[1:])}, '
        elif self.attr['sub-type'] == 'binary' and 'exact-len' in self.checks:
            return f'.type = YNL_PT_BINARY, .len = {self.checks["exact-len"]}, '
        else:
        elif self.attr['sub-type'] == 'nest':
            return f'.type = YNL_PT_NEST, .nest = &{self.nested_render_name}_nest, '
        else:
            raise Exception(f"Typol for ArrayNest sub-type {self.attr['sub-type']} not supported, yet")

    def _attr_get(self, ri, var):
        local_vars = ['const struct nlattr *attr2;']