Netdev List
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Jacob Keller <jacob.e.keller@intel.com>,
	Stanislav Fomichev <sdf@google.com>
Subject: Re: [PATCHv3 net-next 2/2] ynl: support binary/u32 sub-type for indexed-array
Date: Wed, 3 Apr 2024 11:27:22 +0800	[thread overview]
Message-ID: <ZgzMmqWzRvdk4wzP@Laptop-X1> (raw)
In-Reply-To: <20240402193551.38a5aead@kernel.org>

On Tue, Apr 02, 2024 at 07:35:51PM -0700, Jakub Kicinski wrote:
> On Wed, 3 Apr 2024 10:28:34 +0800 Hangbin Liu wrote:
> > I didn't check other subsystem. For bonding only, if we don't have the hint.
> > e.g.
> > 
> >   -
> >     name: arp-ip-target
> >     type: indexed-array
> >     sub-type: u32
> > 
> > The result will looks like:
> > 
> >     "arp-ip-target": [
> >       "c0a80101",
> >       "c0a80102"
> >     ],
> > 
> > Which looks good to me. Do you have other suggestion?
> 
> That doesn't look right, without the format hint if the type is u32 
> the members should be plain integers not hex strings.

OK, I can separate the binary and u32 dealing. How about like

diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index e5ad415905c7..be42e4fc1037 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -640,6 +640,16 @@ class YnlFamily(SpecFamily):
             if attr_spec["sub-type"] == 'nest':
                 subattrs = self._decode(NlAttrs(item.raw), attr_spec['nested-attributes'])
                 decoded.append({ item.type: subattrs })
+            elif attr_spec["sub-type"] == 'binary':
+                subattrs = item.as_bin()
+                if attr_spec.display_hint:
+                    subattrs = self._formatted_string(subattrs, attr_spec.display_hint)
+                decoded.append(subattrs)
+            elif attr_spec["sub-type"] in NlAttr.type_formats:
+                subattrs = item.as_scalar(attr_spec['sub-type'], attr_spec.byte_order)
+                if attr_spec.display_hint:
+                    subattrs = self._formatted_string(subattrs, attr_spec.display_hint)
+                decoded.append(subattrs)
             else:
                 raise Exception(f'Unknown {attr_spec["sub-type"]} with name {attr_spec["name"]}')
         return decoded


With only sub-type: u32 it shows like

    "arp-ip-target": [
      3232235777,
      3232235778
    ],

Thanks
Hangbin

  reply	other threads:[~2024-04-03  3:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-01  3:56 [PATCHv3 net-next 0/2] ynl: rename array-nest to indexed-array Hangbin Liu
2024-04-01  3:56 ` [PATCHv3 net-next 1/2] " Hangbin Liu
2024-04-01  3:56 ` [PATCHv3 net-next 2/2] ynl: support binary/u32 sub-type for indexed-array Hangbin Liu
2024-04-02  4:43   ` Jakub Kicinski
2024-04-03  2:28     ` Hangbin Liu
2024-04-03  2:35       ` Jakub Kicinski
2024-04-03  3:27         ` Hangbin Liu [this message]
2024-04-04  0:07           ` Jakub Kicinski
  -- strict thread matches above, loose matches on Subject: below --
2024-04-04  6:31 [PATCHv4 net-next 0/2] ynl: rename array-nest to indexed-array Hangbin Liu
2024-04-04  6:31 ` [PATCHv3 net-next 2/2] ynl: support binary/u32 sub-type for indexed-array Hangbin Liu

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=ZgzMmqWzRvdk4wzP@Laptop-X1 \
    --to=liuhangbin@gmail.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=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