]> Git Repo - linux.git/commitdiff
tools: ynl: fix duplicate op name in devlink
authorJakub Kicinski <[email protected]>
Thu, 23 Nov 2023 03:05:58 +0000 (19:05 -0800)
committerJakub Kicinski <[email protected]>
Thu, 23 Nov 2023 16:52:23 +0000 (08:52 -0800)
We don't support CRUD-inspired message types in YNL too well.
One aspect that currently trips us up is the fact that single
message ID can be used in multiple commands (as the response).
This leads to duplicate entries in the id-to-string tables:

devlink-user.c:19:34: warning: initialized field overwritten [-Woverride-init]
   19 |         [DEVLINK_CMD_PORT_NEW] = "port-new",
      |                                  ^~~~~~~~~~
devlink-user.c:19:34: note: (near initialization for ‘devlink_op_strmap[7]’)

Fixes tag points at where the code was generated, the "real" problem
is that the code generator does not support CRUD.

Fixes: f2f9dd164db0 ("netlink: specs: devlink: add the remaining command to generate complete split_ops")
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
tools/net/ynl/generated/devlink-user.c
tools/net/ynl/ynl-gen-c.py

index bc5065bd99b2f05f4835da18d8a2a1a6fd28ce26..c12ca87ca2bb3f95f74d4854341a75edd5808822 100644 (file)
@@ -15,7 +15,7 @@
 /* Enums */
 static const char * const devlink_op_strmap[] = {
        [3] = "get",
-       [7] = "port-get",
+       // skip "port-get", duplicate reply value
        [DEVLINK_CMD_PORT_NEW] = "port-new",
        [13] = "sb-get",
        [17] = "sb-pool-get",
index c4003a83cd5d87dc1764f83f230b0aca5ce7a1a3..3bd6b928c14ff7c1e7e67e83ad19f2c7568db410 100755 (executable)
@@ -1505,6 +1505,12 @@ def put_op_name(family, cw):
     cw.block_start(line=f"static const char * const {map_name}[] =")
     for op_name, op in family.msgs.items():
         if op.rsp_value:
+            # Make sure we don't add duplicated entries, if multiple commands
+            # produce the same response in legacy families.
+            if family.rsp_by_value[op.rsp_value] != op:
+                cw.p(f'// skip "{op_name}", duplicate reply value')
+                continue
+
             if op.req_value == op.rsp_value:
                 cw.p(f'[{op.enum_name}] = "{op_name}",')
             else:
This page took 0.059733 seconds and 4 git commands to generate.