selftests: mptcp: more operations in ns_init/exit
authorGeliang Tang <tanggeliang@kylinos.cn>
Wed, 6 Mar 2024 09:42:54 +0000 (10:42 +0100)
committerJakub Kicinski <kuba@kernel.org>
Fri, 8 Mar 2024 05:06:52 +0000 (21:06 -0800)
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>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://lore.kernel.org/r/20240306-upstream-net-next-20240304-selftests-mptcp-shared-code-shellcheck-v2-5-bc79e6e5e6a0@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/testing/selftests/net/mptcp/mptcp_connect.sh
tools/testing/selftests/net/mptcp/mptcp_join.sh
tools/testing/selftests/net/mptcp/mptcp_lib.sh
tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
tools/testing/selftests/net/mptcp/pm_netlink.sh
tools/testing/selftests/net/mptcp/simult_flows.sh
tools/testing/selftests/net/mptcp/userspace_pm.sh

index 92f6260ba9f34e0096405e7ffadc6ff2db7f48ac..b53ae64ec08cdee14ef556ac85e75df494252728 100755 (executable)
@@ -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}"
 }
 
index 612470244c585c04418edd883fbbc902d3ff264f..2d9cf6f3bbf34fa5be1eb1827ad28893ae83a7e4 100755 (executable)
@@ -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}"
 }
 
index 17d609368603f0292eca5ff0edb3d2c8679190ad..5f44a4ebd1850d92c2aec8fed12bab210bb9ce29 100644 (file)
@@ -385,6 +385,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
 }
 
@@ -392,5 +395,6 @@ mptcp_lib_ns_exit() {
        local netns
        for netns in "${@}"; do
                ip netns del "${netns}"
+               rm -f /tmp/"${netns}".{nstat,out}
        done
 }
index 5fa5fa8cab71b363a986fda2f413c57d4ebed777..7dd0e5467d35c0fd32cbf96fd00b7f0ad968d614 100755 (executable)
@@ -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"
index 30ec0ec3d68f2ee58811d37e881fd471d45d453e..c7c46152f6fd4581d91b05552b87e746a751f47f 100755 (executable)
@@ -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()
 {
index 2aeebb80da0742d7ce2ae1615a6d2b5fb7e91c0b..5a4b83cdaaa9e6366ba8e7684aabdd30d83f2865 100755 (executable)
@@ -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"
index e3092696d2deae9a16fa4e3502b2aa73d7eb2a3c..6d71bf36a1b9cf89ef8d5e67eebb709330778e98 100755 (executable)
@@ -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