[PATCH mptcp-net 11/13] selftests: mptcp: userspace pm: skip if not supported

Matthieu Baerts posted 13 patches 2 years, 10 months ago
Maintainers: Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Shuah Khan <shuah@kernel.org>, Florian Westphal <fw@strlen.de>, Christoph Paasch <cpaasch@apple.com>, Mat Martineau <mathew.j.martineau@linux.intel.com>, Kishen Maloor <kishen.maloor@intel.com>, Dmytro Shytyi <dmytro@shytyi.net>, Geliang Tang <geliang.tang@suse.com>
There is a newer version of this series
[PATCH mptcp-net 11/13] selftests: mptcp: userspace pm: skip if not supported
Posted by Matthieu Baerts 2 years, 10 months ago
Selftests are supposed to run on any kernels, including the old ones not
supporting all MPTCP features.

One of them is the new MPTCP Userspace PM. We can skip these tests if
the feature is not supported.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
Fixes: 259a834fadda ("selftests: mptcp: functional tests for the userspace PM type")
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
---
 tools/testing/selftests/net/mptcp/mptcp_join.sh   | 6 ++++++
 tools/testing/selftests/net/mptcp/userspace_pm.sh | 6 ++++++
 2 files changed, 12 insertions(+)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 315ea136fe2c..4bc181485fef 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -135,6 +135,7 @@ cleanup_partial()
 check_tools()
 {
 	mptcp_lib_check_mptcp
+	mptcp_lib_check_kallsyms
 
 	if ! ip -Version &> /dev/null; then
 		echo "SKIP: Could not run test without ip tool"
@@ -3045,6 +3046,11 @@ fail_tests()
 
 userspace_tests()
 {
+	if ! mptcp_lib_kallsyms_has 'mptcp_userspace_pm_'; then
+		echo "userspace pm tests are not supported by the kernel: SKIP"
+		return
+	fi
+
 	# userspace pm type prevents add_addr
 	if reset "userspace pm type prevents add_addr"; then
 		set_userspace_pm $ns1
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 192ab818f292..12556051a72a 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -4,6 +4,12 @@
 . "$(dirname "${0}")/mptcp_lib.sh"
 
 mptcp_lib_check_mptcp
+mptcp_lib_check_kallsyms
+
+if ! mptcp_lib_kallsyms_has 'mptcp_userspace_pm_'; then
+	echo "userspace pm tests are not supported by the kernel: SKIP"
+	exit ${KSFT_SKIP}
+fi
 
 ip -Version > /dev/null 2>&1
 if [ $? -ne 0 ];then

-- 
2.39.2
Re: [PATCH mptcp-net 11/13] selftests: mptcp: userspace pm: skip if not supported
Posted by Mat Martineau 2 years, 9 months ago
On Fri, 7 Apr 2023, Matthieu Baerts wrote:

> Selftests are supposed to run on any kernels, including the old ones not
> supporting all MPTCP features.
>
> One of them is the new MPTCP Userspace PM. We can skip these tests if
> the feature is not supported.
>
> Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
> Fixes: 259a834fadda ("selftests: mptcp: functional tests for the userspace PM type")
> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
> ---
> tools/testing/selftests/net/mptcp/mptcp_join.sh   | 6 ++++++
> tools/testing/selftests/net/mptcp/userspace_pm.sh | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> index 315ea136fe2c..4bc181485fef 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
> @@ -135,6 +135,7 @@ cleanup_partial()
> check_tools()
> {
> 	mptcp_lib_check_mptcp
> +	mptcp_lib_check_kallsyms
>
> 	if ! ip -Version &> /dev/null; then
> 		echo "SKIP: Could not run test without ip tool"
> @@ -3045,6 +3046,11 @@ fail_tests()
>
> userspace_tests()
> {
> +	if ! mptcp_lib_kallsyms_has 'mptcp_userspace_pm_'; then
> +		echo "userspace pm tests are not supported by the kernel: SKIP"
> +		return
> +	fi

In this case, it seems simpler to see if /proc/sys/net/mptcp/pm_type 
exists.

I didn't find as simple of an answer for MPTCP TFO and pm listener events, 
but maybe there's some other hint from the kernel about this 
functionality. The kallsyms approach seems a bit "brute force", if we can 
find similar lightweight checks for these other features.

If I missed a discussion on this topic please let me know and I will 
do a better search of the list archives :)


- Mat

> +
> 	# userspace pm type prevents add_addr
> 	if reset "userspace pm type prevents add_addr"; then
> 		set_userspace_pm $ns1
> diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
> index 192ab818f292..12556051a72a 100755
> --- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
> +++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
> @@ -4,6 +4,12 @@
> . "$(dirname "${0}")/mptcp_lib.sh"
>
> mptcp_lib_check_mptcp
> +mptcp_lib_check_kallsyms
> +
> +if ! mptcp_lib_kallsyms_has 'mptcp_userspace_pm_'; then
> +	echo "userspace pm tests are not supported by the kernel: SKIP"
> +	exit ${KSFT_SKIP}
> +fi
>
> ip -Version > /dev/null 2>&1
> if [ $? -ne 0 ];then
>
> -- 
> 2.39.2
>
>
>
Re: [PATCH mptcp-net 11/13] selftests: mptcp: userspace pm: skip if not supported
Posted by Matthieu Baerts 2 years, 9 months ago
Hi Mat,

On 25/04/2023 02:13, Mat Martineau wrote:
> On Fri, 7 Apr 2023, Matthieu Baerts wrote:
> 
>> Selftests are supposed to run on any kernels, including the old ones not
>> supporting all MPTCP features.
>>
>> One of them is the new MPTCP Userspace PM. We can skip these tests if
>> the feature is not supported.
>>
>> Link: https://github.com/multipath-tcp/mptcp_net-next/issues/368
>> Fixes: 259a834fadda ("selftests: mptcp: functional tests for the
>> userspace PM type")
>> Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
>> ---
>> tools/testing/selftests/net/mptcp/mptcp_join.sh   | 6 ++++++
>> tools/testing/selftests/net/mptcp/userspace_pm.sh | 6 ++++++
>> 2 files changed, 12 insertions(+)
>>
>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> index 315ea136fe2c..4bc181485fef 100755
>> --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
>> @@ -135,6 +135,7 @@ cleanup_partial()
>> check_tools()
>> {
>>     mptcp_lib_check_mptcp
>> +    mptcp_lib_check_kallsyms
>>
>>     if ! ip -Version &> /dev/null; then
>>         echo "SKIP: Could not run test without ip tool"
>> @@ -3045,6 +3046,11 @@ fail_tests()
>>
>> userspace_tests()
>> {
>> +    if ! mptcp_lib_kallsyms_has 'mptcp_userspace_pm_'; then
>> +        echo "userspace pm tests are not supported by the kernel: SKIP"
>> +        return
>> +    fi
> 
> In this case, it seems simpler to see if /proc/sys/net/mptcp/pm_type
> exists.

Indeed, good idea.

> I didn't find as simple of an answer for MPTCP TFO and pm listener
> events, but maybe there's some other hint from the kernel about this
> functionality. The kallsyms approach seems a bit "brute force", if we
> can find similar lightweight checks for these other features.
> 
> If I missed a discussion on this topic please let me know and I will do
> a better search of the list archives :)

I agree with you, the kallsyms approach seems a bit "brute force". In
previous discussions, we said we wanted something simple to make the
tests from LKFT on stable kernels useful: for the moment, many selftests
are marked as failed because a few subtests are always failure due to
unsupported features.

You probably read that we said we don't think it is a good idea for them
to run the latest selftests on older kernels but that's not something
they want to change. The recommended way for us to support that is to
try to use a feature and then check the error that is returned but this
doesn't always work. Either because we validate internal behaviours like
which packets have been exchanged: we can change the internal behaviour
without impacting the user API. Or because it is not be easy to put
everything in place (ns, network, etc.), then run a tool (mptcp_connect,
pm_nl_ctl, etc.) to see that a feature is not available, then we need to
propagate the error, clean everything, mark the subtest as skipped, etc.

That's why we are looking at "external" hints. Looking at kallsyms seems
to be a good enough approach but yes, if we can look at sysctl, that's
safer and lighter! :)

I will do that in a v2.

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net