Skip to content

Commit df8b9be

Browse files
committed
Merge branch 'mptcp-avoid-dup-nl-events-and-propagate-error'
Matthieu Baerts says: ==================== mptcp: avoid dup NL events and propagate error Here are two fixes affecting the MPTCP Netlink events with their tests: - Patches 1 & 2: a subflow closed NL event was visible multiple times in some specific conditions. A fix for v5.12. - Patches 3 & 4: subflow closed NL events never contained the error code, even when expected. A fix for v5.11. Plus an extra fix: - Patch 5: fix a false positive with the "signal addresses race test" subtest when validating the MPTCP Join selftest on a v5.15.y stable kernel. ==================== Link: https://patch.msgid.link/20260127-net-mptcp-dup-nl-events-v1-0-7f71e1bc4feb@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 95f82b2 + c5d5ecf commit df8b9be

2 files changed

Lines changed: 81 additions & 13 deletions

File tree

net/mptcp/protocol.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -821,18 +821,19 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk)
821821

822822
static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk)
823823
{
824-
int err = sock_error(ssk);
825824
int ssk_state;
826-
827-
if (!err)
828-
return false;
825+
int err;
829826

830827
/* only propagate errors on fallen-back sockets or
831828
* on MPC connect
832829
*/
833830
if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(mptcp_sk(sk)))
834831
return false;
835832

833+
err = sock_error(ssk);
834+
if (!err)
835+
return false;
836+
836837
/* We need to propagate only transition to CLOSE state.
837838
* Orphaned socket will see such state change via
838839
* subflow_sched_work_if_closed() and that path will properly
@@ -2598,8 +2599,8 @@ void mptcp_close_ssk(struct sock *sk, struct sock *ssk,
25982599
struct mptcp_sock *msk = mptcp_sk(sk);
25992600
struct sk_buff *skb;
26002601

2601-
/* The first subflow can already be closed and still in the list */
2602-
if (subflow->close_event_done)
2602+
/* The first subflow can already be closed or disconnected */
2603+
if (subflow->close_event_done || READ_ONCE(subflow->local_id) < 0)
26032604
return;
26042605

26052606
subflow->close_event_done = true;

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

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,17 +2329,16 @@ signal_address_tests()
23292329
ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1
23302330
speed=slow \
23312331
run_tests $ns1 $ns2 10.0.1.1
2332+
chk_join_nr 3 3 3
23322333

23332334
# It is not directly linked to the commit introducing this
23342335
# symbol but for the parent one which is linked anyway.
2335-
if ! mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
2336-
chk_join_nr 3 3 2
2337-
chk_add_nr 4 4
2338-
else
2339-
chk_join_nr 3 3 3
2336+
if mptcp_lib_kallsyms_has "mptcp_pm_subflow_check_next$"; then
23402337
# the server will not signal the address terminating
23412338
# the MPC subflow
23422339
chk_add_nr 3 3
2340+
else
2341+
chk_add_nr 4 4
23432342
fi
23442343
fi
23452344
}
@@ -3847,21 +3846,28 @@ userspace_pm_chk_get_addr()
38473846
fi
38483847
}
38493848

3850-
# $1: ns ; $2: event type ; $3: count
3849+
# $1: ns ; $2: event type ; $3: count ; [ $4: attr ; $5: attr count ]
38513850
chk_evt_nr()
38523851
{
38533852
local ns=${1}
38543853
local evt_name="${2}"
38553854
local exp="${3}"
3855+
local attr="${4}"
3856+
local attr_exp="${5}"
38563857

38573858
local evts="${evts_ns1}"
38583859
local evt="${!evt_name}"
3860+
local attr_name
38593861
local count
38603862

3863+
if [ -n "${attr}" ]; then
3864+
attr_name=", ${attr}: ${attr_exp}"
3865+
fi
3866+
38613867
evt_name="${evt_name:16}" # without MPTCP_LIB_EVENT_
38623868
[ "${ns}" == "ns2" ] && evts="${evts_ns2}"
38633869

3864-
print_check "event ${ns} ${evt_name} (${exp})"
3870+
print_check "event ${ns} ${evt_name} (${exp}${attr_name})"
38653871

38663872
if [[ "${evt_name}" = "LISTENER_"* ]] &&
38673873
! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then
@@ -3872,11 +3878,42 @@ chk_evt_nr()
38723878
count=$(grep -cw "type:${evt}" "${evts}")
38733879
if [ "${count}" != "${exp}" ]; then
38743880
fail_test "got ${count} events, expected ${exp}"
3881+
cat "${evts}"
3882+
return
3883+
elif [ -z "${attr}" ]; then
3884+
print_ok
3885+
return
3886+
fi
3887+
3888+
count=$(grep -w "type:${evt}" "${evts}" | grep -c ",${attr}:")
3889+
if [ "${count}" != "${attr_exp}" ]; then
3890+
fail_test "got ${count} event attributes, expected ${attr_exp}"
3891+
grep -w "type:${evt}" "${evts}"
38753892
else
38763893
print_ok
38773894
fi
38783895
}
38793896

3897+
# $1: ns ; $2: event type ; $3: expected count
3898+
wait_event()
3899+
{
3900+
local ns="${1}"
3901+
local evt_name="${2}"
3902+
local exp="${3}"
3903+
3904+
local evt="${!evt_name}"
3905+
local evts="${evts_ns1}"
3906+
local count
3907+
3908+
[ "${ns}" == "ns2" ] && evts="${evts_ns2}"
3909+
3910+
for _ in $(seq 100); do
3911+
count=$(grep -cw "type:${evt}" "${evts}")
3912+
[ "${count}" -ge "${exp}" ] && break
3913+
sleep 0.1
3914+
done
3915+
}
3916+
38803917
userspace_tests()
38813918
{
38823919
# userspace pm type prevents add_addr
@@ -4085,6 +4122,36 @@ userspace_tests()
40854122
kill_events_pids
40864123
mptcp_lib_kill_group_wait $tests_pid
40874124
fi
4125+
4126+
# userspace pm no duplicated spurious close events after an error
4127+
if reset_with_events "userspace pm no dup close events after error" &&
4128+
continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then
4129+
set_userspace_pm $ns2
4130+
pm_nl_set_limits $ns1 0 2
4131+
{ timeout_test=120 test_linkfail=128 speed=slow \
4132+
run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null
4133+
local tests_pid=$!
4134+
wait_event ns2 MPTCP_LIB_EVENT_ESTABLISHED 1
4135+
userspace_pm_add_sf $ns2 10.0.3.2 20
4136+
chk_mptcp_info subflows 1 subflows 1
4137+
chk_subflows_total 2 2
4138+
4139+
# force quick loss
4140+
ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_retries=1
4141+
if ip netns exec "${ns1}" ${iptables} -A INPUT -s "10.0.1.2" \
4142+
-p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset &&
4143+
ip netns exec "${ns2}" ${iptables} -A INPUT -d "10.0.1.2" \
4144+
-p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset; then
4145+
wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1
4146+
wait_event ns1 MPTCP_LIB_EVENT_SUB_CLOSED 1
4147+
chk_subflows_total 1 1
4148+
userspace_pm_add_sf $ns2 10.0.1.2 0
4149+
wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2
4150+
chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 error 2
4151+
fi
4152+
kill_events_pids
4153+
mptcp_lib_kill_group_wait $tests_pid
4154+
fi
40884155
}
40894156

40904157
endpoint_tests()

0 commit comments

Comments
 (0)