diff mbox series

[net-next,01/13] tools: ynl: allow user to specify flag attr with bool values

Message ID 20240219172525.71406-2-jiri@resnulli.us (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series netlink: specs: devlink: add the rest of missing attribute definitions | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl fail Generated files up to date; build failed; build has 3 warnings/errors; GEN HAS DIFF 2 files changed, 12648 deletions(-);
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: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
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: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-02-19--21-00 (tests: 1357)

Commit Message

Jiri Pirko Feb. 19, 2024, 5:25 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

The flag attr presence in Netlink message indicates value "true",
if it is missing in the message it means "false".

Allow user to specify attrname with value "true"/"false"
in json for flag attrs, treat "false" value properly.

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

Comments

Jakub Kicinski Feb. 19, 2024, 8:42 p.m. UTC | #1
On Mon, 19 Feb 2024 18:25:17 +0100 Jiri Pirko wrote:
>          elif attr["type"] == 'flag':
> +            if value == False:
> +                return b''

how about "if value:" ? It could also be null / None or some other
"false" object.
Jiri Pirko Feb. 20, 2024, 7:24 a.m. UTC | #2
Mon, Feb 19, 2024 at 09:42:22PM CET, kuba@kernel.org wrote:
>On Mon, 19 Feb 2024 18:25:17 +0100 Jiri Pirko wrote:
>>          elif attr["type"] == 'flag':
>> +            if value == False:
>> +                return b''
>
>how about "if value:" ? It could also be null / None or some other
>"false" object.

Sure, why not.
diff mbox series

Patch

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index f45ee5f29bed..108fe7eadd93 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -459,6 +459,8 @@  class YnlFamily(SpecFamily):
                 attr_payload += self._add_attr(attr['nested-attributes'],
                                                subname, subvalue, sub_attrs)
         elif attr["type"] == 'flag':
+            if value == False:
+                return b''
             attr_payload = b''
         elif attr["type"] == 'string':
             attr_payload = str(value).encode('ascii') + b'\x00'