From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
Jakub Kicinski <kuba@kernel.org>,
shuah@kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH net 5/5] selftests: net-drv: stats: sanity check netlink dumps
Date: Fri, 13 Dec 2024 07:22:44 -0800 [thread overview]
Message-ID: <20241213152244.3080955-6-kuba@kernel.org> (raw)
In-Reply-To: <20241213152244.3080955-1-kuba@kernel.org>
Sanity check netlink dumps, to make sure dumps don't have
repeated entries or gaps in IDs.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: shuah@kernel.org
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/drivers/net/stats.py | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/drivers/net/stats.py b/tools/testing/selftests/drivers/net/stats.py
index 63e3c045a3b2..031ac9def6c0 100755
--- a/tools/testing/selftests/drivers/net/stats.py
+++ b/tools/testing/selftests/drivers/net/stats.py
@@ -110,6 +110,23 @@ rtnl = RtnlFamily()
ksft_ge(triple[1][key], triple[0][key], comment="bad key: " + key)
ksft_ge(triple[2][key], triple[1][key], comment="bad key: " + key)
+ # Sanity check the dumps
+ queues = NetdevFamily(recv_size=4096).qstats_get({"scope": "queue"}, dump=True)
+ # Reformat the output into {ifindex: {rx: [id, id, ...], tx: [id, id, ...]}}
+ parsed = {}
+ for entry in queues:
+ ifindex = entry["ifindex"]
+ if ifindex not in parsed:
+ parsed[ifindex] = {"rx":[], "tx": []}
+ parsed[ifindex][entry["queue-type"]].append(entry['queue-id'])
+ # Now, validate
+ for ifindex, queues in parsed.items():
+ for qtype in ['rx', 'tx']:
+ ksft_eq(len(queues[qtype]), len(set(queues[qtype])),
+ comment="repeated queue keys")
+ ksft_eq(len(queues[qtype]), max(queues[qtype]) + 1,
+ comment="missing queue keys")
+
# Test invalid dumps
# 0 is invalid
with ksft_raises(NlError) as cm:
@@ -158,7 +175,7 @@ rtnl = RtnlFamily()
def main() -> None:
- with NetDrvEnv(__file__) as cfg:
+ with NetDrvEnv(__file__, queue_count=100) as cfg:
ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex,
check_down],
args=(cfg, ))
--
2.47.1
next prev parent reply other threads:[~2024-12-13 15:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-13 15:22 [PATCH net 0/5] netdev: fix repeated netlink messages in queue dumps Jakub Kicinski
2024-12-13 15:22 ` [PATCH net 1/5] netdev: fix repeated netlink messages in queue dump Jakub Kicinski
2024-12-13 21:41 ` Joe Damato
2024-12-13 15:22 ` [PATCH net 2/5] netdev: fix repeated netlink messages in queue stats Jakub Kicinski
2024-12-13 21:42 ` Joe Damato
2024-12-13 15:22 ` [PATCH net 3/5] selftests: net: support setting recv_size in YNL Jakub Kicinski
2024-12-13 21:45 ` Joe Damato
2024-12-16 10:37 ` Petr Machata
2024-12-13 15:22 ` [PATCH net 4/5] selftests: net-drv: queues: sanity check netlink dumps Jakub Kicinski
2024-12-13 21:47 ` Joe Damato
2024-12-16 10:46 ` Petr Machata
2024-12-13 15:22 ` Jakub Kicinski [this message]
2024-12-16 10:53 ` [PATCH net 5/5] selftests: net-drv: stats: " Petr Machata
2024-12-17 1:29 ` Jakub Kicinski
2024-12-13 21:52 ` [PATCH net 0/5] netdev: fix repeated netlink messages in queue dumps Joe Damato
2024-12-14 1:38 ` Jakub Kicinski
2024-12-17 1:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241213152244.3080955-6-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).