Skip to content

Commit c011187

Browse files
kuba-moodavem330
authored andcommitted
tools: ynl: add --dbg-small-recv for easier kernel testing
Most "production" netlink clients use large buffers to make dump efficient, which means that handling of dump continuation in the kernel is not very well tested. Add an option for debugging / testing handling of dumps. It enables printing of extra netlink-level debug and lowers the recv() buffer size in one go. When used without any argument (--dbg-small-recv) it picks a very small default (4000), explicit size can be set, too (--dbg-small-recv 5000). Example: $ ./cli.py [...] --dbg-small-recv Recv: read 3712 bytes, 29 messages nl_len = 128 (112) nl_flags = 0x0 nl_type = 19 [...] nl_len = 128 (112) nl_flags = 0x0 nl_type = 19 Recv: read 3968 bytes, 31 messages nl_len = 128 (112) nl_flags = 0x0 nl_type = 19 [...] nl_len = 128 (112) nl_flags = 0x0 nl_type = 19 Recv: read 532 bytes, 5 messages nl_len = 128 (112) nl_flags = 0x0 nl_type = 19 [...] nl_len = 128 (112) nl_flags = 0x0 nl_type = 19 nl_len = 20 (4) nl_flags = 0x2 nl_type = 3 (the [...] are edits to shorten the commit message). Note that the first message of the dump is sized conservatively by the kernel. Signed-off-by: Jakub Kicinski <kuba@kernel.org> Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a6a4152 commit c011187

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/net/ynl/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def main():
3838
const=Netlink.NLM_F_APPEND)
3939
parser.add_argument('--process-unknown', action=argparse.BooleanOptionalAction)
4040
parser.add_argument('--output-json', action='store_true')
41+
parser.add_argument('--dbg-small-recv', default=0, const=4000,
42+
action='store', nargs='?', type=int)
4143
args = parser.parse_args()
4244

4345
def output(msg):
@@ -53,7 +55,10 @@ def output(msg):
5355
if args.json_text:
5456
attrs = json.loads(args.json_text)
5557

56-
ynl = YnlFamily(args.spec, args.schema, args.process_unknown)
58+
ynl = YnlFamily(args.spec, args.schema, args.process_unknown,
59+
recv_size=args.dbg_small_recv)
60+
if args.dbg_small_recv:
61+
ynl.set_recv_dbg(True)
5762

5863
if args.ntf:
5964
ynl.ntf_subscribe(args.ntf)

0 commit comments

Comments
 (0)