Skip to content

Commit a2f0da5

Browse files
Geliang Tangintel-lab-lkp
Geliang Tang
authored andcommitted
selftests: mptcp: add path_manager sysctl tests
This patch checks if the newly added net.mptcp.path_manager is mapped successfully from or to the old net.mptcp.pm_type. And add a new helper set_path_manager() to set the newly added net.mptcp.path_manager. Signed-off-by: Geliang Tang <[email protected]> fix Signed-off-by: Geliang Tang <[email protected]>
1 parent 466ab12 commit a2f0da5

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

tools/testing/selftests/net/mptcp/userspace_pm.sh

+55-3
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,61 @@ trap cleanup EXIT
118118

119119
# Create and configure network namespaces for testing
120120
mptcp_lib_ns_init ns1 ns2
121-
for i in "$ns1" "$ns2" ;do
122-
ip netns exec "$i" sysctl -q net.mptcp.pm_type=1
123-
done
121+
122+
set_path_manager()
123+
{
124+
local ns=$1
125+
local pm=$2
126+
127+
if ! ip netns exec ${ns} sysctl net.mptcp.available_path_managers |
128+
grep -wq "${pm}"; then
129+
test_fail "path manager ${pm} not found"
130+
return 1
131+
fi
132+
ip netns exec ${ns} sysctl -q net.mptcp.path_manager="${pm}"
133+
}
134+
135+
if [ -f /proc/sys/net/mptcp/path_manager ]; then
136+
ip netns exec "$ns1" sysctl -q net.mptcp.pm_type=0
137+
pm_name="$(ip netns exec "$ns1" sysctl -n net.mptcp.path_manager)"
138+
if [ "${pm_name}" != "kernel" ]; then
139+
test_fail "unexpected pm_name: ${pm_name}"
140+
mptcp_lib_result_print_all_tap
141+
exit ${KSFT_FAIL}
142+
fi
143+
144+
ip netns exec "$ns1" sysctl -q net.mptcp.pm_type=1
145+
pm_name="$(ip netns exec "$ns1" sysctl -n net.mptcp.path_manager)"
146+
if [ "${pm_name}" != "userspace" ]; then
147+
test_fail "unexpected pm_name: ${pm_name}"
148+
mptcp_lib_result_print_all_tap
149+
exit ${KSFT_FAIL}
150+
fi
151+
152+
set_path_manager "$ns1" "kernel"
153+
pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)"
154+
if [ "${pm_type}" != "0" ]; then
155+
test_fail "unexpected pm_type: ${pm_type}"
156+
mptcp_lib_result_print_all_tap
157+
exit ${KSFT_FAIL}
158+
fi
159+
160+
set_path_manager "$ns1" "userspace"
161+
pm_type="$(ip netns exec "$ns1" sysctl -n net.mptcp.pm_type)"
162+
if [ "${pm_type}" != "1" ]; then
163+
test_fail "unexpected pm_type: ${pm_type}"
164+
mptcp_lib_result_print_all_tap
165+
exit ${KSFT_FAIL}
166+
fi
167+
168+
set_path_manager "$ns2" "userspace"
169+
print_test "check path_manager and pm_type sysctl mapping"
170+
test_pass
171+
else
172+
for i in "$ns1" "$ns2"; do
173+
ip netns exec "$i" sysctl -q net.mptcp.pm_type=1
174+
done
175+
fi
124176

125177
# "$ns1" ns2
126178
# ns1eth2 ns2eth1

0 commit comments

Comments
 (0)