[PATCH net-next v2 2/3] tools: ynl-gen: use macro for binary min-len check

Asbjørn Sloth Tønnesen posted 3 patches 1 month ago
[PATCH net-next v2 2/3] tools: ynl-gen: use macro for binary min-len check
Posted by Asbjørn Sloth Tønnesen 1 month ago
This patch changes the generated min-len check for binary
attributes to use the NLA_POLICY_MIN_LEN() macro, thereby the
generated code supports strict policy validation.

With this change TypeBinary will always generate a NLA_BINARY
attribute 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>
---
 tools/net/ynl/pyynl/ynl_gen_c.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index ef032e17fec44..52f955ed84a7f 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -556,7 +556,7 @@ class TypeBinary(Type):
         elif 'exact-len' in self.checks:
             mem = 'NLA_POLICY_EXACT_LEN(' + self.get_limit_str('exact-len') + ')'
         elif 'min-len' in self.checks:
-            mem = '{ .len = ' + self.get_limit_str('min-len') + ', }'
+            mem = 'NLA_POLICY_MIN_LEN(' + self.get_limit_str('min-len') + ')'
         elif 'max-len' in self.checks:
             mem = 'NLA_POLICY_MAX_LEN(' + self.get_limit_str('max-len') + ')'
 
-- 
2.50.1

Re: [PATCH net-next v2 2/3] tools: ynl-gen: use macro for binary min-len check
Posted by Donald Hunter 1 month ago
Asbjørn Sloth Tønnesen <ast@fiberby.net> writes:

> This patch changes the generated min-len check for binary
> attributes to use the NLA_POLICY_MIN_LEN() macro, thereby the
> generated code supports strict policy validation.
>
> With this change TypeBinary will always generate a NLA_BINARY
> attribute 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>