netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Donald Hunter <donald.hunter@gmail.com>
Cc: netdev@vger.kernel.org, kuba@kernel.org, pabeni@redhat.com,
	davem@davemloft.net, edumazet@google.com,
	jacob.e.keller@intel.com, swarupkotikalapudi@gmail.com,
	sdf@google.com, lorenzo@kernel.org,
	alessandromarcolini99@gmail.com
Subject: Re: [patch net-next v2 1/3] tools: ynl: allow user to specify flag attr with bool values
Date: Thu, 22 Feb 2024 14:17:32 +0100	[thread overview]
Message-ID: <ZddJbO095_h-2bn9@nanopsycho> (raw)
In-Reply-To: <CAD4GDZxn7bq0t59=V7AJ_aFsJNvkdK_CJmnaPV2W_7uiEUozKQ@mail.gmail.com>

Wed, Feb 21, 2024 at 07:07:40PM CET, donald.hunter@gmail.com wrote:
>On Wed, 21 Feb 2024 at 15:54, 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>
>> ---
>> v1->v2:
>> - accept other values than "False"
>> ---
>>  tools/net/ynl/lib/ynl.py | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
>> index f45ee5f29bed..4a44840bab68 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 not value:
>> +                return b''
>
>Minor nit: It took me a moment to realise that by returning here, this
>skips attribute creation. A comment to this effect would be helpful:
>
># If value is absent or false then skip attribute creation.

Sure, will add.

>
>>              attr_payload = b''
>>          elif attr["type"] == 'string':
>>              attr_payload = str(value).encode('ascii') + b'\x00'
>> --
>> 2.43.2
>>

  reply	other threads:[~2024-02-22 13:17 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21 15:54 [patch net-next v2 0/3] tools: ynl: couple of cmdline enhancements Jiri Pirko
2024-02-21 15:54 ` [patch net-next v2 1/3] tools: ynl: allow user to specify flag attr with bool values Jiri Pirko
2024-02-21 18:07   ` Donald Hunter
2024-02-22 13:17     ` Jiri Pirko [this message]
2024-02-21 15:54 ` [patch net-next v2 2/3] tools: ynl: process all scalar types encoding in single elif statement Jiri Pirko
2024-02-21 18:12   ` Donald Hunter
2024-02-21 15:54 ` [patch net-next v2 3/3] tools: ynl: allow user to pass enum string instead of scalar value Jiri Pirko
2024-02-21 18:14   ` Donald Hunter
2024-02-21 18:49   ` Jakub Kicinski
2024-02-22 13:14     ` Jiri Pirko
2024-02-21 22:29 ` [patch net-next v2 0/3] tools: ynl: couple of cmdline enhancements Keller, Jacob E

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZddJbO095_h-2bn9@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=alessandromarcolini99@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    --cc=swarupkotikalapudi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).