tools: ynl: allow user to specify flag attr with bool values
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> Link: https://lore.kernel.org/r/20240222134351.224704-2-jiri@resnulli.us Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
5c4e0f3ae4
commit
ac95b1fca0
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user