]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests: mptcp: lib: get counters from nstat history
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Fri, 14 Nov 2025 18:12:09 +0000 (19:12 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 18 Nov 2025 03:27:47 +0000 (19:27 -0800)
commit71388a9f331da20bab70e09bdf010f925ad7ce79
tree37362cc80f57c9e27e3300fda24a61c2fcec6b45
parent658e531417801cd8d9aac630cee712e160ab5380
selftests: mptcp: lib: get counters from nstat history

Before, 'nstat' was used to retrieve each individual counter: this means
querying 4 different sources from /proc/net and iterating over 100+
counters each time. Instead, the stats could be retrieved once, and the
output file could be parsed for each counter. Even better, such file is
already present: the nstat history file.

To be able to get this working, the nstat history file also needs to
contains zero counters too, so it is still possible to know if a counter
is missing or set to 0.

This also simplifies mptcp_connect.sh: instead of checking multiple
counters before and after a test to compute the difference, the stats
history files can be reset before each test, and nstat can display only
the difference.

mptcp_lib_get_counter() continues to work when no history file is
available: by fetching nstat directly, like before. This is the case in
diag.sh and userspace_pm.sh where there is no need to save the history
file. This is also the case in mptcp_join.sh, when 'run_tests' is
executed in the background: easier to continue fetching counters than
updating the history each time it is needed.

Note: 'nstat' is called with '-s' in mptcp_lib_nstat_get(), so this
helper can be called multiple times during the test if needed.

Acked-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20251114-net-next-mptcp-sft-count-cache-stats-timeout-v1-5-863cb04e1b7b@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/mptcp_connect.sh
tools/testing/selftests/net/mptcp/mptcp_lib.sh