Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: drv-net: xdp: make the XDP qstats tests less flaky

The XDP qstats tests send 2k packets over a single socket.
Looks like when netdev CI is busy running those tests in QEMU
occasionally flakes. The target doesn't get to run at all
before all 2000 packets are sent.

Lower the number of packets to 1000 and reopen the socket
every 50 packets, to give RSS a chance to spread the packets
to multiple queues.

For the netdev CI testing either lowering the count or using
multiple sockets is enough, but let's do both for extra resiliency.

Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20251113152703.3819756-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+9 -6
+9 -6
tools/testing/selftests/drivers/net/xdp.py
··· 687 687 "/dev/null" 688 688 # Listener runs on "remote" in case of XDP_TX 689 689 rx_host = cfg.remote if act == XDPAction.TX else None 690 - # We want to spew 2000 packets quickly, bash seems to do a good enough job 691 - tx_udp = f"exec 5<>/dev/udp/{cfg.addr}/{port}; " \ 692 - "for i in `seq 2000`; do echo a >&5; done; exec 5>&-" 690 + # We want to spew 1000 packets quickly, bash seems to do a good enough job 691 + # Each reopening of the socket gives us a differenot local port (for RSS) 692 + tx_udp = "for _ in `seq 20`; do " \ 693 + f"exec 5<>/dev/udp/{cfg.addr}/{port}; " \ 694 + "for i in `seq 50`; do echo a >&5; done; " \ 695 + "exec 5>&-; done" 693 696 694 697 cfg.wait_hw_stats_settle() 695 698 # Qstats have more clearly defined semantics than rtnetlink. ··· 707 704 cfg.wait_hw_stats_settle() 708 705 after = cfg.netnl.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0] 709 706 710 - ksft_ge(after['rx-packets'] - before['rx-packets'], 2000) 707 + expected_pkts = 1000 708 + ksft_ge(after['rx-packets'] - before['rx-packets'], expected_pkts) 711 709 if act == XDPAction.TX: 712 - ksft_ge(after['tx-packets'] - before['tx-packets'], 2000) 710 + ksft_ge(after['tx-packets'] - before['tx-packets'], expected_pkts) 713 711 714 - expected_pkts = 2000 715 712 stats = _get_stats(prog_info["maps"]["map_xdp_stats"]) 716 713 ksft_eq(stats[XDPStats.RX.value], expected_pkts, "XDP RX stats mismatch") 717 714 if act == XDPAction.TX: