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, yuyanghuang@google•com,
sdf@fomichev•me, gnault@redhat•com, nicolas.dichtel@6wind•com,
petrm@nvidia•com, Jakub Kicinski <kuba@kernel•org>
Subject: [PATCH net-next 08/13] tools: ynl-gen: don't consider requests with fixed hdr empty
Date: Tue, 8 Apr 2025 17:03:55 -0700 [thread overview]
Message-ID: <20250409000400.492371-9-kuba@kernel.org> (raw)
In-Reply-To: <20250409000400.492371-1-kuba@kernel.org>
C codegen skips generating the structs if request/reply has no attrs.
In such cases the request op takes no argument and return int
(rather than response struct). In case of classic netlink a lot of
information gets passed using the fixed struct, however, so adjust
the logic to consider a request empty only if it has no attrs _and_
no fixed struct.
Signed-off-by: Jakub Kicinski <kuba@kernel•org>
---
tools/net/ynl/pyynl/ynl_gen_c.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 9e00aac4801c..04f1ac62cb01 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -1247,6 +1247,9 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
if op_mode == 'event':
self.struct['reply'] = Struct(family, self.attr_set, type_list=op['event']['attributes'])
+ def type_empty(self, key):
+ return len(self.struct[key].attr_list) == 0 and self.fixed_hdr is None
+
class CodeWriter:
def __init__(self, nlib, out_file=None, overwrite=True):
@@ -2034,7 +2037,7 @@ _C_KW = {
def print_req_type_helpers(ri):
- if len(ri.struct["request"].attr_list) == 0:
+ if ri.type_empty("request"):
return
print_alloc_wrapper(ri, "request")
print_type_helpers(ri, "request")
@@ -2057,7 +2060,7 @@ _C_KW = {
def print_req_type(ri):
- if len(ri.struct["request"].attr_list) == 0:
+ if ri.type_empty("request"):
return
print_type(ri, "request")
--
2.49.0
next prev parent reply other threads:[~2025-04-09 0:04 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 0:03 [PATCH net-next 00/13] tools: ynl: c: basic netlink-raw support Jakub Kicinski
2025-04-09 0:03 ` [PATCH net-next 01/13] netlink: specs: rename rtnetlink specs in accordance with family name Jakub Kicinski
2025-04-09 4:49 ` Jacob Keller
2025-04-09 12:15 ` Donald Hunter
2025-04-09 14:15 ` Jakub Kicinski
2025-04-09 14:36 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 02/13] netlink: specs: rt-route: specify fixed-header at operations level Jakub Kicinski
2025-04-09 4:50 ` Jacob Keller
2025-04-09 12:16 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 03/13] netlink: specs: rt-addr: remove the fixed members from attrs Jakub Kicinski
2025-04-09 4:53 ` Jacob Keller
2025-04-09 4:58 ` Jacob Keller
2025-04-09 12:19 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 04/13] netlink: specs: rt-route: " Jakub Kicinski
2025-04-09 4:58 ` Jacob Keller
2025-04-09 12:20 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 05/13] netlink: specs: rt-addr: add C naming info Jakub Kicinski
2025-04-09 4:54 ` Jacob Keller
2025-04-09 12:21 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 06/13] netlink: specs: rt-route: " Jakub Kicinski
2025-04-09 4:54 ` Jacob Keller
2025-04-09 12:21 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 07/13] tools: ynl: support creating non-genl sockets Jakub Kicinski
2025-04-09 4:56 ` Jacob Keller
2025-04-09 12:25 ` Donald Hunter
2025-04-09 0:03 ` Jakub Kicinski [this message]
2025-04-09 4:57 ` [PATCH net-next 08/13] tools: ynl-gen: don't consider requests with fixed hdr empty Jacob Keller
2025-04-09 0:03 ` [PATCH net-next 09/13] tools: ynl: don't use genlmsghdr in classic netlink Jakub Kicinski
2025-04-09 4:59 ` Jacob Keller
2025-04-09 12:26 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 10/13] tools: ynl-gen: consider dump ops without a do "type-consistent" Jakub Kicinski
2025-04-09 5:01 ` Jacob Keller
2025-04-09 12:38 ` Donald Hunter
2025-04-09 13:52 ` Jakub Kicinski
2025-04-09 21:58 ` Jacob Keller
2025-04-09 0:03 ` [PATCH net-next 11/13] tools: ynl-gen: use family c-name in notifications Jakub Kicinski
2025-04-09 5:01 ` Jacob Keller
2025-04-09 12:38 ` Donald Hunter
2025-04-09 0:03 ` [PATCH net-next 12/13] tools: ynl: generate code for rt-addr and add a sample Jakub Kicinski
2025-04-09 5:04 ` Jacob Keller
2025-04-09 15:01 ` Jakub Kicinski
2025-04-09 12:50 ` Donald Hunter
2025-04-09 0:04 ` [PATCH net-next 13/13] tools: ynl: generate code for rt-route " Jakub Kicinski
2025-04-09 5:05 ` Jacob Keller
2025-04-09 12:49 ` 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=20250409000400.492371-9-kuba@kernel.org \
--to=kuba@kernel$(echo .)org \
--cc=andrew+netdev@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=donald.hunter@gmail$(echo .)com \
--cc=edumazet@google$(echo .)com \
--cc=gnault@redhat$(echo .)com \
--cc=horms@kernel$(echo .)org \
--cc=jacob.e.keller@intel$(echo .)com \
--cc=netdev@vger$(echo .)kernel.org \
--cc=nicolas.dichtel@6wind$(echo .)com \
--cc=pabeni@redhat$(echo .)com \
--cc=petrm@nvidia$(echo .)com \
--cc=sdf@fomichev$(echo .)me \
--cc=yuyanghuang@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