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 X-Patchwork-Id: 13937695 X-Patchwork-Delegate: kuba@kernel.org 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: netdev@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 X-Patchwork-Delegate: kuba@kernel.org 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:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Baerts X-Patchwork-Id: 13937696 X-Patchwork-Delegate: kuba@kernel.org 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 A624F20F078; Mon, 13 Jan 2025 15:45:31 +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=1736783132; cv=none; b=pQFngjnt9d32CBDPAQgq7XZ5C2SGajWzjaYuU1JIXV7laRnTdUjXHfX9WwNsqc+5VoBqBegT8Z1yeail8JUCXRd/Y//HMwJfbPh+rbtVf/hp/3LJ1IO6ALqfKlF6UqP3BHkEdCRZhiL+xJAaL2E1pLHz0hPRSbqNzaPpVhW9p3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736783132; c=relaxed/simple; bh=a4IVk6Wkvbym/FS6vrTUr8M9EE1WPv534v+LrcnmBHo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lRGJx/TR7/OEL/vQY5dYR1NrYE0T5l8FMeeClkpS7+iiHIGgg9q1gf68m9MzIQOvYswbWqqRg2Ui8h9JsTUqUqv2CNWNoj00OOQ4RQknzWIH87KHju8lPBxR/PHhUhHzmhWw1AApRQZ1kZQ+mUFC514pgXEFQ+dsOAhtLC2Cn2w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZqPvjrN9; 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="ZqPvjrN9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78C02C4CEE4; Mon, 13 Jan 2025 15:45:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1736783131; bh=a4IVk6Wkvbym/FS6vrTUr8M9EE1WPv534v+LrcnmBHo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZqPvjrN90kkCPoKXtII1QJFD9W4udrM9DGpjt7etY3+KQflYWvGVe0gbBZ4EzxJU9 lGNsoVWZtEXQSYVOPV0GDBSwGdrZXA5fkb5PGLuud2/uPXTDAQDsKKSBb75yS7J6k9 9WUsgF/Vf4aMVoBROodIS/BVSXYynk0wZDhcZ/lOzklGTtppVqDe3LBLEF2dNj3DZG Hz2AoHZG4Dpx+yM5ignElfdrbsAcTSPm3AxtvDb1saLtwHb0i9SbEXucZfRkIa6J+s bOLJf9p4K3TfNV9Q1Lbt5JjKk/NuuXbigLJOzRXhUWMHXa2rMn9RHP+tG1kRN01z3d rU7c6DOJAjnOA== From: "Matthieu Baerts (NGI0)" Date: Mon, 13 Jan 2025 16:44:57 +0100 Subject: [PATCH net 2/3] mptcp: fix spurious wake-up on under memory pressure Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250113-net-mptcp-connect-st-flakes-v1-2-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=1514; i=matttbe@kernel.org; h=from:subject:message-id; bh=lyfNEDgNKcHqMuRGoTCOWatpy9m17ST8LWrIBkAirm4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBnhTUROG/XNAvrj0vkCzgAg7U9N3QgBKXggsPwy shsrAkmucSJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZ4U1EQAKCRD2t4JPQmmg c+3TD/0ak62R+yh1/6PHMhcU4Udz4Xq0TzhebVickRTnS3Dx56we5bdIPueTt3sYS1/7J+k6pDh BwdBNLRouXiay9btW68q3Jxyh6HGvLJeIhaybjbfmOyUYVqg5Zc+xmPKGF4GVmwJVV26yKOYHWk XF4HApdpqRej9qLtpaak1hCfQ7B1cyyuqLISq9KyaYPQ+INVN8DJ8TyH1mEGA7KhNJAntqJJCh7 yNCxgVJCMk5iIuzA9CCGqEZffR7JkV6nxXaNSPBTlWYjSXhcOVK8MkAywYPO22SnM35KVh6Z2rG cKBNWb97P8qZq3WKLoU8vyRLj6kKRUHfhVXSIwqzOV0IJg6hVcooztJ8RCXQ7pjzECo28DVYBsh JKEmlnotM3r2kF0s7YjDxtVVhP5E3H6OSWEN3hVgYRN/SylKnghhYGzGvzZu3eyDy8NFlNaxFWl zOczWlfzjfp+/orIvlH7PpTrNKTnsMTsRUa2Ic3Tikor5ImU8h2qww0kVG9yzvKjbejB4WsEnYi fFJbK4G6W+bNQ0oNb0eODIhMWKQyv990TlmRV44LuquXeuWIgL3b94ZqjLSB+JIhbn1Tk4Uer7v GbAPVqkMeGkPX4Va/3TYHvdkJnX9Jnw0bmDiVMeotfJ9PzVfIeZcf2sWR0j9GUMFYjJ7qD/w9Zu i5NaNI34U984VDg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 X-Patchwork-Delegate: kuba@kernel.org From: Paolo Abeni The wake-up condition currently implemented by mptcp_epollin_ready() is wrong, as it could mark the MPTCP socket as readable even when no data are present and the system is under memory pressure. Explicitly check for some data being available in the receive queue. Fixes: 5684ab1a0eff ("mptcp: give rcvlowat some love") Cc: stable@vger.kernel.org Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts (NGI0) Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a93e661ef5c435155066ce9cc109092661f0711c..73526f1d768fcb6ba5bcf1a43eb09ed5ff9d67bf 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -760,10 +760,15 @@ static inline u64 mptcp_data_avail(const struct mptcp_sock *msk) static inline bool mptcp_epollin_ready(const struct sock *sk) { + u64 data_avail = mptcp_data_avail(mptcp_sk(sk)); + + if (!data_avail) + return false; + /* mptcp doesn't have to deal with small skbs in the receive queue, - * at it can always coalesce them + * as it can always coalesce them */ - return (mptcp_data_avail(mptcp_sk(sk)) >= sk->sk_rcvlowat) || + return (data_avail >= sk->sk_rcvlowat) || (mem_cgroup_sockets_enabled && sk->sk_memcg && mem_cgroup_under_socket_pressure(sk->sk_memcg)) || READ_ONCE(tcp_memory_pressure); 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 X-Patchwork-Id: 13937697 X-Patchwork-Delegate: kuba@kernel.org 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: netdev@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 X-Patchwork-Delegate: kuba@kernel.org 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