diff mbox series

[net-next,1/8] ynl-gen-c.py: fix rendering of validate field

Message ID 20230801141907.816280-2-jiri@resnulli.us (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series devlink: use spec to generate split ops | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 9 this patch: 9
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 18 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jiri Pirko Aug. 1, 2023, 2:19 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

For split ops, do and dump has different value in validate field. Fix
the rendering so for do op, only "strict" is filled out and for dump op,
"strict" is prefixed by "dump-".

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 tools/net/ynl/ynl-gen-c.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Jakub Kicinski Aug. 1, 2023, 6:25 p.m. UTC | #1
On Tue,  1 Aug 2023 16:19:00 +0200 Jiri Pirko wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> For split ops, do and dump has different value in validate field. Fix
> the rendering so for do op, only "strict" is filled out and for dump op,
> "strict" is prefixed by "dump-".
> 
> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
> ---
>  tools/net/ynl/ynl-gen-c.py | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
> index 650be9b8b693..1c36d0c935da 100755
> --- a/tools/net/ynl/ynl-gen-c.py
> +++ b/tools/net/ynl/ynl-gen-c.py
> @@ -1988,9 +1988,17 @@ def print_kernel_op_table(family, cw):
>                  cw.block_start()
>                  members = [('cmd', op.enum_name)]
>                  if 'dont-validate' in op:
> +                    dont_validate = []
> +                    for x in op['dont-validate']:
> +                        if op_mode == 'do' and x == 'dump':
> +                            continue
> +                        if op_mode == "dump" and x == 'strict':
> +                            x = 'dump-' + x
> +                        dont_validate.append(x)
> +
>                      members.append(('validate',
>                                      ' | '.join([c_upper('genl-dont-validate-' + x)
> -                                                for x in op['dont-validate']])), )
> +                                                for x in dont_validate])), )
>                  name = c_lower(f"{family.name}-nl-{op_name}-{op_mode}it")
>                  if 'pre' in op[op_mode]:
>                      members.append((cb_names[op_mode]['pre'], c_lower(op[op_mode]['pre'])))

I was hoping we can delete GENL_DONT_VALIDATE_DUMP_STRICT
but there is one cmd (TIPC_NL_LINK_GET) which
sets GENL_DONT_VALIDATE_STRICT and nothing about the dump.

To express something like that we should add dump-strict as
an allowed flag explicitly rather than doing the auto-prepending
Jiri Pirko Aug. 2, 2023, 6:41 a.m. UTC | #2
Tue, Aug 01, 2023 at 08:25:30PM CEST, kuba@kernel.org wrote:
>On Tue,  1 Aug 2023 16:19:00 +0200 Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>> 
>> For split ops, do and dump has different value in validate field. Fix
>> the rendering so for do op, only "strict" is filled out and for dump op,
>> "strict" is prefixed by "dump-".
>> 
>> Signed-off-by: Jiri Pirko <jiri@nvidia.com>
>> ---
>>  tools/net/ynl/ynl-gen-c.py | 10 +++++++++-
>>  1 file changed, 9 insertions(+), 1 deletion(-)
>> 
>> diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
>> index 650be9b8b693..1c36d0c935da 100755
>> --- a/tools/net/ynl/ynl-gen-c.py
>> +++ b/tools/net/ynl/ynl-gen-c.py
>> @@ -1988,9 +1988,17 @@ def print_kernel_op_table(family, cw):
>>                  cw.block_start()
>>                  members = [('cmd', op.enum_name)]
>>                  if 'dont-validate' in op:
>> +                    dont_validate = []
>> +                    for x in op['dont-validate']:
>> +                        if op_mode == 'do' and x == 'dump':
>> +                            continue
>> +                        if op_mode == "dump" and x == 'strict':
>> +                            x = 'dump-' + x
>> +                        dont_validate.append(x)
>> +
>>                      members.append(('validate',
>>                                      ' | '.join([c_upper('genl-dont-validate-' + x)
>> -                                                for x in op['dont-validate']])), )
>> +                                                for x in dont_validate])), )
>>                  name = c_lower(f"{family.name}-nl-{op_name}-{op_mode}it")
>>                  if 'pre' in op[op_mode]:
>>                      members.append((cb_names[op_mode]['pre'], c_lower(op[op_mode]['pre'])))
>
>I was hoping we can delete GENL_DONT_VALIDATE_DUMP_STRICT
>but there is one cmd (TIPC_NL_LINK_GET) which
>sets GENL_DONT_VALIDATE_STRICT and nothing about the dump.

I need GENL_DONT_VALIDATE_STRICT for devlink dump selectors as well. I
don't want to break existing user that may pass garbage attributes.

>
>To express something like that we should add dump-strict as
>an allowed flag explicitly rather than doing the auto-prepending

Yeah, that was an option. But strict means GENL_DONT_VALIDATE_STRICT
for do and GENL_DONT_VALIDATE_DUMP_STRICT for dump. That is why I
decided to go this way.

I will add dump-strict if you prefer it, I don't care.

>-- 
>pw-bot: cr
diff mbox series

Patch

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 650be9b8b693..1c36d0c935da 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -1988,9 +1988,17 @@  def print_kernel_op_table(family, cw):
                 cw.block_start()
                 members = [('cmd', op.enum_name)]
                 if 'dont-validate' in op:
+                    dont_validate = []
+                    for x in op['dont-validate']:
+                        if op_mode == 'do' and x == 'dump':
+                            continue
+                        if op_mode == "dump" and x == 'strict':
+                            x = 'dump-' + x
+                        dont_validate.append(x)
+
                     members.append(('validate',
                                     ' | '.join([c_upper('genl-dont-validate-' + x)
-                                                for x in op['dont-validate']])), )
+                                                for x in dont_validate])), )
                 name = c_lower(f"{family.name}-nl-{op_name}-{op_mode}it")
                 if 'pre' in op[op_mode]:
                     members.append((cb_names[op_mode]['pre'], c_lower(op[op_mode]['pre'])))