diff mbox series

[net-next] tools: ynl-gen: fix nested policy attribute type

Message ID 20230613231709.150622-1-arkadiusz.kubalewski@intel.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] tools: ynl-gen: fix nested policy attribute type | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Kubalewski, Arkadiusz June 13, 2023, 11:17 p.m. UTC
When nested multi-attribute is used in yaml spec, generated type in
the netlink policy is NLA_NEST, which is wrong as there is no such type.
Fix be adding `ed` sufix for policy generated for 'nest' type attribute
when the attribute is parsed as TypeMultiAttr class.

Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
---
 tools/net/ynl/ynl-gen-c.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Jakub Kicinski June 14, 2023, 12:50 a.m. UTC | #1
On Wed, 14 Jun 2023 01:17:07 +0200 Arkadiusz Kubalewski wrote:
> When nested multi-attribute is used in yaml spec, generated type in
> the netlink policy is NLA_NEST, which is wrong as there is no such type.
> Fix be adding `ed` sufix for policy generated for 'nest' type attribute
> when the attribute is parsed as TypeMultiAttr class.

I CCed you on my changes which address the same issue, they have
already been merged:

https://lore.kernel.org/all/20230612155920.1787579-1-kuba@kernel.org/

I think that covers the first two patches. What am I missing? :S
Kubalewski, Arkadiusz June 14, 2023, 12:28 p.m. UTC | #2
>From: Jakub Kicinski <kuba@kernel.org>
>Sent: Wednesday, June 14, 2023 2:51 AM
>To: Kubalewski, Arkadiusz <arkadiusz.kubalewski@intel.com>
>Cc: netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
>davem@davemloft.net; pabeni@redhat.com; edumazet@google.com;
>chuck.lever@oracle.com
>Subject: Re: [PATCH net-next] tools: ynl-gen: fix nested policy attribute
>type
>
>On Wed, 14 Jun 2023 01:17:07 +0200 Arkadiusz Kubalewski wrote:
>> When nested multi-attribute is used in yaml spec, generated type in
>> the netlink policy is NLA_NEST, which is wrong as there is no such type.
>> Fix be adding `ed` sufix for policy generated for 'nest' type attribute
>> when the attribute is parsed as TypeMultiAttr class.
>
>I CCed you on my changes which address the same issue, they have
>already been merged:
>
>https://lore.kernel.org/all/20230612155920.1787579-1-kuba@kernel.org/
>
>I think that covers the first two patches. What am I missing? :S

Yep, sorry I missed them.
Did rebase and it seems your changes are great, everything works,
please drop this patch.

Thank you!
Arkadiusz
diff mbox series

Patch

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 9adcd785db0b..0b5e0802a9a7 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -498,6 +498,16 @@  class TypeArrayNest(Type):
         else:
             raise Exception(f"Sub-type {self.attr['sub-type']} not supported yet")
 
+    def attr_policy(self, cw):
+        t = self.attr['type']
+        if (t == 'nest'):
+            policy = c_upper(f'nla-{t}ed')
+        else:
+            policy = c_upper(f'nla-{t}')
+
+        spec = self._attr_policy(policy)
+        cw.p(f"\t[{self.enum_name}] = {spec},")
+
     def _attr_typol(self):
         return f'.type = YNL_PT_NEST, .nest = &{self.nested_render_name}_nest, '