summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Damato <joe@dama.to>2026-07-28 09:09:27 -0700
committerJakub Kicinski <kuba@kernel.org>2026-07-29 16:59:11 -0700
commit9404fe514efccfd01abc9746f4714de63fe54f1f (patch)
tree94a40004d5967e34232a5d6bb66fe5d3dd70c931
parent0982666c1bb02792970a7f3ba27f0b4af68e6245 (diff)
downloadlinux-next-9404fe514efccfd01abc9746f4714de63fe54f1f.tar.gz
linux-next-9404fe514efccfd01abc9746f4714de63fe54f1f.zip
selftests/net: psock: Generalize stats check
Generalize stats check code so that callers can specify the expected packets. Signed-off-by: Joe Damato <joe@dama.to> Reviewed-by: Willem de Bruijn <willemb@google.com> Link: https://patch.msgid.link/20260728160935.4128982-3-joe@dama.to Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--tools/testing/selftests/net/psock_snd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/tools/testing/selftests/net/psock_snd.c b/tools/testing/selftests/net/psock_snd.c
index bb9a9cfdbe95..d506ea19491b 100644
--- a/tools/testing/selftests/net/psock_snd.c
+++ b/tools/testing/selftests/net/psock_snd.c
@@ -440,7 +440,7 @@ static void parse_opts(int argc, char **argv)
error(1, 0, "option aux data (-a) conflicts with drop (-D)");
}
-static void check_packet_stats(int fd)
+static void check_packet_stats(int fd, unsigned int expected_packets)
{
struct tpacket_stats st = {};
socklen_t len = sizeof(st);
@@ -459,8 +459,9 @@ static void check_packet_stats(int fd)
if (st.tp_drops == 0)
error(1, 0, "stats: expected drops but tp_drops == 0");
} else {
- if (st.tp_packets != 1)
- error(1, 0, "stats: tp_packets %u != 1", st.tp_packets);
+ if (st.tp_packets != expected_packets)
+ error(1, 0, "stats: tp_packets %u != %u",
+ st.tp_packets, expected_packets);
if (st.tp_drops != 0)
error(1, 0, "stats: tp_drops %u != 0", st.tp_drops);
@@ -490,7 +491,7 @@ static void run_test(void)
total_len = do_tx();
if (cfg_drop) {
- check_packet_stats(fds);
+ check_packet_stats(fds, 0);
goto out;
}
@@ -498,7 +499,7 @@ static void run_test(void)
if (cfg_payload_len == DATA_LEN && !cfg_use_vlan) {
do_rx(fds, total_len - sizeof(struct virtio_net_hdr),
tbuf + sizeof(struct virtio_net_hdr), true);
- check_packet_stats(fds);
+ check_packet_stats(fds, 1);
}
do_rx(fdr, cfg_payload_len, tbuf + total_len - cfg_payload_len, false);