netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Alessandro Marcolini <alessandromarcolini99@gmail.com>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, donald.hunter@gmail.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: Mon, 22 Jan 2024 11:46:13 -0800	[thread overview]
Message-ID: <Za7GBaCiE+LUv6ZZ@gmail.com> (raw)
In-Reply-To: <0eedc19860e9b84f105c57d17219b3d0af3100d2.1705950652.git.alessandromarcolini99@gmail.com>

On Mon, Jan 22, 2024 at 08:19:41PM +0100, Alessandro Marcolini wrote:
> Add encoding support for 'sub-message' attribute and for resolving
> sub-message selectors at different nesting level from the key
> attribute.
> 
> Also, add encoding support for multi-attr attributes.
> 
> 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()
> +            ):

This is a bit hard to read.

Is it possible to make it a bit easier to read?

  reply	other threads:[~2024-01-22 19:46 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 [this message]
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
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=Za7GBaCiE+LUv6ZZ@gmail.com \
    --to=leitao@debian.org \
    --cc=alessandromarcolini99@gmail.com \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.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).