Netdev Archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tools: ynl: fix setting presence bits in simple nests
@ 2024-03-21  2:02 Jakub Kicinski
  2024-03-21  9:13 ` Breno Leitao
  2024-03-23  1:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Kicinski @ 2024-03-21  2:02 UTC (permalink / raw
  To: davem; +Cc: netdev, edumazet, pabeni, Jakub Kicinski, sdf

When we set members of simple nested structures in requests
we need to set "presence" bits for all the nesting layers
below. This has nothing to do with the presence type of
the last layer.

Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: sdf@google.com
---
 tools/net/ynl/ynl-gen-c.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 6b7eb2d2aaf1..a451cbfbd781 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -228,8 +228,11 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
         presence = ''
         for i in range(0, len(ref)):
             presence = f"{var}->{'.'.join(ref[:i] + [''])}_present.{ref[i]}"
-            if self.presence_type() == 'bit':
-                code.append(presence + ' = 1;')
+            # Every layer below last is a nest, so we know it uses bit presence
+            # last layer is "self" and may be a complex type
+            if i == len(ref) - 1 and self.presence_type() != 'bit':
+                continue
+            code.append(presence + ' = 1;')
         code += self._setter_lines(ri, member, presence)
 
         func_name = f"{op_prefix(ri, direction, deref=deref)}_set_{'_'.join(ref)}"
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net] tools: ynl: fix setting presence bits in simple nests
  2024-03-21  2:02 [PATCH net] tools: ynl: fix setting presence bits in simple nests Jakub Kicinski
@ 2024-03-21  9:13 ` Breno Leitao
  2024-03-23  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Breno Leitao @ 2024-03-21  9:13 UTC (permalink / raw
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, sdf

On Wed, Mar 20, 2024 at 07:02:14PM -0700, Jakub Kicinski wrote:
> When we set members of simple nested structures in requests
> we need to set "presence" bits for all the nesting layers
> below. This has nothing to do with the presence type of
> the last layer.
> 
> Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Reviewed-by: Breno Leitao <leitao@debian.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] tools: ynl: fix setting presence bits in simple nests
  2024-03-21  2:02 [PATCH net] tools: ynl: fix setting presence bits in simple nests Jakub Kicinski
  2024-03-21  9:13 ` Breno Leitao
@ 2024-03-23  1:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-03-23  1:10 UTC (permalink / raw
  To: Jakub Kicinski; +Cc: davem, netdev, edumazet, pabeni, sdf

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 20 Mar 2024 19:02:14 -0700 you wrote:
> When we set members of simple nested structures in requests
> we need to set "presence" bits for all the nesting layers
> below. This has nothing to do with the presence type of
> the last layer.
> 
> Fixes: be5bea1cc0bf ("net: add basic C code generators for Netlink")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> 
> [...]

Here is the summary with links:
  - [net] tools: ynl: fix setting presence bits in simple nests
    https://git.kernel.org/netdev/net/c/f6c8f5e8694c

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] 3+ messages in thread

end of thread, other threads:[~2024-03-23  1:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21  2:02 [PATCH net] tools: ynl: fix setting presence bits in simple nests Jakub Kicinski
2024-03-21  9:13 ` Breno Leitao
2024-03-23  1:10 ` 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 read-only IMAP folder(s) and NNTP newsgroup(s).