All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org, donald.hunter@gmail.com,
	jacob.e.keller@intel.com, sdf@fomichev.me, jstancek@redhat.com,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 07/11] tools: ynl-gen: support local attrs in _multi_parse
Date: Fri, 16 May 2025 17:13:14 -0700	[thread overview]
Message-ID: <20250517001318.285800-8-kuba@kernel.org> (raw)
In-Reply-To: <20250517001318.285800-1-kuba@kernel.org>

The _multi_parse() helper calls the _attr_get() method of each attr,
but it only respects what code the helper wants to emit, not what
local variables it needs. Local variables will soon be needed,
support them.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/pyynl/ynl_gen_c.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index bd1fadb2cf5a..f2a4404d0d21 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -2214,12 +2214,16 @@ _C_KW = {
     parse_rsp_nested_prototype(ri, struct, suffix='')
 
     var = 'dst'
+    local_vars = {'const struct nlattr *attr = nested;',
+                  f'{struct.ptr_name}{var} = yarg->data;',
+                  'struct ynl_parse_arg parg;'}
+
+    for _, arg in struct.member_list():
+        _, _, l_vars = arg._attr_get(ri, var)
+        local_vars |= set(l_vars) if l_vars else set()
 
     ri.cw.block_start()
-    ri.cw.write_func_lvar(['const struct nlattr *attr = nested;',
-                          f'{struct.ptr_name}{var} = yarg->data;',
-                          'struct ynl_parse_arg parg;'])
-
+    ri.cw.write_func_lvar(list(local_vars))
     ri.cw.p('parg.ys = yarg->ys;')
     ri.cw.nl()
 
-- 
2.49.0


  parent reply	other threads:[~2025-05-17  0:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-17  0:13 [PATCH net-next 00/11] tools: ynl-gen: add support for "inherited" selector and therefore TC Jakub Kicinski
2025-05-17  0:13 ` [PATCH net-next 01/11] netlink: specs: tc: remove duplicate nests Jakub Kicinski
2025-05-18 13:34   ` Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 02/11] netlink: specs: tc: use tc-gact instead of tc-gen as struct name Jakub Kicinski
2025-05-18 13:35   ` Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 03/11] netlink: specs: tc: add C naming info Jakub Kicinski
2025-05-18 13:36   ` Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 04/11] netlink: specs: tc: drop the family name prefix from attrs Jakub Kicinski
2025-05-18 13:37   ` Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 05/11] tools: ynl-gen: support passing selector to a nest Jakub Kicinski
2025-05-18 13:46   ` Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 06/11] tools: ynl-gen: move fixed header info from RenderInfo to Struct Jakub Kicinski
2025-05-18 13:49   ` Donald Hunter
2025-05-17  0:13 ` Jakub Kicinski [this message]
2025-05-18 13:50   ` [PATCH net-next 07/11] tools: ynl-gen: support local attrs in _multi_parse Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 08/11] tools: ynl-gen: support weird sub-message formats Jakub Kicinski
2025-05-19  9:25   ` Donald Hunter
2025-05-20  3:07     ` Jakub Kicinski
2025-05-17  0:13 ` [PATCH net-next 09/11] tools: ynl: enable codegen for TC Jakub Kicinski
2025-05-19  9:26   ` Donald Hunter
2025-05-20  8:27   ` Kory Maincent
2025-05-17  0:13 ` [PATCH net-next 10/11] netlink: specs: tc: add qdisc dump to TC spec Jakub Kicinski
2025-05-19  9:27   ` Donald Hunter
2025-05-17  0:13 ` [PATCH net-next 11/11] tools: ynl: add a sample for TC Jakub Kicinski
2025-05-19 10:19   ` Donald Hunter

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=20250517001318.285800-8-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jacob.e.keller@intel.com \
    --cc=jstancek@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.