Skip to content

Commit 39f04b1

Browse files
committed
tools: ynl: fix duplicate op name in devlink
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: f2f9dd1 ("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]>
1 parent 2be35a6 commit 39f04b1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

tools/net/ynl/generated/devlink-user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/* Enums */
1616
static const char * const devlink_op_strmap[] = {
1717
[3] = "get",
18-
[7] = "port-get",
18+
// skip "port-get", duplicate reply value
1919
[DEVLINK_CMD_PORT_NEW] = "port-new",
2020
[13] = "sb-get",
2121
[17] = "sb-pool-get",

tools/net/ynl/ynl-gen-c.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,12 @@ def put_op_name(family, cw):
15051505
cw.block_start(line=f"static const char * const {map_name}[] =")
15061506
for op_name, op in family.msgs.items():
15071507
if op.rsp_value:
1508+
# Make sure we don't add duplicated entries, if multiple commands
1509+
# produce the same response in legacy families.
1510+
if family.rsp_by_value[op.rsp_value] != op:
1511+
cw.p(f'// skip "{op_name}", duplicate reply value')
1512+
continue
1513+
15081514
if op.req_value == op.rsp_value:
15091515
cw.p(f'[{op.enum_name}] = "{op_name}",')
15101516
else:

0 commit comments

Comments
 (0)