[PATCH mptcp-next v4 4/6] selftests: mptcp: diag: trap cleanup after ns_init

Geliang Tang posted 6 patches 3 months, 3 weeks ago
There is a newer version of this series
[PATCH mptcp-next v4 4/6] selftests: mptcp: diag: trap cleanup after ns_init
Posted by Geliang Tang 3 months, 3 weeks ago
From: Geliang Tang <tanggeliang@kylinos.cn>

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. The patch moves "trap cleanup" from the front
of mptcp_lib_ns_init to the back of it to fix this.

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 tools/testing/selftests/net/mptcp/diag.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 776d43a6922d..cabe6f8f489f 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -266,8 +266,8 @@ wait_connected()
 	done
 }
 
-trap cleanup EXIT
 mptcp_lib_ns_init ns
+trap cleanup EXIT
 
 echo "a" | \
 	timeout ${timeout_test} \
-- 
2.43.0