Re: [PATCH net-next 03/11] tools: ynl-gen: add sub-type check

Jacob Keller <[email protected]>
Newsgroups com.zx2c4.lists.wireguard,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>

On 9/4/2025 3:01 PM, Asbjørn Sloth Tønnesen wrote:
> 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: Asbjørn Sloth Tønnesen <[email protected]>
> ---

Reviewed-by: Jacob Keller <[email protected]>

>  tools/net/ynl/pyynl/ynl_gen_c.py | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
> index b7de7f6b1fc7..04c26ed92ca3 100755
> --- a/tools/net/ynl/pyynl/ynl_gen_c.py
> +++ b/tools/net/ynl/pyynl/ynl_gen_c.py
> @@ -826,8 +826,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;']
OpenPGP_signature.asc (application/pgp-signature, 236 B)
-----BEGIN PGP SIGNATURE-----

wnsEABYIACMWIQQgQFSp1zOQVirsQx5qll0+bw8o6AUCaLt+RQUDAAAAAAAKCRBqll0+bw8o6K01
AQCQwa+JtY6oKMlqWxZw4outY+JhHg/fhOxj3Q32hP3erQEAy9z8JOiWcvhvFwt0EDtWq8gDrm9a
9pr3NnEMrT+LjQk=
=uDnL
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.