* [PATCH net-next] tools: ynl-gen-c: improve support for empty nests
@ 2025-01-08 20:07 Jakub Kicinski
2025-01-09 2:09 ` Stanislav Fomichev
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Jakub Kicinski @ 2025-01-08 20:07 UTC (permalink / raw)
To: davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, Jakub Kicinski,
dw, donald.hunter, nicolas.dichtel, sdf
Empty nests are the same size as a flag at the netlink level
(just a 4 byte nlattr without a payload). They are sometimes
useful in case we want to only communicate a presence of
something but may want to add more details later.
This may be the case in the upcoming io_uring ZC patches,
for example.
Improve handling of nested empty structs. We already support
empty structs since a lot of netlink replies are empty, but
for nested ones we need minor tweaks to avoid pointless empty
lines and unused variables.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: dw@davidwei.uk
CC: donald.hunter@gmail.com
CC: nicolas.dichtel@6wind.com
CC: sdf@fomichev.me
---
tools/net/ynl/ynl-gen-c.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index ec2288948795..9722a8f72a46 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -1765,7 +1765,14 @@ _C_KW = {
f'{struct.ptr_name}dst = yarg->data;']
init_lines = []
- _multi_parse(ri, struct, init_lines, local_vars)
+ if struct.member_list():
+ _multi_parse(ri, struct, init_lines, local_vars)
+ else:
+ # Empty nest
+ ri.cw.block_start()
+ ri.cw.p('return 0;')
+ ri.cw.block_end()
+ ri.cw.nl()
def parse_rsp_msg(ri, deref=False):
@@ -2592,7 +2599,8 @@ _C_KW = {
val = attr.value
val += 1
cw.p(attr.enum_name + suffix)
- cw.nl()
+ if attr_set.items():
+ cw.nl()
cw.p(attr_set.cnt_name + ('' if max_by_define else ','))
if not max_by_define:
cw.p(f"{attr_set.max_name} = {max_value}")
--
2.47.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tools: ynl-gen-c: improve support for empty nests
2025-01-08 20:07 [PATCH net-next] tools: ynl-gen-c: improve support for empty nests Jakub Kicinski
@ 2025-01-09 2:09 ` Stanislav Fomichev
2025-01-09 16:52 ` Nicolas Dichtel
2025-01-09 21:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Stanislav Fomichev @ 2025-01-09 2:09 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, dw,
donald.hunter, nicolas.dichtel, sdf
On 01/08, Jakub Kicinski wrote:
> Empty nests are the same size as a flag at the netlink level
> (just a 4 byte nlattr without a payload). They are sometimes
> useful in case we want to only communicate a presence of
> something but may want to add more details later.
> This may be the case in the upcoming io_uring ZC patches,
> for example.
>
> Improve handling of nested empty structs. We already support
> empty structs since a lot of netlink replies are empty, but
> for nested ones we need minor tweaks to avoid pointless empty
> lines and unused variables.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Looks sensible. Assuming the context is:
https://lore.kernel.org/netdev/20250108220644.3528845-1-dw@davidwei.uk/T/#Z2e.:..:20250108220644.3528845-8-dw::40davidwei.uk:1Documentation:netlink:specs:netdev.yaml
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tools: ynl-gen-c: improve support for empty nests
2025-01-08 20:07 [PATCH net-next] tools: ynl-gen-c: improve support for empty nests Jakub Kicinski
2025-01-09 2:09 ` Stanislav Fomichev
@ 2025-01-09 16:52 ` Nicolas Dichtel
2025-01-09 21:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: Nicolas Dichtel @ 2025-01-09 16:52 UTC (permalink / raw)
To: Jakub Kicinski, davem
Cc: netdev, edumazet, pabeni, andrew+netdev, horms, dw, donald.hunter,
sdf
Le 08/01/2025 à 21:07, Jakub Kicinski a écrit :
> Empty nests are the same size as a flag at the netlink level
> (just a 4 byte nlattr without a payload). They are sometimes
> useful in case we want to only communicate a presence of
> something but may want to add more details later.
> This may be the case in the upcoming io_uring ZC patches,
> for example.
>
> Improve handling of nested empty structs. We already support
> empty structs since a lot of netlink replies are empty, but
> for nested ones we need minor tweaks to avoid pointless empty
> lines and unused variables.
>
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] tools: ynl-gen-c: improve support for empty nests
2025-01-08 20:07 [PATCH net-next] tools: ynl-gen-c: improve support for empty nests Jakub Kicinski
2025-01-09 2:09 ` Stanislav Fomichev
2025-01-09 16:52 ` Nicolas Dichtel
@ 2025-01-09 21:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-01-09 21:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: davem, netdev, edumazet, pabeni, andrew+netdev, horms, dw,
donald.hunter, nicolas.dichtel, sdf
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 8 Jan 2025 12:07:58 -0800 you wrote:
> Empty nests are the same size as a flag at the netlink level
> (just a 4 byte nlattr without a payload). They are sometimes
> useful in case we want to only communicate a presence of
> something but may want to add more details later.
> This may be the case in the upcoming io_uring ZC patches,
> for example.
>
> [...]
Here is the summary with links:
- [net-next] tools: ynl-gen-c: improve support for empty nests
https://git.kernel.org/netdev/net-next/c/93e505a300aa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-01-09 21:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-08 20:07 [PATCH net-next] tools: ynl-gen-c: improve support for empty nests Jakub Kicinski
2025-01-09 2:09 ` Stanislav Fomichev
2025-01-09 16:52 ` Nicolas Dichtel
2025-01-09 21:00 ` patchwork-bot+netdevbpf
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).