Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+81 -13
+7 -6
net/mptcp/protocol.c
··· 821 821 822 822 static bool __mptcp_subflow_error_report(struct sock *sk, struct sock *ssk) 823 823 { 824 - int err = sock_error(ssk); 825 824 int ssk_state; 826 - 827 - if (!err) 828 - return false; 825 + int err; 829 826 830 827 /* only propagate errors on fallen-back sockets or 831 828 * on MPC connect 832 829 */ 833 830 if (sk->sk_state != TCP_SYN_SENT && !__mptcp_check_fallback(mptcp_sk(sk))) 831 + return false; 832 + 833 + err = sock_error(ssk); 834 + if (!err) 834 835 return false; 835 836 836 837 /* We need to propagate only transition to CLOSE state. ··· 2599 2598 struct mptcp_sock *msk = mptcp_sk(sk); 2600 2599 struct sk_buff *skb; 2601 2600 2602 - /* The first subflow can already be closed and still in the list */ 2603 - if (subflow->close_event_done) 2601 + /* The first subflow can already be closed or disconnected */ 2602 + if (subflow->close_event_done || READ_ONCE(subflow->local_id) < 0) 2604 2603 return; 2605 2604 2606 2605 subflow->close_event_done = true;
+74 -7
tools/testing/selftests/net/mptcp/mptcp_join.sh
··· 2329 2329 ip netns exec $ns1 sysctl -q net.mptcp.add_addr_timeout=1 2330 2330 speed=slow \ 2331 2331 run_tests $ns1 $ns2 10.0.1.1 2332 + chk_join_nr 3 3 3 2332 2333 2333 2334 # It is not directly linked to the commit introducing this 2334 2335 # 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 2340 2337 # the server will not signal the address terminating 2341 2338 # the MPC subflow 2342 2339 chk_add_nr 3 3 2340 + else 2341 + chk_add_nr 4 4 2343 2342 fi 2344 2343 fi 2345 2344 } ··· 3846 3847 fi 3847 3848 } 3848 3849 3849 - # $1: ns ; $2: event type ; $3: count 3850 + # $1: ns ; $2: event type ; $3: count ; [ $4: attr ; $5: attr count ] 3850 3851 chk_evt_nr() 3851 3852 { 3852 3853 local ns=${1} 3853 3854 local evt_name="${2}" 3854 3855 local exp="${3}" 3856 + local attr="${4}" 3857 + local attr_exp="${5}" 3855 3858 3856 3859 local evts="${evts_ns1}" 3857 3860 local evt="${!evt_name}" 3861 + local attr_name 3858 3862 local count 3863 + 3864 + if [ -n "${attr}" ]; then 3865 + attr_name=", ${attr}: ${attr_exp}" 3866 + fi 3859 3867 3860 3868 evt_name="${evt_name:16}" # without MPTCP_LIB_EVENT_ 3861 3869 [ "${ns}" == "ns2" ] && evts="${evts_ns2}" 3862 3870 3863 - print_check "event ${ns} ${evt_name} (${exp})" 3871 + print_check "event ${ns} ${evt_name} (${exp}${attr_name})" 3864 3872 3865 3873 if [[ "${evt_name}" = "LISTENER_"* ]] && 3866 3874 ! mptcp_lib_kallsyms_has "mptcp_event_pm_listener$"; then ··· 3878 3872 count=$(grep -cw "type:${evt}" "${evts}") 3879 3873 if [ "${count}" != "${exp}" ]; then 3880 3874 fail_test "got ${count} events, expected ${exp}" 3875 + cat "${evts}" 3876 + return 3877 + elif [ -z "${attr}" ]; then 3878 + print_ok 3879 + return 3880 + fi 3881 + 3882 + count=$(grep -w "type:${evt}" "${evts}" | grep -c ",${attr}:") 3883 + if [ "${count}" != "${attr_exp}" ]; then 3884 + fail_test "got ${count} event attributes, expected ${attr_exp}" 3885 + grep -w "type:${evt}" "${evts}" 3881 3886 else 3882 3887 print_ok 3883 3888 fi 3889 + } 3890 + 3891 + # $1: ns ; $2: event type ; $3: expected count 3892 + wait_event() 3893 + { 3894 + local ns="${1}" 3895 + local evt_name="${2}" 3896 + local exp="${3}" 3897 + 3898 + local evt="${!evt_name}" 3899 + local evts="${evts_ns1}" 3900 + local count 3901 + 3902 + [ "${ns}" == "ns2" ] && evts="${evts_ns2}" 3903 + 3904 + for _ in $(seq 100); do 3905 + count=$(grep -cw "type:${evt}" "${evts}") 3906 + [ "${count}" -ge "${exp}" ] && break 3907 + sleep 0.1 3908 + done 3884 3909 } 3885 3910 3886 3911 userspace_tests() ··· 4119 4082 chk_rst_nr 0 0 invert 4120 4083 chk_mptcp_info subflows 1 subflows 1 4121 4084 chk_subflows_total 1 1 4085 + kill_events_pids 4086 + mptcp_lib_kill_group_wait $tests_pid 4087 + fi 4088 + 4089 + # userspace pm no duplicated spurious close events after an error 4090 + if reset_with_events "userspace pm no dup close events after error" && 4091 + continue_if mptcp_lib_has_file '/proc/sys/net/mptcp/pm_type'; then 4092 + set_userspace_pm $ns2 4093 + pm_nl_set_limits $ns1 0 2 4094 + { timeout_test=120 test_linkfail=128 speed=slow \ 4095 + run_tests $ns1 $ns2 10.0.1.1 & } 2>/dev/null 4096 + local tests_pid=$! 4097 + wait_event ns2 MPTCP_LIB_EVENT_ESTABLISHED 1 4098 + userspace_pm_add_sf $ns2 10.0.3.2 20 4099 + chk_mptcp_info subflows 1 subflows 1 4100 + chk_subflows_total 2 2 4101 + 4102 + # force quick loss 4103 + ip netns exec $ns2 sysctl -q net.ipv4.tcp_syn_retries=1 4104 + if ip netns exec "${ns1}" ${iptables} -A INPUT -s "10.0.1.2" \ 4105 + -p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset && 4106 + ip netns exec "${ns2}" ${iptables} -A INPUT -d "10.0.1.2" \ 4107 + -p tcp --tcp-option 30 -j REJECT --reject-with tcp-reset; then 4108 + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 1 4109 + wait_event ns1 MPTCP_LIB_EVENT_SUB_CLOSED 1 4110 + chk_subflows_total 1 1 4111 + userspace_pm_add_sf $ns2 10.0.1.2 0 4112 + wait_event ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 4113 + chk_evt_nr ns2 MPTCP_LIB_EVENT_SUB_CLOSED 2 error 2 4114 + fi 4122 4115 kill_events_pids 4123 4116 mptcp_lib_kill_group_wait $tests_pid 4124 4117 fi