From nobody Tue May 14 23:21:54 2024 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 A200522EF0 for ; Mon, 18 Mar 2024 08:03:38 +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=1710749018; cv=none; b=AeDF6HMvzGnHeRgl8jtgm2VtacxIkq2rLhqW6i/8EEb1CAPM9ccjcUGrs6pMBgWFWvwdDD2Do8Ms6wuvk/JNkE6d1D+Q0HVkheK28hJz53LFukTQMBpO7tr2+6aLbky6plaYpKkU81Qhtno3LNSFxGq7sDMjD6YXaEEmnGOvQwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710749018; c=relaxed/simple; bh=Gap66gd2HKGg0r8pZDaTpJV5/xdx8b1n1vRLDgNLY1g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gCaZjlJWKMrRisZxf0xDM8ak6tyST8DTuI7BEiWZgXtpjhpzNhXCOefWAlBZZtoF9fNI0W2Ovq+euMBp3GI8A0Mt9jGWCm3iEAjU3QclxbFZ8woHGU/qQGMjYBUSsDp7VIGt1ezZ5klkT8ces0qThpzVc4Ir4dXQ+EbvfHe5OjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=N13RXiIK; 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="N13RXiIK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9271C43390; Mon, 18 Mar 2024 08:03:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710749018; bh=Gap66gd2HKGg0r8pZDaTpJV5/xdx8b1n1vRLDgNLY1g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N13RXiIKtmmMWCkaIsvSUeEnFxDDmifpN/T/+0U4SR3YC9dXy/S+T6sK6NLlIPBvr 1NblII1C9DYOrbFgXeezC5dLRBQw4/EG6j1FKJ1owEndBBSkDJrUYoEVTQQk/dnMYe tSgtB+fNKSMteJQDFdpkErc/2Bod1X4Uzzzt/9jrChVe2HanxKF0bhdEnuiQagShEA VQg2k/zVyAdVU7tTfRKzsmoyvuESIT4Mm5ZkPsScG+D1LkXNwTc/Ehm2iIlc3fFnGR b9M3T663HX5VhdJD90RG9/uTUZWB8hJSTfN+zBDG8cab97mKNpMPDRohYjeqrOGxp9 sH9oYCCAhz9+w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 1/3] mptcp: add last time fields in mptcp_sock Date: Mon, 18 Mar 2024 16:03:29 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds "last time" fields last_data_sent, last_data_recv and last_ack_recv in struct mptcp_sock to record the last time data_sent, data_recv and ack_recv happened. They all are initialized as tcp_jiffies32 in __mptcp_init_sock(), but updated as tcp_jiffies32 too when data is sent in __subflow_push_pending(), data is received in mptcp_recvmsg(), and ack is received in ack_update_msk(). Signed-off-by: Geliang Tang --- net/mptcp/options.c | 1 + net/mptcp/protocol.c | 5 +++++ net/mptcp/protocol.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 5926955625cf..c0832df3b0a3 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1069,6 +1069,7 @@ static void ack_update_msk(struct mptcp_sock *msk, __mptcp_snd_una_update(msk, new_snd_una); __mptcp_data_acked(sk); } + msk->last_ack_recv =3D tcp_jiffies32; mptcp_data_unlock(sk); =20 trace_ack_update_msk(mp_opt->data_ack, diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index cdf9ec67795e..a6b5c6492e9b 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1556,6 +1556,7 @@ static int __subflow_push_pending(struct sock *sk, st= ruct sock *ssk, err =3D copied; =20 out: + msk->last_data_sent =3D tcp_jiffies32; return err; } =20 @@ -2262,6 +2263,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msgh= dr *msg, size_t len, skb_queue_empty(&msk->receive_queue), copied); if (!(flags & MSG_PEEK)) mptcp_rcv_space_adjust(msk, copied); + msk->last_data_recv =3D tcp_jiffies32; =20 release_sock(sk); return copied; @@ -2793,6 +2795,9 @@ static void __mptcp_init_sock(struct sock *sk) WRITE_ONCE(msk->allow_infinite_fallback, true); msk->recovery =3D false; msk->subflow_id =3D 1; + msk->last_data_sent =3D tcp_jiffies32; + msk->last_data_recv =3D tcp_jiffies32; + msk->last_ack_recv =3D tcp_jiffies32; =20 mptcp_pm_data_init(msk); =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 5a4538205fd6..3a3fed3642dd 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -282,6 +282,9 @@ struct mptcp_sock { u64 bytes_acked; u64 snd_una; u64 wnd_end; + u32 last_data_sent; + u32 last_data_recv; + u32 last_ack_recv; unsigned long timer_ival; u32 token; int rmem_released; --=20 2.40.1 From nobody Tue May 14 23:21:54 2024 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 7087622EF0 for ; Mon, 18 Mar 2024 08:03:40 +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=1710749020; cv=none; b=GbHuuCQDcj0uL8OLsYvk4WrTxNEd3qXW85Ozc2Q9HioZIiNtClS8yv1GzGIB1KpZ6uDMh6m19nKy5kR20G0gnHMSgZGb4yUxXjH9o4dUPJhML7ZXXo2Y8ECYYznd69lFQ3xu9FqpCuGh4k14Q6RPf9OBcgWPVM2lAeDVnIjjZQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710749020; c=relaxed/simple; bh=h1YuOpgJ5KGGAiT3kERJ39y9/AVR49h5j5/ZnylTTMo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=synLuQO66UEiooEVqkrNvbYQkXD+ZVrRWTsH5x6uxwH88CXF7bFAAizSX97fAeAiOol63n5Megh1WjjeczML6mPTqkUcnrNCPICt/APX/WSS8c5GSEv3Kqe+aiNiGSkOJx7NFUimJVsFQCOoLGDyTAde+JRanWoZcW0vfjiy9dE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oXMSw1rM; 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="oXMSw1rM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2E99C433F1; Mon, 18 Mar 2024 08:03:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710749020; bh=h1YuOpgJ5KGGAiT3kERJ39y9/AVR49h5j5/ZnylTTMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oXMSw1rMUfs6y08AOVyNdpHxlhLGl2ovrG9JrLU3/AcGeMWhkvbs0CCY4OL4+oSJU VaF7gLn0sQmBeC4vBH7u4P34gnRmW5Owi9Ns+Wsi9tAYVVDW1ZzRE3+GqGNEzgAPtK RDuBekUwYl57jKDR/NJSotqsRxQeP4fHojvimo/8a0zhdPF6LDekjAoxTnSgnwwLjC 4pQXFmAmx8wXvOjnWwXDTucyqbGst7wb/GmaOJb1epu/pVfe3Oo0aMvAOZTa91zr/4 FDsJHMRLW1yVpwpUO4XwHQRL8wJAizvdUKKmzpkEjY5Owo9b2kJPyxfMRH77waLa7+ S4xysNkrj9erQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 2/3] mptcp: add last time fields in mptcp_info Date: Mon, 18 Mar 2024 16:03:30 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Similar to tcpi_last_data_sent, tcpi_last_data_recv and tcpi_last_ack_recv exposed with TCP, this patch exposes the last time "an action happened" for MPTCP in mptcp_info, named mptcpi_last_data_sent, mptcpi_last_data_recv and mptcpi_last_ack_recv, calculated In mptcp_diag_fill_info() as the time deltas between now and the newly added last time fields in mptcp_sock. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/446 Signed-off-by: Geliang Tang --- include/uapi/linux/mptcp.h | 3 +++ net/mptcp/sockopt.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 74cfe496891e..7126563542b3 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -58,6 +58,9 @@ struct mptcp_info { __u64 mptcpi_bytes_received; __u64 mptcpi_bytes_acked; __u8 mptcpi_subflows_total; + __u32 mptcpi_last_data_sent; + __u32 mptcpi_last_data_recv; + __u32 mptcpi_last_ack_recv; }; =20 /* MPTCP Reset reason codes, rfc8684 */ diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index dcd1c76d2a3b..1e74851614e8 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -898,6 +898,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struc= t mptcp_info *info) struct sock *sk =3D (struct sock *)msk; u32 flags =3D 0; bool slow; + u32 now; =20 memset(info, 0, sizeof(*info)); =20 @@ -942,6 +943,10 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, stru= ct mptcp_info *info) info->mptcpi_bytes_retrans =3D msk->bytes_retrans; info->mptcpi_subflows_total =3D info->mptcpi_subflows + __mptcp_has_initial_subflow(msk); + now =3D tcp_jiffies32; + info->mptcpi_last_data_sent =3D jiffies_to_msecs(now - msk->last_data_sen= t); + info->mptcpi_last_data_recv =3D jiffies_to_msecs(now - msk->last_data_rec= v); + info->mptcpi_last_ack_recv =3D jiffies_to_msecs(now - msk->last_ack_recv); unlock_sock_fast(sk, slow); } EXPORT_SYMBOL_GPL(mptcp_diag_fill_info); --=20 2.40.1 From nobody Tue May 14 23:21:54 2024 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 7484822EF0 for ; Mon, 18 Mar 2024 08:03:42 +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=1710749022; cv=none; b=daNXsT0yv8lw1ToMwM3cwbbM5xBX2wgA+v+GJF4lcdBOUoJyWkvoGv5t++cKzdvdL/zcgMlr5lGlnlexlZN6cNe3m/G3BB5pCtpmdHRdHgi+sYEZ2wTMv8qcMU8Tx5q4rsOqYS011sD2KQn2rmbj69swdEXh3R8pmF+zlUeTo+Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710749022; c=relaxed/simple; bh=EgChSyf+Z2wkPW0yI2D4O2z4kgzarzLeZmuW2ONSXO0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HwUb45FxDX6n/c/An8NXrg41oOojPVS1iW3graTbTHvhSrFtfGgA7myuQo7QNGBSDFqFSOX5HclS02HYtESZONN9E0YmnNF6QSTRpzHJiEUrpTHt+cscUIl2Vy7Qt6Fg6ZsTwXOfWWCE3KYGUGzMmUhfIs85LmYcVheoxanDppk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qAp+404v; 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="qAp+404v" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9BAEFC43390; Mon, 18 Mar 2024 08:03:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710749021; bh=EgChSyf+Z2wkPW0yI2D4O2z4kgzarzLeZmuW2ONSXO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qAp+404voNMFId9NG584gJuZH1+Bqq4Ju7HwO+G3Q2xTr6B3tfi46If9Kz+hyWSBg Zld2TmwzdXWlCNuiLD8jdarjmzmYDo85k1j9QN6sppixK2wep4S+VF0akWhKsLy1ZZ sXn9Z/0JNCyLQmfpNNDMjVR+F4KFG9r52uw5CctuRo0+PMIMG+jdGuVI/xITV83fLE SMWVoqaN740ClQMB3Au057c7KRoa9kcGYrMDo+wAxtj6c0GlVZc5mBdMWqhY/NZkgm b9tpOJsSbsFrTz4VgAAPXcx43vIMJIC3bCe8imrl+U2+LYdC4XB7MJl61IfPPflUw8 Obj1cqNLJ1p8Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next 3/3] selftests: mptcp: add last time actions tests Date: Mon, 18 Mar 2024 16:03:31 +0800 Message-Id: <031f4529f5e9daf33e4818b48693e1b0eb25814d.1710748923.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds a new helper show_mptcp_info() to show the counters in mptcp_info of the given infos. Use it to show newly added last_data_sent, last_data_recv and last_ack_recv in mptcp_info in endpoint_tests(). Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_join.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 70621cbbab09..6a6caf472d68 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -1855,6 +1855,25 @@ chk_subflows_total() fi } =20 +show_mptcp_info() +{ + local info + + for info in "${@}"; do + local cnt1 + local cnt2 + + cnt1=3D$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info" "$info") + cnt2=3D$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info" "$info") + print_check "mptcp_info ${info:0:15}=3D$cnt1:$cnt2" + if [ -z "$cnt1" ] || [ -z "$cnt2" ]; then + print_skip + else + print_ok + fi + done +} + chk_link_usage() { local ns=3D$1 @@ -3589,6 +3608,7 @@ endpoint_tests() $ns2 10.0.2.2 id 1 flags implicit chk_mptcp_info subflows 1 subflows 1 chk_mptcp_info add_addr_signal 1 add_addr_accepted 1 + show_mptcp_info last_data_sent last_data_recv last_ack_recv =20 pm_nl_add_endpoint $ns2 10.0.2.2 id 33 2>/dev/null pm_nl_check_endpoint "ID change is prevented" \ @@ -3612,6 +3632,7 @@ endpoint_tests() wait_mpj $ns2 chk_subflow_nr "before delete" 2 chk_mptcp_info subflows 1 subflows 1 + show_mptcp_info last_data_sent last_data_recv last_ack_recv =20 pm_nl_del_endpoint $ns2 2 10.0.2.2 sleep 0.5 --=20 2.40.1