Squash to "use helpers in lib.sh" v5
Subsystems (3)
Geliang Tang
reviewercover Squash to "use helpers in lib.sh" v5
From: Geliang Tang <[email protected]>
Squash to:
v5, use helpers in lib.sh and net_helpers.sh
Based-on: <[email protected]>
Geliang Tang (4):
Squash to "selftests: net: lib: rename ns in setup_ns" Squash to "selftests: mptcp: lib: use setup/cleanup_ns helpers"
selftests: mptcp: diag: add ns name empty check in cleanup
selftests: mptcp: join: print title at the end of reset
tools/testing/selftests/net/lib.sh | 18 +++++++++--------- tools/testing/selftests/net/mptcp/diag.sh | 1 + .../testing/selftests/net/mptcp/mptcp_join.sh | 4 ++-- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 5 +---- 4 files changed, 13 insertions(+), 15 deletions(-)
Signature · 1 line
2.43.0
Geliang Tang
reviewerPATCH 1/4 Squash to "selftests: net: lib: rename ns in setup_ns"
From: Geliang Tang <[email protected]>
I think "ns_temp" is a better name than "_ns" here.
--- tools/testing/selftests/net/lib.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/testing/selftests/net/lib.sh +9 -9
@@ -167,11 +167,11 @@ cleanup_all_ns() # setup_ns local remote setup_ns() { - local _ns="" + local ns_temp="" local ns_name="" local ns_list=() for ns_name in "$@"; do - if [ "${ns_name}" = "_ns" ]; then + if [ "${ns_name}" = "ns_temp" ]; then echo "Failed to setup namespace '${ns_name}': invalid name" cleanup_ns "${ns_list[@]}" exit $ksft_fail
@@ -179,20 +179,20 @@ setup_ns() # Some test may setup/remove same netns multi times if [ -z "${!ns_name}" ]; then - _ns="${ns_name,,}-$(mktemp -u XXXXXX)" - eval "${ns_name}=${_ns}" + ns_temp="${ns_name,,}-$(mktemp -u XXXXXX)" + eval "${ns_name}=${ns_temp}" else - _ns="${!ns_name}" - cleanup_ns "${_ns}" + ns_temp="${!ns_name}" + cleanup_ns "${ns_temp}" fi - if ! ip netns add "${_ns}"; then + if ! ip netns add "${ns_temp}"; then echo "Failed to create namespace $ns_name" cleanup_ns "${ns_list[@]}" return $ksft_skip fi - ip -n "${_ns}" link set lo up - ns_list+=("${_ns}") + ip -n "${ns_temp}" link set lo up + ns_list+=("${ns_temp}") done NS_LIST+=("${ns_list[@]}") }
Signature · 1 line
2.43.0
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 1/4] Squash to "selftests: net: lib: rename ns in setup_ns"
Hi Geliang,
Quoted 3 lines · Geliang Tang
From: Geliang Tang <[email protected]>
I think "
ns_temp" is a better name than "_ns" here.
Good point. But when looking at that, I think it would be even better to get rid of this variable.
I can suggest a patch in a v6.
Quoted 14 lines
Signed-off-by Geliang Tang <[email protected]>--- tools/testing/selftests/net/lib.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)tools/testing/selftests/net/lib.sh +0
-0@@ -167,11 +167,11 @@ cleanup_all_ns() # setup_ns local remote setup_ns() {
tools/testing/selftests/net/lib.sh cleanup_all_ns() · line 177
Quoted 10 lines
tools/testing/selftests/net/lib.sh +2
-2- local _ns="" + local ns_temp="" local ns_name="" local ns_list=() for ns_name in "$@"; do - if [ "${ns_name}" = "_ns" ]; then + if [ "${ns_name}" = "ns_temp" ]; then echo "Failed to setup namespace '${ns_name}': invalid name" cleanup_ns "${ns_list[@]}" exit $ksft_fail
I don't know if this check still makes sense. It could also conflict with ns_name...
Quoted 18 lines
tools/testing/selftests/net/lib.sh +5
-5@@ -179,20 +179,20 @@ setup_ns() # Some test may setup/remove same netns multi times if [ -z "${!ns_name}" ]; then - _ns="${ns_name,,}-$(mktemp -u XXXXXX)" - eval "${ns_name}=${_ns}" + ns_temp="${ns_name,,}-$(mktemp -u XXXXXX)" + eval "${ns_name}=${ns_temp}" else - _ns="${!ns_name}" - cleanup_ns "${_ns}" + ns_temp="${!ns_name}" + cleanup_ns "${ns_temp}" fi - if ! ip netns add "${_ns}"; then + if ! ip netns add "${ns_temp}"; then echo "Failed to create namespace $ns_name"
tools/testing/selftests/net/lib.sh setup_ns() · line 198
Quoted 10 lines
tools/testing/selftests/net/lib.sh +2
-2cleanup_ns "${ns_list[@]}" return $ksft_skip fi - ip -n "${_ns}" link set lo up - ns_list+=("${_ns}") + ip -n "${ns_temp}" link set lo up + ns_list+=("${ns_temp}") done NS_LIST+=("${ns_list[@]}") }
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerRe: [PATCH mptcp-next 1/4] Squash to "selftests: net: lib: rename ns in setup_ns"
Quoted 5 lines · Matthieu Baerts
Hi Geliang,
Quoted 2 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Quoted 7 lines
Quoted 1 line
I think "
ns_temp" is a better name than "_ns" here.Good point. But when looking at that, I think it would be even better to
get rid of this variable.I can suggest a patch in a v6.
Sure, let's drop this set and wait for a v6.
Thanks,
-Geliang
Quoted 63 lines
Quoted 23 lines
Signed-off-by Geliang Tang <[email protected]>---
tools/testing/selftests/net/lib.sh | 18 +++++++++---------1 file changed, 9 insertions(+), 9 deletions(-)tools/testing/selftests/net/lib.sh +1
-1@@ -167,11 +167,11 @@ cleanup_all_ns() # setup_ns local remote setup_ns() { - local _ns="" + local ns_temp=""local ns_name=""
local ns_list=()
forns_namein "$@"; dotools/testing/selftests/net/lib.sh +1
-1- if [ "${ns_name}" = "_ns" ]; then + if [ "${ns_name}" = "ns_temp" ]; thenQuoted 4 lines
echo "Failed to setup namespace '${ns_name}': invalid name"
cleanup_ns"${ns_list[@]}" exit $ksft_failI don't know if this check still makes sense. It could also conflict with
ns_name...Quoted 26 lines
tools/testing/selftests/net/lib.sh +0
-0@@ -179,20 +179,20 @@ setup_ns()
# Some test may setup/remove same netns multi times
if [ -z "${!ns_name}" ]; thentools/testing/selftests/net/lib.sh +2
-2- _ns="${ns_name,,}-$(mktemp -u XXXXXX)" - eval "${ns_name}=${_ns}" + ns_temp="${ns_name,,}-$(mktemp -u XXXXXX)" + eval "${ns_name}=${ns_temp}"else
tools/testing/selftests/net/lib.sh +2
-2- _ns="${!ns_name}" - cleanup_ns "${_ns}" + ns_temp="${!ns_name}" + cleanup_ns "${ns_temp}"fi
tools/testing/selftests/net/lib.sh +1
-1- if ! ip netns add "${_ns}"; then + if ! ip netns add "${ns_temp}"; thenecho "Failed to create namespace $ns_name"
cleanup_ns"${ns_list[@]}" return $ksft_skip
fitools/testing/selftests/net/lib.sh +2
-2- ip -n "${_ns}" link set lo up - ns_list+=("${_ns}") + ip -n "${ns_temp}" link set lo up + ns_list+=("${ns_temp}")Quoted 3 lines
done
NS_LIST+=("${ns_list[@]}")
}Cheers,
Matt
Geliang Tang
reviewerPATCH 2/4 Squash to "selftests: mptcp: lib: use setup/cleanup_ns helpers"
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
setup_ns exits when it fails, so I think no need to exit in mptcp_lib_ns_init anymore.
--- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_lib.sh +1 -4
@@ -428,10 +428,7 @@ mptcp_lib_check_tools() { } mptcp_lib_ns_init() { - if ! setup_ns ${@}; then - mptcp_lib_pr_fail "Failed to setup namespace ${@}" - exit ${KSFT_FAIL} - fi + setup_ns "${@}" local netns for netns in "${@}"; do
Signature · 1 line
2.43.0
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 2/4] Squash to "selftests: mptcp: lib: use setup/cleanup_ns helpers"
Hi Geliang,
Quoted 15 lines · Geliang Tang
From: Geliang Tang <[email protected]>
setup_nsexits when it fails, so I think no need to exit inmptcp_lib_ns_initanymore.Signed-off-by Geliang Tang <[email protected]>--- tools/testing/selftests/net/mptcp/mptcp_lib.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)tools/testing/selftests/net/mptcp/mptcp_lib.sh +0
-0
tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_check_tools() { · line 431
Quoted 8 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +1
-4@@ -428,10 +428,7 @@ mptcp_lib_check_tools() { } mptcp_lib_ns_init() { - if ! setup_ns ${@}; then - mptcp_lib_pr_fail "Failed to setup namespace ${@}" - exit ${KSFT_FAIL} - fi + setup_ns "${@}"
It only exits when there is an internal error (name conflict), but not if there was an issue with 'ip netns add'. I think it is safer to keep this check, no?
tools/testing/selftests/net/mptcp/mptcp_lib.sh mptcp_lib_check_tools() { · line 434
Quoted 3 lines
tools/testing/selftests/net/mptcp/mptcp_lib.sh +0
-0local netns for netns in "${@}"; do
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH 3/4 selftests: mptcp: diag: add ns name empty check in cleanup
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
mptcp_lib_ns_init may fail sometimes, then ns isn't setup correctly. In that case, cleanup is invoked, and ns is used in cleanup. So an "Invalid netns name ''" error occurs.
For example, these errors occur when invalid name is set to setup_ns:
Failed to setup namespace 'ns_temp': invalid name Invalid netns name ""
The patch adds an ns name empty check before using it in cleanup.
--- tools/testing/selftests/net/mptcp/diag.sh | 1 + 1 file changed, 1 insertion(+)
tools/testing/selftests/net/mptcp/diag.sh +1 -0
@@ -31,6 +31,7 @@ flush_pids() #shellcheck disable=SC2317 cleanup() { + [ -n "${ns}" ] && ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null mptcp_lib_ns_exit "${ns}"
Signature · 1 line
2.43.0
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 3/4] selftests: mptcp: diag: add ns name empty check in cleanup
Hi Geliang,
Quoted 10 lines · Geliang Tang
From: Geliang Tang <[email protected]>
mptcp_lib_ns_initmay fail sometimes, then ns isn't setup correctly. In that case, cleanup is invoked, and ns is used in cleanup. So an "Invalid netns name ''" error occurs.For example, these errors occur when invalid name is set to
setup_ns:Failed to setup namespace '
ns_temp': invalid name Invalid netns name ""
Mmh, I don't think this is needed: here, you explicitly caused the issue by picking an invalid name. That's the only case where the 'ns' variable will be not set. It should not fail with this error then.
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Geliang Tang
reviewerPATCH 4/4 selftests: mptcp: join: print title at the end of reset
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
init or init_partial may fail sometimes, in that case, titles shouldn't be printed out.
For example, these errors occur when invalid name is set to setup_ns:
001 no JOIN
Failed to setup namespace 'ns_temp': invalid name
"001 no JOIN" shouldn't be printed out in this case. So the patch moves mptcp_lib_print_title from the front of init to the end of reset().
--- tools/testing/selftests/net/mptcp/mptcp_join.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_join.sh +2 -2
@@ -269,8 +269,6 @@ reset() return 1 fi - mptcp_lib_print_title "${TEST_NAME}" - if [ "${init}" != "1" ]; then init else
@@ -279,6 +277,8 @@ reset() init_partial + mptcp_lib_print_title "${TEST_NAME}" + return 0 }
Signature · 1 line
2.43.0
Matthieu Baerts
maintainerRe: [PATCH mptcp-next 4/4] selftests: mptcp: join: print title at the end of reset
Quoted 11 lines · Geliang Tang
From: Geliang Tang <[email protected]>
init or
init_partialmay fail sometimes, in that case, titles shouldn't be printed out.For example, these errors occur when invalid name is set to
setup_ns:001 no JOIN
Failed to setup namespace 'ns_temp': invalid name"001 no JOIN" shouldn't be printed out in this case.
Why? For me, it sounds better to print the title before creating the
netns: each subtest creates a new netns, that's part of the test, it is important to know which one had an issue. Imagine there is an error later:
001 no JOIN
syn [ OK ]
synack [ OK ]
ack [ OK ] 002 single subflow, limited by client
mount --make-shared /run/netns failed: Operation not permitted Failed to create namespace ns0
Here, it is clear the issue is when creating a new netns with the 2nd test, that's not linked to the first one, no?
Cheers,
Matt
Signature · 1 line
Sponsored by the NGI0 Core fund.
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Success! ✅
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/9235742827
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/2a3ec46fa592
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=855843
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)