From: Jakub Kicinski <kuba@kernel.org>
To: Stanislav Fomichev <sdf@fomichev.me>
Cc: netdev@vger.kernel.org, davem@davemloft.net, edumazet@google.com,
pabeni@redhat.com, Shuah Khan <shuah@kernel.org>,
Joe Damato <jdamato@fastly.com>, Petr Machata <petrm@nvidia.com>,
linux-kselftest@vger.kernel.org
Subject: Re: [PATCH net-next 1/2] selftests: net-drv: exercise queue stats when the device is down
Date: Mon, 29 Jul 2024 18:58:01 -0700 [thread overview]
Message-ID: <20240729185801.7013ecd3@kernel.org> (raw)
In-Reply-To: <20240729221042.2700882-1-sdf@fomichev.me>
On Mon, 29 Jul 2024 15:10:41 -0700 Stanislav Fomichev wrote:
> Verify that total device stats don't decrease after it has been turned down.
> Also make sure the device doesn't crash when we access per-queue stats
> when it's down (in case it tries to access some pointers that are NULL).
>
> KTAP version 1
> 1..5
> ok 1 stats.check_pause
> ok 2 stats.check_fec
> ok 3 stats.pkt_byte_sum
> ok 4 stats.qstat_by_ifindex
> ok 5 stats.check_down
> \# Totals: pass:5 fail:0 xfail:0 xpass:0 skip:0 error:0
nit: may be personal preference but if you indent by 2 spaces
that will neutralize the # as well
> +def check_down(cfg) -> None:
> + try:
> + qstat = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)
> + except NlError as e:
> + if e.error == 95:
> + raise KsftSkipEx("qstats not supported by the device")
> + raise
> +
> + ip(f"link set dev {cfg.dev['ifname']} down")
> +
> + try:
The rest of this test predates defer() but I think it may be cleaner:
ip(f"link set dev {cfg.dev['ifname']} down")
defer(ip, f"link set dev {cfg.dev['ifname']} up")
then you don't need to try/finally.
> + qstat = qstat[0]
> + qstat2 = netfam.qstats_get({"ifindex": cfg.ifindex}, dump=True)[0]
> + for k, v in qstat.items():
> + if k not in qstat2:
> + # skip the stats that are not globally preserved
> + continue
I think we should fail if stats disappear. I can't think of a legit
reason for that to happen.
> + if qstat2[k] < qstat[k]:
> + raise Exception(f"{k} ({qstat2[k]}) should be preserved but has lower value ({qstat[k]}) when the device is down")
ksft_ge(qstat2[k], qstat[k], comment=k)
?
> +
> + # exercise per-queue API to make sure that "device down" state
> + # is handled correctly and doesn't crash
> + netfam.qstats_get({"ifindex": cfg.ifindex, "scope": "queue"}, dump=True)
> + finally:
> + ip(f"link set dev {cfg.dev['ifname']} up")
> +
> +
> def main() -> None:
> with NetDrvEnv(__file__) as cfg:
> - ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex],
> + ksft_run([check_pause, check_fec, pkt_byte_sum, qstat_by_ifindex,
> + check_down],
> args=(cfg, ))
> ksft_exit()
>
prev parent reply other threads:[~2024-07-30 1:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-29 22:10 [PATCH net-next 1/2] selftests: net-drv: exercise queue stats when the device is down Stanislav Fomichev
2024-07-29 22:10 ` [PATCH net-next 2/2] selftests: net: ksft: support marking tests as disruptive Stanislav Fomichev
2024-07-30 2:00 ` Jakub Kicinski
2024-07-30 16:20 ` Stanislav Fomichev
2024-07-30 18:13 ` Jakub Kicinski
2024-07-30 1:58 ` Jakub Kicinski [this message]
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=20240729185801.7013ecd3@kernel.org \
--to=kuba@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jdamato@fastly.com \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=sdf@fomichev.me \
--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).