1 From 7a1b3490f47e88ec4cbde65f1a77a0f4bc972282 Mon Sep 17 00:00:00 2001
2 From: Davide Caratti <dcaratti@redhat.com>
3 Date: Fri, 29 Mar 2024 13:08:52 +0100
4 Subject: mptcp: don't account accept() of non-MPC client as fallback to TCP
6 From: Davide Caratti <dcaratti@redhat.com>
8 commit 7a1b3490f47e88ec4cbde65f1a77a0f4bc972282 upstream.
10 Current MPTCP servers increment MPTcpExtMPCapableFallbackACK when they
11 accept non-MPC connections. As reported by Christoph, this is "surprising"
12 because the counter might become greater than MPTcpExtMPCapableSYNRX.
14 MPTcpExtMPCapableFallbackACK counter's name suggests it should only be
15 incremented when a connection was seen using MPTCP options, then a
16 fallback to TCP has been done. Let's do that by incrementing it when
17 the subflow context of an inbound MPC connection attempt is dropped.
18 Also, update mptcp_connect.sh kselftest, to ensure that the
19 above MIB does not increment in case a pure TCP client connects to a
22 Fixes: fc518953bc9c ("mptcp: add and use MIB counter infrastructure")
23 Cc: stable@vger.kernel.org
24 Reported-by: Christoph Paasch <cpaasch@apple.com>
25 Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/449
26 Signed-off-by: Davide Caratti <dcaratti@redhat.com>
27 Reviewed-by: Mat Martineau <martineau@kernel.org>
28 Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
29 Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
30 Link: https://lore.kernel.org/r/20240329-upstream-net-20240329-fallback-mib-v1-1-324a8981da48@kernel.org
31 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
32 Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
35 net/mptcp/protocol.c | 2 --
36 net/mptcp/subflow.c | 2 ++
37 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 9 +++++++++
38 3 files changed, 11 insertions(+), 2 deletions(-)
40 --- a/net/mptcp/protocol.c
41 +++ b/net/mptcp/protocol.c
42 @@ -3911,8 +3911,6 @@ static int mptcp_stream_accept(struct so
43 mptcp_set_state(newsk, TCP_CLOSE);
46 - MPTCP_INC_STATS(sock_net(ssk),
47 - MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK);
49 newsk->sk_kern_sock = kern;
51 --- a/net/mptcp/subflow.c
52 +++ b/net/mptcp/subflow.c
53 @@ -905,6 +905,8 @@ dispose_child:
58 + SUBFLOW_REQ_INC_STATS(req, MPTCP_MIB_MPCAPABLEPASSIVEFALLBACK);
59 mptcp_subflow_drop_ctx(child);
62 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh
63 +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh
64 @@ -433,12 +433,14 @@ do_transfer()
65 local stat_cookierx_last
68 + local stat_tcpfb_last_l
69 stat_synrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
70 stat_ackrx_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
71 stat_cookietx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent")
72 stat_cookierx_last=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv")
73 stat_csum_err_s=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtDataCsumErr")
74 stat_csum_err_c=$(mptcp_lib_get_counter "${connector_ns}" "MPTcpExtDataCsumErr")
75 + stat_tcpfb_last_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableFallbackACK")
77 timeout ${timeout_test} \
78 ip netns exec ${listener_ns} \
79 @@ -506,11 +508,13 @@ do_transfer()
80 local stat_cookietx_now
81 local stat_cookierx_now
83 + local stat_tcpfb_now_l
84 stat_synrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableSYNRX")
85 stat_ackrx_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableACKRX")
86 stat_cookietx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesSent")
87 stat_cookierx_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtSyncookiesRecv")
88 stat_ooo_now=$(mptcp_lib_get_counter "${listener_ns}" "TcpExtTCPOFOQueue")
89 + stat_tcpfb_now_l=$(mptcp_lib_get_counter "${listener_ns}" "MPTcpExtMPCapableFallbackACK")
91 expect_synrx=$((stat_synrx_last_l))
92 expect_ackrx=$((stat_ackrx_last_l))
93 @@ -564,6 +568,11 @@ do_transfer()
94 mptcp_lib_result_fail "${TEST_GROUP}: ${result_msg}"
97 + if [ ${stat_ooo_now} -eq 0 ] && [ ${stat_tcpfb_last_l} -ne ${stat_tcpfb_now_l} ]; then
98 + mptcp_lib_pr_fail "unexpected fallback to TCP"
102 if [ $cookies -eq 2 ];then
103 if [ $stat_cookietx_last -ge $stat_cookietx_now ] ;then
104 printf " WARN: CookieSent: did not advance"