Skip to content

Commit e8025e7

Browse files
committed
tools: ynl-gen: consider dump ops without a do "type-consistent"
If the type for the response to do and dump are the same we don't generate it twice. This is called "type_consistent" in the generator. Consider operations which only have dump to also be consistent. This removes unnecessary "_dump" from the names. There's a number of GET ops in classic Netlink which only have dump handlers. Make sure we output the "onesided" types, normally if the type is consistent we only output it when we render the do structures. Reviewed-by: Jacob Keller <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7e8ba0c commit e8025e7

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

tools/net/ynl/pyynl/ynl_gen_c.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,14 +1212,16 @@ def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
12121212

12131213
# 'do' and 'dump' response parsing is identical
12141214
self.type_consistent = True
1215+
self.type_oneside = False
12151216
if op_mode != 'do' and 'dump' in op:
12161217
if 'do' in op:
12171218
if ('reply' in op['do']) != ('reply' in op["dump"]):
12181219
self.type_consistent = False
12191220
elif 'reply' in op['do'] and op["do"]["reply"] != op["dump"]["reply"]:
12201221
self.type_consistent = False
12211222
else:
1222-
self.type_consistent = False
1223+
self.type_consistent = True
1224+
self.type_oneside = True
12231225

12241226
self.attr_set = attr_set
12251227
if not self.attr_set:
@@ -1516,7 +1518,9 @@ def op_prefix(ri, direction, deref=False):
15161518
suffix += f"{direction_to_suffix[direction]}"
15171519
else:
15181520
if direction == 'request':
1519-
suffix += '_req_dump'
1521+
suffix += '_req'
1522+
if not ri.type_oneside:
1523+
suffix += '_dump'
15201524
else:
15211525
if ri.type_consistent:
15221526
if deref:
@@ -1995,7 +1999,7 @@ def _print_type(ri, direction, struct):
19951999
if not direction and ri.type_name_conflict:
19962000
suffix += '_'
19972001

1998-
if ri.op_mode == 'dump':
2002+
if ri.op_mode == 'dump' and not ri.type_oneside:
19992003
suffix += '_dump'
20002004

20012005
ri.cw.block_start(line=f"struct {ri.family.c_name}{suffix}")
@@ -2979,7 +2983,7 @@ def main():
29792983
ri = RenderInfo(cw, parsed, args.mode, op, 'dump')
29802984
print_req_type(ri)
29812985
print_req_type_helpers(ri)
2982-
if not ri.type_consistent:
2986+
if not ri.type_consistent or ri.type_oneside:
29832987
print_rsp_type(ri)
29842988
print_wrapped_type(ri)
29852989
print_dump_prototype(ri)
@@ -3057,7 +3061,7 @@ def main():
30573061
if 'dump' in op:
30583062
cw.p(f"/* {op.enum_name} - dump */")
30593063
ri = RenderInfo(cw, parsed, args.mode, op, "dump")
3060-
if not ri.type_consistent:
3064+
if not ri.type_consistent or ri.type_oneside:
30613065
parse_rsp_msg(ri, deref=True)
30623066
print_req_free(ri)
30633067
print_dump_type_free(ri)

0 commit comments

Comments
 (0)