From patchwork Mon Jan 13 15:44:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 857070 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F8DF20AF95; Mon, 13 Jan 2025 15:45:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783128; cv=none; b=JVcxSWTE8KFwGpoWKrQO0RXDCmVJr2vpY6RN8hsjkC9DdHH/qhVBBqLPZ1P2lrmDFTFYOOp323Ulie26G9860Fa08kjVLZRdHNSXdwyl9hJmEo+fq6iPWs5BjSXpRBQNyOnbfzEyeuDcx2elUl6jLRZMlWCH/eHnOmQg+gMOTdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783128; c=relaxed/simple; bh=ugNVgWtl26atWi7BtzLBGgkS6jelBYNZMUVYTnwVTcU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gEErZHybEngYHrakBrsmpZSTO21HDtWXrEWwSVaItsn2V1+iXjAYcYSuGPqE3xMjVVBtNCqvEPhtb93v5XvWVRQHQkO+BO0kUN3tHk+m2kkr7eI1u+BHM+9ZFeQIWsRW/59AWObbW9e5UZ0PB3PRkqChC0ldPMUgb8AwLVjNM0c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nlayQBfT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nlayQBfT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40CD7C4CEE5; Mon, 13 Jan 2025 15:45:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736783128; bh=ugNVgWtl26atWi7BtzLBGgkS6jelBYNZMUVYTnwVTcU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=nlayQBfTCq9kLSpc994NZs5IjJRV5h4wFdV5LGWCppda0j38fElxzwSOTItNdybWX jzQusNqGozKLr1SagRL1G0cFHJnz9wq+2l3+yWiaSh5S6LZ7hUGwAMiQllqqjGzdRv vT7rxsDVLKqDISEB9EsDTrVxMAO0IQVe4f6+PUgJyEFhUFxZ5uP/8ho4BB9oSbdF9+ WT/OoTg+a2uofukRDi/wbALoJa7FD2tTnczv61sdcIO5E8VTH/CHhLD/bbhdmz0QRG BBqTGP9bWIvLQrvN7DdOK6y80Y4/ivTgtF8Xax8kAw4fWevDdzbtcFbJzABevTivxR 5ZKaccY/GCZHg== From: "Matthieu Baerts (NGI0)" Date: Mon, 13 Jan 2025 16:44:56 +0100 Subject: [PATCH net 1/3] mptcp: be sure to send ack when mptcp-level window re-opens Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250113-net-mptcp-connect-st-flakes-v1-1-0d986ee7b1b6@kernel.org> References: <20250113-net-mptcp-connect-st-flakes-v1-0-0d986ee7b1b6@kernel.org> In-Reply-To: <20250113-net-mptcp-connect-st-flakes-v1-0-0d986ee7b1b6@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2652; i=matttbe@kernel.org; h=from:subject:message-id; bh=X8mzsaeWtbOt6rMrUcEg7CQDrWlfiCApjb9AfxhrAxw=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnhTURw3RVQlYDvo1NrHEl350PM3SBqxyrVwTtR Jjtcl8x4XmJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4U1EQAKCRD2t4JPQmmg c27kEACvqRhdhNWfJNyGMIkgB7U9XQfcxxn/CJ94D3AW0jx0xolkl2g/ZEl3MvQG7V4Uw1+m70M 12Y0aUa1WLsT4YrhYa8EPY2U3nE7eT07Wst++ipAuCpjWflauZQAT7dg0w7ZhekTEfsLDvx9jZu FFuUZ9yGKwUHI785pM0xewbqQoCHVPoV8ltkr+oxqNrK2WFKUEu01bhKmI7UfWWyhn5DPqWvnzO 4b/RNkVHJk06Y/VOGg+dP5Ba08WEUv9WfdO3slEst27uYOPkBaqqQ+IdR0i3FAb0Ctzln9bg9jX JKNKxyeOWsYFNeSsj75WTn0TBI90kZq+GSiHUzDd4QpTlGY2P4FRHRntWDsEcakd6eBEk8ZmAlD IROBaXV55WbIjSsRir8DtGl20KmCm7vnDyaCqzFjtHYeZF93dFn6qKtZ76Qdb3MtwI2UJudBq4j wbwDYp9MDOXQdMXYIpwLlzscXWfv9I5g65qvXXca6dGnO/WyivHDclfJexcebyMhNtKPloZFPpz 2R9YJyTPDymi+WpaopG/ojHzb6ATnLXKhMq1cyDShQ9wBxl/lglB1+S7+R8h77h40iyNDhe1uyx PlCfO1j0iID3DpY5JKoPcUqUQCHjYYqKOXOj+QBhU5wMlnx8O6To6tK6We8cWwboavluyNwxrNW QwigZ2QPIQkExeA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni mptcp_cleanup_rbuf() is responsible to send acks when the user-space reads enough data to update the receive windows significantly. It tries hard to avoid acquiring the subflow sockets locks by checking conditions similar to the ones implemented at the TCP level. To avoid too much code duplication - the MPTCP protocol can't reuse the TCP helpers as part of the relevant status is maintained into the msk socket - and multiple costly window size computation, mptcp_cleanup_rbuf uses a rough estimate for the most recently advertised window size: the MPTCP receive free space, as recorded as at last-ack time. Unfortunately the above does not allow mptcp_cleanup_rbuf() to detect a zero to non-zero win change in some corner cases, skipping the tcp_cleanup_rbuf call and leaving the peer stuck. After commit ea66758c1795 ("tcp: allow MPTCP to update the announced window"), MPTCP has actually cheap access to the announced window value. Use it in mptcp_cleanup_rbuf() for a more accurate ack generation. Fixes: e3859603ba13 ("mptcp: better msk receive window updates") Cc: stable@vger.kernel.org Reported-by: Jakub Kicinski Closes: https://lore.kernel.org/20250107131845.5e5de3c5@kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index a62bc874bf1e17c4ee3b4d8d94eef4d0e7c9f272..123f3f2972841aab9fc2ef338687b4c4758efd4a 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -607,7 +607,6 @@ static bool mptcp_established_options_dss(struct sock *sk, struct sk_buff *skb, } opts->ext_copy.use_ack = 1; opts->suboptions = OPTION_MPTCP_DSS; - WRITE_ONCE(msk->old_wspace, __mptcp_space((struct sock *)msk)); /* Add kind/length/subtype/flag overhead if mapping is not populated */ if (dss_size == 0) @@ -1288,7 +1287,7 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th) } MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDCONFLICT); } - return; + goto update_wspace; } if (rcv_wnd_new != rcv_wnd_old) { @@ -1313,6 +1312,9 @@ static void mptcp_set_rwin(struct tcp_sock *tp, struct tcphdr *th) th->window = htons(new_win); MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_RCVWNDSHARED); } + +update_wspace: + WRITE_ONCE(msk->old_wspace, tp->rcv_wnd); } __sum16 __mptcp_make_csum(u64 data_seq, u32 subflow_seq, u16 data_len, __wsum sum) From patchwork Mon Jan 13 15:44:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 857069 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D13DC1C5D6F; Mon, 13 Jan 2025 15:45:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783135; cv=none; b=frnROQccvq0ZCf2G7gtLGraqgmSUbIgV6mqyXL1rHUPGWgwogUN03PSka67uvJFRvF8yllMWShJySH8KrnYwAtElSRzwpmUy81e1zoj+uJkC2jbiM5fOWd2lTVY+DmNBPKFYy1Y6e45Lr8JyCQqDJg3MGm7fE7FE/sq4nXKSZA4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783135; c=relaxed/simple; bh=fG3xbLFjUW12Ssjew7xsKuz4ojI9yBcQdAaajeXFMiA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RgfUnBnU7IT7U4uChYjXZ9bfR9dXYost2O94g7payw0G/z4P0+IIn5fPOj6ClEMN/pXEfSIFxYfoHA8JBwe4Tfp5+dwy7sdKUlNsWZN3V7vq+SpLC6OkdVfdGLnSCvV//sa5vK1Z/99WGLJMaGQJW6Bm1WgcC1ZtmyEPT0uEhpI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g8Oh+Mr/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="g8Oh+Mr/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3FFEC4CEE6; Mon, 13 Jan 2025 15:45:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736783134; bh=fG3xbLFjUW12Ssjew7xsKuz4ojI9yBcQdAaajeXFMiA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=g8Oh+Mr/gkIFvtlPbXrpyQpfAWVcsTuEPqSyORHj0kRRPPcL2zGammKerln6n8Syp AhLTQFqW+Rb9crrhFN7tcKDjh11l99aq7cEjtn1R9SoZwinyBBeEhsz8NIBBDVe4C/ W5nZz3rBpOFBgG5GS5acCUCTzTVlkq91BcBuLEjPdUTRzJBfbQ3SJJh1DIAhhPIUNU WPwwukh29Tg3CmzZh2FEdWKxcGXP83XHi1lzxrEh6CbLwUXrW3FZCak4dYGdY/7Gyy KdM80xUVz+AwOzDMZD21lZ4NruhNoilGNjU+px+cOnpLkTKzl2TpFhollZEPc3X7J+ /W/GggQY4XPGA== From: "Matthieu Baerts (NGI0)" Date: Mon, 13 Jan 2025 16:44:58 +0100 Subject: [PATCH net 3/3] selftests: mptcp: avoid spurious errors on disconnect Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250113-net-mptcp-connect-st-flakes-v1-3-0d986ee7b1b6@kernel.org> References: <20250113-net-mptcp-connect-st-flakes-v1-0-0d986ee7b1b6@kernel.org> In-Reply-To: <20250113-net-mptcp-connect-st-flakes-v1-0-0d986ee7b1b6@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , stable@vger.kernel.org X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4147; i=matttbe@kernel.org; h=from:subject:message-id; bh=HMHeFU265RAxalmgcayy5V/AECiL0u4m+mFxhLobykU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnhTURBAOsIDulk//XDrXyUSJcoyUUjSFRGmb/K UVDDnIhkJeJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4U1EQAKCRD2t4JPQmmg c2fvD/sEwmb7hidlUYjFsi6wPM/OgR3K2AKH1DZVqqJtUPwcKMwXtwhvcZwWNiTtU7BvrKviAJx busvpoil/J759if16tF53QGvt5CYymBFWqCfaVfJc6a0xOztX83rRoTVRgxtDspsMV27o9SOH6K Ru1CUONYrWMaqxR0+nTPJjaPVEj+I4K+1PiJz/knNox59or+KPLLg26zSpybz4JoSE7O/ojMMrh n2DHwQpSaAXmlkABEQnWVlVBsKDjFu30RjH+jrO6BnPKoX/6pgmewdhWtIFCe6nrDIfFKieBJ+N rcFjl/afog8F9De/bblTI+okWDqEuwhoe7uKz1nUs9zUXGMQpotMhijzl/TT4z9qQST2jDN+P/X uM+de6+HV+1Dw6SaS4R12/cQv/7uMsE0/Wjm8Cwc5N8FaK1kKSIZqckfhybRzLdN5PgF3elgZIY 6BtpVSla4LJzN7OjBJByLrDcvbNeyNOmIg20bGhGMCCTH+nsplkBVwp25GAJrBL5YhJiePwYHXL ZB9vou1RpZO79GZ3GDY4czi7NJUkKkuTriljc/3Rp7ljvyVaKi6ZOzcMAbiF2cZV0D7jI6GBr8J q8VVxnxTTFNqz2lAL4XUX7ZJcXgRTqv1McTcoPRNIkK1/3kfxEvLmcx5yOwl5jWOC1FZjl6uvk6 FErQ++6RuDxT/Aw== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Paolo Abeni The disconnect test-case generates spurious errors: INFO: disconnect INFO: extra options: -I 3 -i /tmp/tmp.r43niviyoI 01 ns1 MPTCP -> ns1 (10.0.1.1:10000 ) MPTCP (duration 140ms) [FAIL] file received by server does not match (in, out): Unexpected revents: POLLERR/POLLNVAL(19) -rw-r--r-- 1 root root 10028676 Jan 10 10:47 /tmp/tmp.r43niviyoI.disconnect Trailing bytes are: ��\����R���!8��u2��5N% -rw------- 1 root root 9992290 Jan 10 10:47 /tmp/tmp.Os4UbnWbI1 Trailing bytes are: ��\����R���!8��u2��5N% 02 ns1 MPTCP -> ns1 (dead:beef:1::1:10001) MPTCP (duration 206ms) [ OK ] 03 ns1 MPTCP -> ns1 (dead:beef:1::1:10002) TCP (duration 31ms) [ OK ] 04 ns1 TCP -> ns1 (dead:beef:1::1:10003) MPTCP (duration 26ms) [ OK ] [FAIL] Tests of the full disconnection have failed Time: 2 seconds The root cause is actually in the user-space bits: the test program currently disconnects as soon as all the pending data has been spooled, generating an FASTCLOSE. If such option reaches the peer before the latter has reached the closed status, the msk socket will report an error to the user-space, as per protocol specification, causing the above failure. Address the issue explicitly waiting for all the relevant sockets to reach a closed status before performing the disconnect. Fixes: 05be5e273c84 ("selftests: mptcp: add disconnect tests") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 43 +++++++++++++++++------ 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/testing/selftests/net/mptcp/mptcp_connect.c index 4209b95690394b7565f330a37606bf39b6d2d228..414addef9a4514c489ecd09249143fe0ce2af649 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -25,6 +25,8 @@ #include #include +#include + #include #include @@ -1211,23 +1213,42 @@ static void parse_setsock_options(const char *name) exit(1); } -void xdisconnect(int fd, int addrlen) +void xdisconnect(int fd) { - struct sockaddr_storage empty; + socklen_t addrlen = sizeof(struct sockaddr_storage); + struct sockaddr_storage addr, empty; int msec_sleep = 10; - int queued = 1; - int i; + void *raw_addr; + int i, cmdlen; + char cmd[128]; + + /* get the local address and convert it to string */ + if (getsockname(fd, (struct sockaddr *)&addr, &addrlen) < 0) + xerror("getsockname"); + + if (addr.ss_family == AF_INET) + raw_addr = &(((struct sockaddr_in *)&addr)->sin_addr); + else if (addr.ss_family == AF_INET6) + raw_addr = &(((struct sockaddr_in6 *)&addr)->sin6_addr); + else + xerror("bad family"); + + strcpy(cmd, "ss -M | grep -q "); + cmdlen = strlen(cmd); + if (!inet_ntop(addr.ss_family, raw_addr, &cmd[cmdlen], + sizeof(cmd) - cmdlen)) + xerror("inet_ntop"); shutdown(fd, SHUT_WR); - /* while until the pending data is completely flushed, the later + /* + * wait until the pending data is completely flushed and all + * the MPTCP sockets reached the closed status. * disconnect will bypass/ignore/drop any pending data. */ for (i = 0; ; i += msec_sleep) { - if (ioctl(fd, SIOCOUTQ, &queued) < 0) - xerror("can't query out socket queue: %d", errno); - - if (!queued) + /* closed socket are not listed by 'ss' */ + if (system(cmd) != 0) break; if (i > poll_timeout) @@ -1281,9 +1302,9 @@ int main_loop(void) return ret; if (cfg_truncate > 0) { - xdisconnect(fd, peer->ai_addrlen); + xdisconnect(fd); } else if (--cfg_repeat > 0) { - xdisconnect(fd, peer->ai_addrlen); + xdisconnect(fd); /* the socket could be unblocking at this point, we need the * connect to be blocking