Skip to content

Commit

Permalink
selftests: mptcp: run mptcp_sockopt from a new netns
Browse files Browse the repository at this point in the history
Not running it from a new netns causes issues if some MPTCP settings are
modified, e.g. if MPTCP is disabled from the sysctl knob, if multiple
addresses are available and added to the MPTCP path-manager, etc.

In these cases, the created connection will not behave as expected, e.g.
unable to create an MPTCP socket, more than one subflow is seen, etc.

A new "sandbox" net namespace is now created and used to run
mptcp_sockopt from this controlled environment.

Fixes: ce99791 ("selftests: mptcp: add mptcp getsockopt test cases")
Reviewed-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Matthieu Baerts authored and Jakub Kicinski committed Nov 18, 2022
1 parent 22b2955 commit 7e68d31
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/testing/selftests/net/mptcp/mptcp_sockopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ init()

ns1="ns1-$rndh"
ns2="ns2-$rndh"
ns_sbox="ns_sbox-$rndh"

for netns in "$ns1" "$ns2";do
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
Expand Down Expand Up @@ -73,7 +74,7 @@ init()

cleanup()
{
for netns in "$ns1" "$ns2"; do
for netns in "$ns1" "$ns2" "$ns_sbox"; do
ip netns del $netns
done
rm -f "$cin" "$cout"
Expand Down Expand Up @@ -243,7 +244,7 @@ do_mptcp_sockopt_tests()
{
local lret=0

./mptcp_sockopt
ip netns exec "$ns_sbox" ./mptcp_sockopt
lret=$?

if [ $lret -ne 0 ]; then
Expand All @@ -252,7 +253,7 @@ do_mptcp_sockopt_tests()
return
fi

./mptcp_sockopt -6
ip netns exec "$ns_sbox" ./mptcp_sockopt -6
lret=$?

if [ $lret -ne 0 ]; then
Expand Down

0 comments on commit 7e68d31

Please sign in to comment.