Skip to content

Commit 8d4ccc1

Browse files
matttbegregkh
authored andcommitted
selftests: mptcp: check no dup close events after error
commit 8467458 upstream. This validates the previous commit: subflow closed events are re-sent with less info when the initial subflow is disconnected after an error and each time a subflow is closed after that. In this new test, the userspace PM is involved because that's how it was discovered, but it is not specific to it. The initial subflow is terminated with a RESET, and that will cause the subflow disconnect. Then, a new subflow is initiated, but also got rejected, which cause a second subflow closed event, but not a third one. While at it, in case of failure to get the expected amount of events, the events are printed. The 'Fixes' tag here below is the same as the one from the previous commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID. Fixes: d82809b ("mptcp: avoid duplicated SUB_CLOSED events") Cc: stable@vger.kernel.org Reviewed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20260127-net-mptcp-dup-nl-events-v1-2-7f71e1bc4feb@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 35bb480 commit 8d4ccc1

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

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

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3717,11 +3717,32 @@ chk_evt_nr()
37173717
count=$(grep -cw "type:${evt}" "${evts}")
37183718
if [ "${count}" != "${exp}" ]; then
37193719
fail_test "got ${count} events, expected ${exp}"
3720+
cat "${evts}"
37203721
else
37213722
print_ok
37223723
fi
37233724
}
37243725

3726+
# $1: ns ; $2: event type ; $3: expected count
3727+
wait_event()
3728+
{
3729+
local ns="${1}"
3730+
local evt_name="${2}"
3731+
local exp="${3}"
3732+
3733+
local evt="${!evt_name}"
3734+
local evts="${evts_ns1}"
3735+
local count
3736+
3737+
[ "${ns}" == "ns2" ] && evts="${evts_ns2}"
3738+
3739+
for _ in $(seq 100); do
3740+
count=$(grep -cw "type:${evt}" "${evts}")
3741+
[ "${count}" -ge "${exp}" ] && break
3742+
sleep 0.1
3743+
done
3744+
}
3745+
37253746
userspace_tests()
37263747
{
37273748
# userspace pm type prevents add_addr
@@ -3930,6 +3951,36 @@ userspace_tests()
39303951
kill_events_pids
39313952
mptcp_lib_kill_group_wait $tests_pid
39323953
fi
3954+
3955+
# userspace pm no duplicated spurious close events after an error
3956+
if reset_with_events "userspace pm no dup close events after error" &&
3957+
continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
3958+
set_userspace_pm $ns2
3959+
pm_nl_set_limits $ns1 0 2
3960+
{ timeout_test=120 test_linkfail=128 speed=slow \
3961+
run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null
3962+
local tests_pid=$!
3963+
wait_event ns2 MPTCP_LIB_EVENT_ESTABLISHED 1
3964+
userspace_pm_add_sf $ns2 10.0.3.2 20
3965+
chk_mptcp_info subflows 1 subflows 1
3966+
chk_subflows_total 2 2
3967+
3968+
# force quick loss
3969+
ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_retries=1
3970+
if ip netns exec "${ns1}" ${iptables} -A INPUT -s "10.0.1.2" \
3971+
-p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset &&
3972+
ip netns exec "${ns2}" ${iptables} -A INPUT -d "10.0.1.2" \
3973+
-p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset; then
3974+
wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1
3975+
wait_event ns1 MPTCP_LIB_EVENT_SUB_CLOSED 1
3976+
chk_subflows_total 1 1
3977+
userspace_pm_add_sf $ns2 10.0.1.2 0
3978+
wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2
3979+
chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2
3980+
fi
3981+
kill_events_pids
3982+
mptcp_lib_kill_group_wait $tests_pid
3983+
fi
39333984
}
39343985

39353986
endpoint_tests()

0 commit comments

Comments
 (0)