Message ID | 20240222134351.224704-2-jiri@resnulli.us (mailing list archive) |
---|---|
State | Accepted |
Commit | ac95b1fca034d50d42a058a9476e0fe555653d0d |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | tools: ynl: couple of cmdline enhancements | expand |
On Thu, 22 Feb 2024 at 13:43, Jiri Pirko <jiri@resnulli.us> wrote: > > 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> Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index f45ee5f29bed..1c5c7662dc9a 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -459,6 +459,9 @@ class YnlFamily(SpecFamily): attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue, sub_attrs) elif attr["type"] == 'flag': + if not value: + # If value is absent or false then skip attribute creation. + return b'' attr_payload = b'' elif attr["type"] == 'string': attr_payload = str(value).encode('ascii') + b'\x00'