From: Donald Hunter <donald.hunter@gmail•com>
To: Alessandro Marcolini <alessandromarcolini99@gmail•com>
Cc: davem@davemloft•net, edumazet@google•com, kuba@kernel•org,
pabeni@redhat•com, sdf@google•com, chuck.lever@oracle•com,
lorenzo@kernel•org, jacob.e.keller@intel•com, jiri@resnulli•us,
netdev@vger•kernel.org
Subject: Re: [PATCH net-next 3/3] tools: ynl: add encoding support for 'sub-message' to ynl
Date: Wed, 24 Jan 2024 09:45:47 +0000 [thread overview]
Message-ID: <m27cjzxdx0.fsf@gmail.com> (raw)
In-Reply-To: <17795933-a5ca-44c6-be4c-58ed2e573aff@gmail.com> (Alessandro Marcolini's message of "Wed, 24 Jan 2024 10:12:02 +0100")
Alessandro Marcolini <alessandromarcolini99@gmail•com> writes:
> On 1/23/24 17:44, Donald Hunter wrote:
>> Alessandro Marcolini <alessandromarcolini99@gmail•com> writes:
>>
>>> Add encoding support for 'sub-message' attribute and for resolving
>>> sub-message selectors at different nesting level from the key
>>> attribute.
>> I think the relevant patches in my series are:
>>
>> https://lore.kernel.org/netdev/20240123160538.172-3-donald.hunter@gmail.com/T/#u
>> https://lore.kernel.org/netdev/20240123160538.172-5-donald.hunter@gmail.com/T/#u
> I really like your idea of using ChainMap, I think it's better than mine and more concise.
>>> Also, add encoding support for multi-attr attributes.
>> This would be better as a separate patch since it is unrelated to the
>> other changes.
> You mean as a separate patch in this patchset or as an entirely new patch?
I was thinking as a separate patch in this patchset, yes.
>>> Signed-off-by: Alessandro Marcolini <alessandromarcolini99@gmail•com>
>>> ---
>>> tools/net/ynl/lib/ynl.py | 54 +++++++++++++++++++++++++++++++++++-----
>>> 1 file changed, 48 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
>>> index 1e10512b2117..f8c56944f7e7 100644
>>> --- a/tools/net/ynl/lib/ynl.py
>>> +++ b/tools/net/ynl/lib/ynl.py
>>> @@ -449,7 +449,7 @@ class YnlFamily(SpecFamily):
>>> self.sock.setsockopt(Netlink.SOL_NETLINK, Netlink.NETLINK_ADD_MEMBERSHIP,
>>> mcast_id)
>>>
>>> - def _add_attr(self, space, name, value):
>>> + def _add_attr(self, space, name, value, vals):
>>> try:
>>> attr = self.attr_sets[space][name]
>>> except KeyError:
>>> @@ -458,8 +458,13 @@ class YnlFamily(SpecFamily):
>>> if attr["type"] == 'nest':
>>> nl_type |= Netlink.NLA_F_NESTED
>>> attr_payload = b''
>>> - for subname, subvalue in value.items():
>>> - attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue)
>>> + # Check if it's a list of values (i.e. it contains multi-attr elements)
>>> + for subname, subvalue in (
>>> + ((k, v) for item in value for k, v in item.items())
>>> + if isinstance(value, list)
>>> + else value.items()
>>> + ):
>>> + attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue, vals)
>> Should really check whether multi-attr is true in the spec before
>> processing the json input as a list of values.
> Yes, you're right. Maybe I could resend this on top of your changes, what do you think?
Yes, that would be great. Thanks!
next prev parent reply other threads:[~2024-01-24 9:48 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-22 19:19 [PATCH net-next 0/3] tools: ynl: Add sub-message and multi-attr encoding support Alessandro Marcolini
2024-01-22 19:19 ` [PATCH net-next 1/3] tools: ynl: correct typo and docstring Alessandro Marcolini
2024-01-23 16:28 ` Donald Hunter
2024-01-22 19:19 ` [PATCH net-next 2/3] doc: netlink: specs: tc: add multi-attr to tc-taprio-sched-entry Alessandro Marcolini
2024-01-23 16:35 ` Donald Hunter
2024-01-22 19:19 ` [PATCH net-next 3/3] tools: ynl: add encoding support for 'sub-message' to ynl Alessandro Marcolini
2024-01-22 19:46 ` Breno Leitao
2024-01-22 20:31 ` Alessandro Marcolini
2024-01-23 16:44 ` Donald Hunter
2024-01-24 9:12 ` Alessandro Marcolini
2024-01-24 9:45 ` Donald Hunter [this message]
2024-01-22 21:43 ` [PATCH net-next 0/3] tools: ynl: Add sub-message and multi-attr encoding support Donald Hunter
2024-01-23 0:40 ` Alessandro Marcolini
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=m27cjzxdx0.fsf@gmail.com \
--to=donald.hunter@gmail$(echo .)com \
--cc=alessandromarcolini99@gmail$(echo .)com \
--cc=chuck.lever@oracle$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=jacob.e.keller@intel$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=kuba@kernel$(echo .)org \
--cc=lorenzo@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=sdf@google$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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