From nobody Fri May 17 08:24:47 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 1403F36119 for ; Fri, 29 Mar 2024 09:07:09 +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=1711703230; cv=none; b=nKJxUppo2ctRjWzV41uamsv8Vj8nii7dPuC8DtQJrbdfipnz8PS59UclCxkKls+hXV21af6cOYyA5VPOsk38a3xAFokW66dGod+mwErg6XHWYY4I24PiFZqO0bpUF271K3lGBhkG0I7UwG5GWgG8d9TsvlKmJiec+eZu60fr+T4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711703230; c=relaxed/simple; bh=hkoDZOuPqtAY3Wsi6VBhf7SUD+iXtlQ4gTo7nvgCfDE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eENfA3dmHWhzpFdX57C0AluLBZtvsOK7TjqETpUp91qGRiqd5ZPBQQQVDHfKip9XO7vTq586KX8tqtBWCH7d200PqPYlLxGN9XscMs/S7vjXGMwkpoEpUaN/y+i6XYjPx/xKCW+9ruMhD7hTxnlceSf/PVFfJT0QXmRod4IXofE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ytzk5x+o; 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="Ytzk5x+o" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA89BC433C7; Fri, 29 Mar 2024 09:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711703229; bh=hkoDZOuPqtAY3Wsi6VBhf7SUD+iXtlQ4gTo7nvgCfDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ytzk5x+ofXzH2xcfSsT1hNHNB8+tv12KyvU3o5z7NixiuonJfSDhaREIAUGNHDuC6 vS0fTs8IYt18TAB1cFZ7bKlX+bv+DRYi7HUUJpVDsOjMWAh2w7Qvc/9ZkSKubV89nJ z3U8LuzZAsfgOYthCQfycYIY9t7rC9FBJ8CjSS99c0epx5eqEuxprt+BhD89XMy5X5 SI52s/TNLl/OLW8NuNSp5vDqP2J4Jlv5/1QnTVLdRHaWBU/32afqjk4aqNzh7SpXvL acDFrRTZB2b/DpR5rt7qr9GBHk/M6O8qAteuHWHO8wqC8CBBT9P4jKJF4e3lis1QyI EBpYEVdFx1qVA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 1/3] mptcp: add last time fields in mptcp_sock Date: Fri, 29 Mar 2024 17:06:59 +0800 Message-Id: <83a26dc8e1049d8c4d047fecd9ba5f91c5e77af2.1711702915.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 "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_move_skbs_from_subflow(), and ack is received in ack_update_msk(). Signed-off-by: Geliang Tang --- net/mptcp/options.c | 1 + net/mptcp/protocol.c | 7 +++++++ net/mptcp/protocol.h | 3 +++ 3 files changed, 11 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 556b3b95c537..43318aa5f991 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -706,6 +706,8 @@ static bool __mptcp_move_skbs_from_subflow(struct mptcp= _sock *msk, } } while (more_data_avail); =20 + if (moved > 0) + msk->last_data_recv =3D tcp_jiffies32; *bytes +=3D moved; return done; } @@ -1556,6 +1558,8 @@ static int __subflow_push_pending(struct sock *sk, st= ruct sock *ssk, err =3D copied; =20 out: + if (err > 0) + msk->last_data_sent =3D tcp_jiffies32; return err; } =20 @@ -2793,6 +2797,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 Fri May 17 08:24:47 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 7D8C434CD5 for ; Fri, 29 Mar 2024 09:07:11 +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=1711703231; cv=none; b=qQS5430aRRxBqG2iOmW+bocPcooURrLpydQnsJUDWJMXXauDrKTyL0dL88+pUhkUqD0M4S0jxAbNHzOJXQRtU+N088xlOPS77MWG6JcUoOM0c0T6qOm4ljcIgsiboCHTly5qXCw3rAOmQ642o4F1n5uPvenTV8clp8KRmQ/QaEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711703231; c=relaxed/simple; bh=vMMYevMUlNNQAJot//JBI5DCaZ77/LieHP9Ci+9MRmQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ukwVrY958JdDzUzz9RMCCzzybXRUzuwpZDDPne5E9y6bKYSCPVNZeZ9IH5kCooJzY3PP2+v1Z8G5FWpCjGvawhjW+rmKUTLkael2UMp1KOsdN8T07aXa3fVZQfuGXfnvTNg8bPNGtjmDAKDqI66Z+Fack3A7WNgSsZqOl3oq1cc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZeG7Kan1; 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="ZeG7Kan1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 367FDC433C7; Fri, 29 Mar 2024 09:07:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711703231; bh=vMMYevMUlNNQAJot//JBI5DCaZ77/LieHP9Ci+9MRmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZeG7Kan1VuMCjd+BeEEFpt/Ncne9b9kP4HC1ZG4RUFyuwYWWSVmjbNz19D//ljSXY BnlRYhETbfcoOcqul6lE+lMtzY3t9wPYdqZeHP+NWfjYiBt1jN0VS43+H6kJ2gvLNR gU+qOIfFYQBEGKriyveZm73VHyPhXYTasNsxDL872qUeMBkEDQkBubCtHyqeavBF+8 7ZVRNscPk7RiwKqqWgMBXnAT71TTIaO2L+qa54Xowx+PG6wyejx1T3crq3CTP1sfBV nuNhfeu3xQRKojoqv2K6yo1671V5mO4WlM38wg/X7fk9p6p0E2BZKwRNviMbElt09J DTD/iVsTGSW3g== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 2/3] mptcp: add last time fields in mptcp_info Date: Fri, 29 Mar 2024 17:07:00 +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. Also add three reserved bytes in struct mptcp_info. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/446 Signed-off-by: Geliang Tang --- include/uapi/linux/mptcp.h | 4 ++++ net/mptcp/sockopt.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 74cfe496891e..67d015df8893 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -58,6 +58,10 @@ struct mptcp_info { __u64 mptcpi_bytes_received; __u64 mptcpi_bytes_acked; __u8 mptcpi_subflows_total; + __u8 reserved[3]; + __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 Fri May 17 08:24:47 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 C2B9836AE7 for ; Fri, 29 Mar 2024 09:07:12 +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=1711703232; cv=none; b=LOf3GvVjYEeqp8Vnl+EwOy9Uzye2VkQeNNFE4UyfedzUirS49j0t9BUawuievD9UyuB37bo5pgG55dw35OsAXRWrTqkEQZEdN6Tkcy1shE46kvCKQhm+2kqq3NyA+/5H96cauQIWHTU1EjNC2w7BRcUQCdmXf1sL+0dKN2EEWhM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711703232; c=relaxed/simple; bh=2EFd5TVQtjeSbt5MVaSXYjWDR1iY+AA/afGKv2sJHBY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=aiTT4jilboQUDtarZFoA9rYxxotAa1Q1X1u5PwJ/dsNGbeqG3a2PkV2Vp75bHsWB9UKjRJpUBS5c7LehBBe4zWj4Mecd4SvPpGXsIiZp+XftwqJcKchiNiNEuzl7mOLrFoSQ8ZKKBozzDWDAD6f17Q6epr87sKRRf8lHhToUJ+M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jtyq/Apy; 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="Jtyq/Apy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86210C433F1; Fri, 29 Mar 2024 09:07:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711703232; bh=2EFd5TVQtjeSbt5MVaSXYjWDR1iY+AA/afGKv2sJHBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jtyq/ApyiFgDTVw8EO0KiLCiCarcY7NqwQtoPX2YKl8bZDtNdvzXrHL9xmomxEZSU eM4SFA2kuCmKMWPVgZ8Fc5Mo5EkeNY4tT2MnjXHahATdxktWtvZnon98ZX8Dci60bD YL6ZTKHV8QIwRx6a65SOVEG7EkjYjKinOwU9ongXxIhqlC2Ey0PpLlyeGB6eAqi8bf DNqs1OqaGbt4k9JxJTsGpoMJrScipLu2eqEhgGP4v/KLZWj1jb5UdlNXHP/ehVnKbu nCBFoUwqtUUHfyRTuqEuouwBJLPXT3u/0Qot8UuQqeSwXmxxfA3ZDvdcH7uH50wpmV NcdGiv2ewVRAA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v2 3/3] selftests: mptcp: add last time actions tests Date: Fri, 29 Mar 2024 17:07:01 +0800 Message-Id: <5dd35f7df3332535dc938d1dfcc1c41ee7c717f0.1711702915.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 chk_msk_info() to show the counters in mptcp_info of the given infos, and check that the timestamps move forward. Use it to show newly added last_data_sent, last_data_recv and last_ack_recv in mptcp_info in diag.sh. Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/diag.sh | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/diag.sh b/tools/testing/self= tests/net/mptcp/diag.sh index bc97ab33a00e..6e865f95f85e 100755 --- a/tools/testing/selftests/net/mptcp/diag.sh +++ b/tools/testing/selftests/net/mptcp/diag.sh @@ -200,6 +200,27 @@ chk_msk_cestab() "${expected}" "${msg}" "" } =20 +chk_msk_info() +{ + local info + + for info in "${@}"; do + local cnt1 cnt2 msg + + cnt1=3D$(ss -N ${ns} -inmHM | mptcp_lib_get_info_value "$info" "$info") + cnt2=3D$(ss -N ${ns} -inmHM | mptcp_lib_get_info_value "$info" "$info") + msg=3D"....chk ${info:0:15}=3D$cnt1:$cnt2" + mptcp_lib_print_title "${msg}" + if [ "${cnt1}" -lt "${cnt2}" ]; then + mptcp_lib_pr_ok + mptcp_lib_result_pass "${msg}" + else + mptcp_lib_pr_skip + mptcp_lib_result_skip "${msg}" + fi + done +} + wait_connected() { local listener_ns=3D"${1}" @@ -237,6 +258,7 @@ chk_msk_remote_key_nr 2 "....chk remote_key" chk_msk_fallback_nr 0 "....chk no fallback" chk_msk_inuse 2 chk_msk_cestab 2 +chk_msk_info last_data_sent last_data_recv last_ack_recv flush_pids =20 chk_msk_inuse 0 "2->0" @@ -257,6 +279,7 @@ wait_connected $ns 10001 chk_msk_fallback_nr 1 "check fallback" chk_msk_inuse 1 chk_msk_cestab 1 +chk_msk_info last_data_sent last_data_recv last_ack_recv flush_pids =20 chk_msk_inuse 0 "1->0" @@ -283,6 +306,7 @@ done wait_msk_nr $((NR_CLIENTS*2)) "many msk socket present" chk_msk_inuse $((NR_CLIENTS*2)) "many" chk_msk_cestab $((NR_CLIENTS*2)) "many" +chk_msk_info last_data_sent last_data_recv last_ack_recv flush_pids =20 chk_msk_inuse 0 "many->0" --=20 2.40.1