* [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2
@ 2024-02-22 3:40 Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 1/4] selftests: mptcp: add local variables rndh Geliang Tang
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Geliang Tang @ 2024-02-22 3:40 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
v4:
- address Matt's comments in v3 except
- keep #1, #3 as separate patches, not squash them into #2, to keep #2
clean.
v3:
- patch #2, drop this line in mptcp_lib_ns_exit():
rm -f /tmp/"$netns".{nstat,out}
Geliang Tang (4):
selftests: mptcp: add local variables rndh
selftests: mptcp: add mptcp_lib_ns_init/exit helpers
selftests: mptcp: more operations in ns_init/exit
selftests: mptcp: add mptcp_lib_events helper
tools/testing/selftests/net/mptcp/diag.sh | 9 ++---
.../selftests/net/mptcp/mptcp_connect.sh | 28 +++++--------
.../testing/selftests/net/mptcp/mptcp_join.sh | 26 ++----------
.../testing/selftests/net/mptcp/mptcp_lib.sh | 40 +++++++++++++++++++
.../selftests/net/mptcp/mptcp_sockopt.sh | 22 +++-------
.../testing/selftests/net/mptcp/pm_netlink.sh | 10 ++---
.../selftests/net/mptcp/simult_flows.sh | 21 +++-------
.../selftests/net/mptcp/userspace_pm.sh | 29 +++-----------
8 files changed, 77 insertions(+), 108 deletions(-)
--
2.40.1
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH mptcp-next v4 1/4] selftests: mptcp: add local variables rndh
2024-02-22 3:40 [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Geliang Tang
@ 2024-02-22 3:40 ` Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 2/4] selftests: mptcp: add mptcp_lib_ns_init/exit helpers Geliang Tang
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Geliang Tang @ 2024-02-22 3:40 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
This patch adds local variables rndh in do_transfer() functions both in
mptcp_connect.sh and simult_flows.sh, setting it with ${ns1:4}, not the
global variable rndh. The global one is hidden in the next commit.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_connect.sh | 1 +
tools/testing/selftests/net/mptcp/simult_flows.sh | 1 +
2 files changed, 2 insertions(+)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index ea52110c3fbc..b609649311f6 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -348,6 +348,7 @@ do_transfer()
if $capture; then
local capuser
+ local rndh="${connector_ns:4}"
if [ -z $SUDO_USER ] ; then
capuser=""
else
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 7d8388ecc966..8a4520f29601 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -139,6 +139,7 @@ do_transfer()
if $capture; then
local capuser
+ local rndh="${ns1:4}"
if [ -z $SUDO_USER ] ; then
capuser=""
else
--
2.40.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH mptcp-next v4 2/4] selftests: mptcp: add mptcp_lib_ns_init/exit helpers
2024-02-22 3:40 [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 1/4] selftests: mptcp: add local variables rndh Geliang Tang
@ 2024-02-22 3:40 ` Geliang Tang
2024-02-22 10:34 ` Matthieu Baerts
2024-02-22 3:40 ` [PATCH mptcp-next v4 3/4] selftests: mptcp: more operations in ns_init/exit Geliang Tang
` (2 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Geliang Tang @ 2024-02-22 3:40 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Add helpers mptcp_lib_ns_init() and mptcp_lib_ns_exit() in mptcp_lib.sh to
initialize and delete the given namespaces. Then every test script can
invoke these helpers and use all namespaces.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/diag.sh | 9 +++-----
.../selftests/net/mptcp/mptcp_connect.sh | 23 ++++++++-----------
.../testing/selftests/net/mptcp/mptcp_join.sh | 11 ++-------
.../testing/selftests/net/mptcp/mptcp_lib.sh | 22 ++++++++++++++++++
.../selftests/net/mptcp/mptcp_sockopt.sh | 17 +++++---------
.../testing/selftests/net/mptcp/pm_netlink.sh | 9 +++-----
.../selftests/net/mptcp/simult_flows.sh | 16 ++++---------
.../selftests/net/mptcp/userspace_pm.sh | 14 ++++-------
8 files changed, 54 insertions(+), 67 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/selftests/net/mptcp/diag.sh
index 60a7009ce1b5..24cffd94baae 100755
--- a/tools/testing/selftests/net/mptcp/diag.sh
+++ b/tools/testing/selftests/net/mptcp/diag.sh
@@ -3,9 +3,7 @@
. "$(dirname "${0}")/mptcp_lib.sh"
-sec=$(date +%s)
-rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-ns="ns1-$rndh"
+ns=""
ksft_skip=4
test_cnt=1
timeout_poll=30
@@ -30,7 +28,7 @@ cleanup()
{
ip netns pids "${ns}" | xargs --no-run-if-empty kill -SIGKILL &>/dev/null
- ip netns del $ns
+ mptcp_lib_ns_exit "${ns}"
}
mptcp_lib_check_mptcp
@@ -205,8 +203,7 @@ wait_connected()
}
trap cleanup EXIT
-ip netns add $ns
-ip -n $ns link set dev lo up
+mptcp_lib_ns_init ns
echo "a" | \
timeout ${timeout_test} \
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index b609649311f6..92f6260ba9f3 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -121,12 +121,10 @@ while getopts "$optstring" option;do
esac
done
-sec=$(date +%s)
-rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-ns1="ns1-$rndh"
-ns2="ns2-$rndh"
-ns3="ns3-$rndh"
-ns4="ns4-$rndh"
+ns1=""
+ns2=""
+ns3=""
+ns4=""
TEST_COUNT=0
TEST_GROUP=""
@@ -140,9 +138,9 @@ cleanup()
local netns
for netns in "$ns1" "$ns2" "$ns3" "$ns4";do
- ip netns del $netns
rm -f /tmp/$netns.{nstat,out}
done
+ mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" "${ns4}"
}
mptcp_lib_check_mptcp
@@ -158,10 +156,7 @@ cin_disconnect="$cin".disconnect
cout_disconnect="$cout".disconnect
trap cleanup EXIT
-for i in "$ns1" "$ns2" "$ns3" "$ns4";do
- ip netns add $i || exit $ksft_skip
- ip -net $i link set lo up
-done
+mptcp_lib_ns_init ns1 ns2 ns3 ns4
# "$ns1" ns2 ns3 ns4
# ns1eth2 ns2eth1 ns2eth3 ns3eth2 ns3eth4 ns4eth3
@@ -251,8 +246,8 @@ fi
check_mptcp_disabled()
{
- local disabled_ns="ns_disabled-$rndh"
- ip netns add ${disabled_ns} || exit $ksft_skip
+ local disabled_ns
+ mptcp_lib_ns_init disabled_ns
# net.mptcp.enabled should be enabled by default
if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
@@ -266,7 +261,7 @@ check_mptcp_disabled()
local err=0
LC_ALL=C ip netns exec ${disabled_ns} ./mptcp_connect -p 10000 -s MPTCP 127.0.0.1 < "$cin" 2>&1 | \
grep -q "^socket: Protocol not available$" && err=1
- ip netns delete ${disabled_ns}
+ mptcp_lib_ns_exit "${disabled_ns}"
if [ ${err} -eq 0 ]; then
echo -e "New MPTCP socket cannot be blocked via sysctl\t\t[ FAIL ]"
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index aedc5698f26a..612470244c58 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -86,17 +86,10 @@ init_partial()
{
capout=$(mktemp)
- local sec rndh
- sec=$(date +%s)
- rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-
- ns1="ns1-$rndh"
- ns2="ns2-$rndh"
+ mptcp_lib_ns_init ns1 ns2
local netns
for netns in "$ns1" "$ns2"; do
- ip netns add $netns || exit $ksft_skip
- ip -net $netns link set lo up
ip netns exec $netns sysctl -q net.mptcp.enabled=1
ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true
ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
@@ -147,9 +140,9 @@ cleanup_partial()
local netns
for netns in "$ns1" "$ns2"; do
- ip netns del $netns
rm -f /tmp/$netns.{nstat,out}
done
+ mptcp_lib_ns_exit "${ns1}" "${ns2}"
}
init() {
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index 556a7d9784d7..fcb3afb4d51f 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -373,3 +373,25 @@ mptcp_lib_check_output() {
return 1
fi
}
+
+mptcp_lib_ns_init() {
+ local sec rndh
+
+ sec=$(date +%s)
+ rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX)
+
+ local netns
+ for netns in "${@}"; do
+ eval "${netns}=${netns}-${rndh}"
+
+ ip netns add "${!netns}" || exit ${KSFT_SKIP}
+ ip -net "${!netns}" link set lo up
+ done
+}
+
+mptcp_lib_ns_exit() {
+ local netns
+ for netns in "${@}"; do
+ ip netns del "$netns"
+ done
+}
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index fd7de1b3dc55..5fa5fa8cab71 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -14,11 +14,9 @@ timeout_test=$((timeout_poll * 2 + 1))
iptables="iptables"
ip6tables="ip6tables"
-sec=$(date +%s)
-rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-ns1="ns1-$rndh"
-ns2="ns2-$rndh"
-ns_sbox="ns_sbox-$rndh"
+ns1=""
+ns2=""
+ns_sbox=""
add_mark_rules()
{
@@ -40,10 +38,10 @@ add_mark_rules()
init()
{
+ mptcp_lib_ns_init ns1 ns2 ns_sbox
+
local netns
for netns in "$ns1" "$ns2" "$ns_sbox";do
- ip netns add $netns || exit $ksft_skip
- ip -net $netns link set lo up
ip netns exec $netns sysctl -q net.mptcp.enabled=1
ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
@@ -79,10 +77,7 @@ init()
cleanup()
{
- local netns
- for netns in "$ns1" "$ns2" "$ns_sbox"; do
- ip netns del $netns
- done
+ mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns_sbox}"
rm -f "$cin" "$cout"
rm -f "$sin" "$sout"
}
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 1ec9d8622fc9..30ec0ec3d68f 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -24,15 +24,13 @@ while getopts "$optstring" option;do
esac
done
-sec=$(date +%s)
-rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-ns1="ns1-$rndh"
+ns1=""
err=$(mktemp)
cleanup()
{
rm -f $err
- ip netns del $ns1
+ mptcp_lib_ns_exit "${ns1}"
}
mptcp_lib_check_mptcp
@@ -40,8 +38,7 @@ mptcp_lib_check_tools ip
trap cleanup EXIT
-ip netns add $ns1 || exit $ksft_skip
-ip -net $ns1 link set lo up
+mptcp_lib_ns_init ns1
ip netns exec $ns1 sysctl -q net.mptcp.enabled=1
check()
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index 8a4520f29601..c5128d690c46 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -3,11 +3,9 @@
. "$(dirname "${0}")/mptcp_lib.sh"
-sec=$(date +%s)
-rndh=$(printf %x $sec)-$(mktemp -u XXXXXX)
-ns1="ns1-$rndh"
-ns2="ns2-$rndh"
-ns3="ns3-$rndh"
+ns1=""
+ns2=""
+ns3=""
capture=false
ksft_skip=4
timeout_poll=30
@@ -36,10 +34,7 @@ cleanup()
rm -f "$large" "$small"
rm -f "$capout"
- local netns
- for netns in "$ns1" "$ns2" "$ns3";do
- ip netns del $netns
- done
+ mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}"
}
mptcp_lib_check_mptcp
@@ -65,9 +60,8 @@ setup()
trap cleanup EXIT
+ mptcp_lib_ns_init ns1 ns2 ns3
for i in "$ns1" "$ns2" "$ns3";do
- ip netns add $i || exit $ksft_skip
- ip -net $i link set lo up
ip netns exec $i sysctl -q net.ipv4.conf.all.rp_filter=0
ip netns exec $i sysctl -q net.ipv4.conf.default.rp_filter=0
done
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 629fc5d0ecc5..e3092696d2de 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -50,10 +50,8 @@ app6_port=50004
client_addr_id=${RANDOM:0:2}
server_addr_id=${RANDOM:0:2}
-sec=$(date +%s)
-rndh=$(printf %x "$sec")-$(mktemp -u XXXXXX)
-ns1="ns1-$rndh"
-ns2="ns2-$rndh"
+ns1=""
+ns2=""
ret=0
test_name=""
@@ -118,10 +116,7 @@ cleanup()
mptcp_lib_kill_wait $pid
done
- local netns
- for netns in "$ns1" "$ns2" ;do
- ip netns del "$netns"
- done
+ mptcp_lib_ns_exit "${ns1}" "${ns2}"
rm -rf $file $client_evts $server_evts
@@ -131,9 +126,8 @@ cleanup()
trap cleanup EXIT
# Create and configure network namespaces for testing
+mptcp_lib_ns_init ns1 ns2
for i in "$ns1" "$ns2" ;do
- ip netns add "$i" || exit 1
- ip -net "$i" link set lo up
ip netns exec "$i" sysctl -q net.mptcp.enabled=1
ip netns exec "$i" sysctl -q net.mptcp.pm_type=1
done
--
2.40.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH mptcp-next v4 3/4] selftests: mptcp: more operations in ns_init/exit
2024-02-22 3:40 [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 1/4] selftests: mptcp: add local variables rndh Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 2/4] selftests: mptcp: add mptcp_lib_ns_init/exit helpers Geliang Tang
@ 2024-02-22 3:40 ` Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Geliang Tang
2024-02-22 10:30 ` [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Matthieu Baerts
4 siblings, 0 replies; 11+ messages in thread
From: Geliang Tang @ 2024-02-22 3:40 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
Set more the default sysctl values in mptcp_lib_ns_init(). It is fine to
do that everywhere, because they could be overridden latter if needed.
mptcp_lib_ns_exit() now also try to remove temp netns files used for the
stats even for selftests not using them. That's fine to do that because
these files have a unique name.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_connect.sh | 4 ----
tools/testing/selftests/net/mptcp/mptcp_join.sh | 7 -------
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 4 ++++
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh | 7 -------
tools/testing/selftests/net/mptcp/pm_netlink.sh | 1 -
tools/testing/selftests/net/mptcp/simult_flows.sh | 4 ----
tools/testing/selftests/net/mptcp/userspace_pm.sh | 1 -
7 files changed, 4 insertions(+), 24 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
index 92f6260ba9f3..b53ae64ec08c 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
@@ -136,10 +136,6 @@ cleanup()
rm -f "$sin" "$sout"
rm -f "$capout"
- local netns
- for netns in "$ns1" "$ns2" "$ns3" "$ns4";do
- rm -f /tmp/$netns.{nstat,out}
- done
mptcp_lib_ns_exit "${ns1}" "${ns2}" "${ns3}" "${ns4}"
}
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 612470244c58..2d9cf6f3bbf3 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -90,10 +90,7 @@ init_partial()
local netns
for netns in "$ns1" "$ns2"; do
- ip netns exec $netns sysctl -q net.mptcp.enabled=1
ip netns exec $netns sysctl -q net.mptcp.pm_type=0 2>/dev/null || true
- ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
- ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
if $checksum; then
ip netns exec $netns sysctl -q net.mptcp.checksum_enabled=1
fi
@@ -138,10 +135,6 @@ cleanup_partial()
{
rm -f "$capout"
- local netns
- for netns in "$ns1" "$ns2"; do
- rm -f /tmp/$netns.{nstat,out}
- done
mptcp_lib_ns_exit "${ns1}" "${ns2}"
}
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index fcb3afb4d51f..f65a31594829 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -386,6 +386,9 @@ mptcp_lib_ns_init() {
ip netns add "${!netns}" || exit ${KSFT_SKIP}
ip -net "${!netns}" link set lo up
+ ip netns exec "${!netns}" sysctl -q net.mptcp.enabled=1
+ ip netns exec "${!netns}" sysctl -q net.ipv4.conf.all.rp_filter=0
+ ip netns exec "${!netns}" sysctl -q net.ipv4.conf.default.rp_filter=0
done
}
@@ -393,5 +396,6 @@ mptcp_lib_ns_exit() {
local netns
for netns in "${@}"; do
ip netns del "$netns"
+ rm -f /tmp/"$netns".{nstat,out}
done
}
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
index 5fa5fa8cab71..7dd0e5467d35 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
@@ -40,13 +40,6 @@ init()
{
mptcp_lib_ns_init ns1 ns2 ns_sbox
- local netns
- for netns in "$ns1" "$ns2" "$ns_sbox";do
- ip netns exec $netns sysctl -q net.mptcp.enabled=1
- ip netns exec $netns sysctl -q net.ipv4.conf.all.rp_filter=0
- ip netns exec $netns sysctl -q net.ipv4.conf.default.rp_filter=0
- done
-
local i
for i in `seq 1 4`; do
ip link add ns1eth$i netns "$ns1" type veth peer name ns2eth$i netns "$ns2"
diff --git a/tools/testing/selftests/net/mptcp/pm_netlink.sh b/tools/testing/selftests/net/mptcp/pm_netlink.sh
index 30ec0ec3d68f..c7c46152f6fd 100755
--- a/tools/testing/selftests/net/mptcp/pm_netlink.sh
+++ b/tools/testing/selftests/net/mptcp/pm_netlink.sh
@@ -39,7 +39,6 @@ mptcp_lib_check_tools ip
trap cleanup EXIT
mptcp_lib_ns_init ns1
-ip netns exec $ns1 sysctl -q net.mptcp.enabled=1
check()
{
diff --git a/tools/testing/selftests/net/mptcp/simult_flows.sh b/tools/testing/selftests/net/mptcp/simult_flows.sh
index c5128d690c46..bc8f107357ac 100755
--- a/tools/testing/selftests/net/mptcp/simult_flows.sh
+++ b/tools/testing/selftests/net/mptcp/simult_flows.sh
@@ -61,10 +61,6 @@ setup()
trap cleanup EXIT
mptcp_lib_ns_init ns1 ns2 ns3
- for i in "$ns1" "$ns2" "$ns3";do
- ip netns exec $i sysctl -q net.ipv4.conf.all.rp_filter=0
- ip netns exec $i sysctl -q net.ipv4.conf.default.rp_filter=0
- done
ip link add ns1eth1 netns "$ns1" type veth peer name ns2eth1 netns "$ns2"
ip link add ns1eth2 netns "$ns1" type veth peer name ns2eth2 netns "$ns2"
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index e3092696d2de..6d71bf36a1b9 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -128,7 +128,6 @@ trap cleanup EXIT
# Create and configure network namespaces for testing
mptcp_lib_ns_init ns1 ns2
for i in "$ns1" "$ns2" ;do
- ip netns exec "$i" sysctl -q net.mptcp.enabled=1
ip netns exec "$i" sysctl -q net.mptcp.pm_type=1
done
--
2.40.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper
2024-02-22 3:40 [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Geliang Tang
` (2 preceding siblings ...)
2024-02-22 3:40 ` [PATCH mptcp-next v4 3/4] selftests: mptcp: more operations in ns_init/exit Geliang Tang
@ 2024-02-22 3:40 ` Geliang Tang
2024-02-22 4:31 ` selftests: mptcp: add mptcp_lib_events helper: Tests Results MPTCP CI
2024-02-22 11:07 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Matthieu Baerts
2024-02-22 10:30 ` [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Matthieu Baerts
4 siblings, 2 replies; 11+ messages in thread
From: Geliang Tang @ 2024-02-22 3:40 UTC (permalink / raw)
To: mptcp; +Cc: Geliang Tang
From: Geliang Tang <tanggeliang@kylinos.cn>
To avoid duplicated code in different MPTCP selftests, we can add and
use helpers defined in mptcp_lib.sh.
This patch unifies "pm_nl_ctl events" related code in userspace_pm.sh
and mptcp_join.sh into a helper mptcp_lib_events(). Define it in
mptcp_lib.sh and use it in both scripts.
Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
tools/testing/selftests/net/mptcp/mptcp_join.sh | 8 ++------
tools/testing/selftests/net/mptcp/mptcp_lib.sh | 14 ++++++++++++++
tools/testing/selftests/net/mptcp/userspace_pm.sh | 14 ++------------
3 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testing/selftests/net/mptcp/mptcp_join.sh
index 2d9cf6f3bbf3..292fccb1f7f4 100755
--- a/tools/testing/selftests/net/mptcp/mptcp_join.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh
@@ -430,12 +430,8 @@ reset_with_events()
{
reset "${1}" || return 1
- :> "$evts_ns1"
- :> "$evts_ns2"
- ip netns exec $ns1 ./pm_nl_ctl events >> "$evts_ns1" 2>&1 &
- evts_ns1_pid=$!
- ip netns exec $ns2 ./pm_nl_ctl events >> "$evts_ns2" 2>&1 &
- evts_ns2_pid=$!
+ mptcp_lib_events "${ns1}" "${evts_ns1}" evts_ns1_pid
+ mptcp_lib_events "${ns2}" "${evts_ns2}" evts_ns2_pid
}
reset_with_tcp_filter()
diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
index f65a31594829..5b5ad9947c21 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
+++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
@@ -399,3 +399,17 @@ mptcp_lib_ns_exit() {
rm -f /tmp/"$netns".{nstat,out}
done
}
+
+mptcp_lib_events() {
+ local ns="${1}"
+ local evts="${2}"
+ declare -n pid="${3}"
+
+ :>"${evts}"
+
+ if [ ${pid} -ne 0 ]; then
+ mptcp_lib_kill_wait "${pid}"
+ fi
+ ip netns exec "${ns}" ./pm_nl_ctl events >> "${evts}" 2>&1 &
+ pid=$!
+}
diff --git a/tools/testing/selftests/net/mptcp/userspace_pm.sh b/tools/testing/selftests/net/mptcp/userspace_pm.sh
index 6d71bf36a1b9..3200d0b96d53 100755
--- a/tools/testing/selftests/net/mptcp/userspace_pm.sh
+++ b/tools/testing/selftests/net/mptcp/userspace_pm.sh
@@ -178,21 +178,11 @@ make_connection()
if [ -z "$client_evts" ]; then
client_evts=$(mktemp)
fi
- :>"$client_evts"
- if [ $client_evts_pid -ne 0 ]; then
- mptcp_lib_kill_wait $client_evts_pid
- fi
- ip netns exec "$ns2" ./pm_nl_ctl events >> "$client_evts" 2>&1 &
- client_evts_pid=$!
+ mptcp_lib_events "${ns2}" "${client_evts}" client_evts_pid
if [ -z "$server_evts" ]; then
server_evts=$(mktemp)
fi
- :>"$server_evts"
- if [ $server_evts_pid -ne 0 ]; then
- mptcp_lib_kill_wait $server_evts_pid
- fi
- ip netns exec "$ns1" ./pm_nl_ctl events >> "$server_evts" 2>&1 &
- server_evts_pid=$!
+ mptcp_lib_events "${ns1}" "${server_evts}" server_evts_pid
sleep 0.5
# Run the server
--
2.40.1
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: selftests: mptcp: add mptcp_lib_events helper: Tests Results
2024-02-22 3:40 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Geliang Tang
@ 2024-02-22 4:31 ` MPTCP CI
2024-02-22 11:07 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Matthieu Baerts
1 sibling, 0 replies; 11+ messages in thread
From: MPTCP CI @ 2024-02-22 4:31 UTC (permalink / raw)
To: Geliang Tang; +Cc: mptcp
Hi Geliang,
Thank you for your modifications, that's great!
Our CI (GitHub Action) did some validations and here is its report:
- KVM Validation: normal:
- Unstable: 1 failed test(s): packetdrill_regressions 🔴:
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/7999199133
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/965ac86521bd
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-normal
For 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)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2
2024-02-22 3:40 [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Geliang Tang
` (3 preceding siblings ...)
2024-02-22 3:40 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Geliang Tang
@ 2024-02-22 10:30 ` Matthieu Baerts
2024-02-22 11:39 ` Matthieu Baerts
4 siblings, 1 reply; 11+ messages in thread
From: Matthieu Baerts @ 2024-02-22 10:30 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 22/02/2024 4:40 am, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> v4:
> - address Matt's comments in v3 except
> - keep #1, #3 as separate patches, not squash them into #2, to keep #2
> clean.
Thank you for the v4, it looks better to me!
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
I have just one comment for patch 2/4, but it is fine, I think. (I will
also add {} around the new 'netns' variable in mptcp_lib.sh when
applying the patch.)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH mptcp-next v4 2/4] selftests: mptcp: add mptcp_lib_ns_init/exit helpers
2024-02-22 3:40 ` [PATCH mptcp-next v4 2/4] selftests: mptcp: add mptcp_lib_ns_init/exit helpers Geliang Tang
@ 2024-02-22 10:34 ` Matthieu Baerts
0 siblings, 0 replies; 11+ messages in thread
From: Matthieu Baerts @ 2024-02-22 10:34 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 22/02/2024 4:40 am, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> Add helpers mptcp_lib_ns_init() and mptcp_lib_ns_exit() in mptcp_lib.sh to
> initialize and delete the given namespaces. Then every test script can
> invoke these helpers and use all namespaces.
(...)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> index b609649311f6..92f6260ba9f3 100755
> --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
(...)
> check_mptcp_disabled()
> {
> - local disabled_ns="ns_disabled-$rndh"
> - ip netns add ${disabled_ns} || exit $ksft_skip
> + local disabled_ns
> + mptcp_lib_ns_init disabled_ns
>
> # net.mptcp.enabled should be enabled by default
> if [ "$(ip netns exec ${disabled_ns} sysctl net.mptcp.enabled | awk '{ print $3 }')" -ne 1 ]; then
After patch 3/4, this check will have less value: the other patch will
always force it to the 'enabled' value. But I guess that's fine: this
check was mainly to make sure we would not forget to adapt the test if
we wanted to set it to disable by default. So fine like that.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper
2024-02-22 3:40 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Geliang Tang
2024-02-22 4:31 ` selftests: mptcp: add mptcp_lib_events helper: Tests Results MPTCP CI
@ 2024-02-22 11:07 ` Matthieu Baerts
2024-02-22 11:15 ` Matthieu Baerts
1 sibling, 1 reply; 11+ messages in thread
From: Matthieu Baerts @ 2024-02-22 11:07 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 22/02/2024 4:40 am, Geliang Tang wrote:
> From: Geliang Tang <tanggeliang@kylinos.cn>
>
> To avoid duplicated code in different MPTCP selftests, we can add and
> use helpers defined in mptcp_lib.sh.
>
> This patch unifies "pm_nl_ctl events" related code in userspace_pm.sh
> and mptcp_join.sh into a helper mptcp_lib_events(). Define it in
> mptcp_lib.sh and use it in both scripts.
(...)
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index f65a31594829..5b5ad9947c21 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -399,3 +399,17 @@ mptcp_lib_ns_exit() {
> rm -f /tmp/"$netns".{nstat,out}
> done
> }
> +
> +mptcp_lib_events() {
> + local ns="${1}"
> + local evts="${2}"
> + declare -n pid="${3}"
> +
> + :>"${evts}"
> +
> + if [ ${pid} -ne 0 ]; then
Yet another new shellcheck warning introduced here:
>
> In mptcp_lib.sh line 410:
> if [ ${pid} -ne 0 ]; then
> ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
>
> Did you mean:
> if [ "${pid}" -ne 0 ]; then
I guess the CI should check that and report it, so I would not have to
fix that just before applying patches.
I just added the suggested double-quotes when applying the patch.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper
2024-02-22 11:07 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Matthieu Baerts
@ 2024-02-22 11:15 ` Matthieu Baerts
0 siblings, 0 replies; 11+ messages in thread
From: Matthieu Baerts @ 2024-02-22 11:15 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
On 22/02/2024 12:07 pm, Matthieu Baerts wrote:
> Hi Geliang,
>
> On 22/02/2024 4:40 am, Geliang Tang wrote:
>> From: Geliang Tang <tanggeliang@kylinos.cn>
>>
>> To avoid duplicated code in different MPTCP selftests, we can add and
>> use helpers defined in mptcp_lib.sh.
>>
>> This patch unifies "pm_nl_ctl events" related code in userspace_pm.sh
>> and mptcp_join.sh into a helper mptcp_lib_events(). Define it in
>> mptcp_lib.sh and use it in both scripts.
>
> (...)
>
>> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>> index f65a31594829..5b5ad9947c21 100644
>> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
>> @@ -399,3 +399,17 @@ mptcp_lib_ns_exit() {
>> rm -f /tmp/"$netns".{nstat,out}
>> done
>> }
>> +
>> +mptcp_lib_events() {
>> + local ns="${1}"
>> + local evts="${2}"
>> + declare -n pid="${3}"
>> +
>> + :>"${evts}"
>> +
>> + if [ ${pid} -ne 0 ]; then
>
> Yet another new shellcheck warning introduced here:
>
>>
>> In mptcp_lib.sh line 410:
>> if [ ${pid} -ne 0 ]; then
>> ^----^ SC2086 (info): Double quote to prevent globbing and word splitting.
>>
>> Did you mean:
>> if [ "${pid}" -ne 0 ]; then
>
> I guess the CI should check that and report it, so I would not have to
> fix that just before applying patches.
In fact, we don't need this check because mptcp_lib_kill_wait() does
nothing if the pid is set to 0. So I simplified the fix by removing the
condition.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2
2024-02-22 10:30 ` [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Matthieu Baerts
@ 2024-02-22 11:39 ` Matthieu Baerts
0 siblings, 0 replies; 11+ messages in thread
From: Matthieu Baerts @ 2024-02-22 11:39 UTC (permalink / raw)
To: Geliang Tang, mptcp; +Cc: Geliang Tang
Hi Geliang,
On 22/02/2024 11:30 am, Matthieu Baerts wrote:
> Hi Geliang,
>
> On 22/02/2024 4:40 am, Geliang Tang wrote:
>> From: Geliang Tang <tanggeliang@kylinos.cn>
>>
>> v4:
>> - address Matt's comments in v3 except
>> - keep #1, #3 as separate patches, not squash them into #2, to keep #2
>> clean.
>
> Thank you for the v4, it looks better to me!
>
> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
>
> I have just one comment for patch 2/4, but it is fine, I think. (I will
> also add {} around the new 'netns' variable in mptcp_lib.sh when
> applying the patch.)
I just applied the new patches with the suggested modifications.
New patches for t/upstream:
- b19e35a9c85b: selftests: mptcp: add local variables rndh
- 1e458efc9900: selftests: mptcp: add mptcp_lib_ns_init/exit helpers
- dcb564917e5b: selftests: mptcp: more operations in ns_init/exit
- d734b17e00dd: selftests: mptcp: add mptcp_lib_events helper
- Results: a542d2d60003..80a8f9458231 (export)
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-02-22 11:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-22 3:40 [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 1/4] selftests: mptcp: add local variables rndh Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 2/4] selftests: mptcp: add mptcp_lib_ns_init/exit helpers Geliang Tang
2024-02-22 10:34 ` Matthieu Baerts
2024-02-22 3:40 ` [PATCH mptcp-next v4 3/4] selftests: mptcp: more operations in ns_init/exit Geliang Tang
2024-02-22 3:40 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Geliang Tang
2024-02-22 4:31 ` selftests: mptcp: add mptcp_lib_events helper: Tests Results MPTCP CI
2024-02-22 11:07 ` [PATCH mptcp-next v4 4/4] selftests: mptcp: add mptcp_lib_events helper Matthieu Baerts
2024-02-22 11:15 ` Matthieu Baerts
2024-02-22 10:30 ` [PATCH mptcp-next v4 0/4] add helpers and vars in mptcp_lib.sh, part 2 Matthieu Baerts
2024-02-22 11:39 ` Matthieu Baerts
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox