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

Asbjørn Sloth Tønnesen posted 11 patches 4 weeks ago
There is a newer version of this series
[PATCH net-next 03/11] tools: ynl-gen: add sub-type check
Posted by Asbjørn Sloth Tønnesen 4 weeks ago
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 <ast@fiberby.net>
---
 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;']
-- 
2.51.0

Re: [PATCH net-next 03/11] tools: ynl-gen: add sub-type check
Posted by Jacob Keller 3 weeks, 6 days ago

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 <ast@fiberby.net>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>

>  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;']

Re: [PATCH net-next 03/11] tools: ynl-gen: add sub-type check
Posted by Jakub Kicinski 3 weeks, 6 days ago
On Thu,  4 Sep 2025 22:01:26 +0000 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.

I _think_ the expectation was that one of the other methods which
validate the types more thoroughly has to be called if this one is.
But either way:

Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Re: [PATCH net-next 03/11] tools: ynl-gen: add sub-type check
Posted by Donald Hunter 3 weeks, 6 days ago
Asbjørn Sloth Tønnesen <ast@fiberby.net> writes:

> 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 <ast@fiberby.net>

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>