display "last time" actions info
Subsystems (3)
Geliang Tang
reviewercover display "last time" actions info
From: Geliang Tang <[email protected]>
Geliang Tang (3):
mptcp: add last time fields in mptcp_sock
mptcp: add last time fields in mptcp_info
selftests: mptcp: add last time actions tests
include/uapi/linux/mptcp.h | 3 +++ net/mptcp/options.c | 1 + net/mptcp/protocol.c | 5 +++++ net/mptcp/protocol.h | 3 +++ net/mptcp/sockopt.c | 5 +++++ .../testing/selftests/net/mptcp/mptcp_join.sh | 21 +++++++++++++++++++ 6 files changed, 38 insertions(+)
Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 1/3 mptcp: add last time fields in mptcp_sock
From: Geliang Tang <[email protected]>
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().
--- net/mptcp/options.c | 1 + net/mptcp/protocol.c | 5 +++++ net/mptcp/protocol.h | 3 +++ 3 files changed, 9 insertions(+)
net/mptcp/options.c +1 -0
@@ -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 = tcp_jiffies32;mptcp_data_unlock (sk); trace_ack_update_msk(mp_opt->data_ack,
net/mptcp/protocol.c +5 -0
@@ -1556,6 +1556,7 @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk, err = copied; out: + msk->last_data_sent = tcp_jiffies32;return err; }
@@ -2262,6 +2263,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *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 = tcp_jiffies32;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 = false; msk->subflow_id =1 ; + msk->last_data_sent = tcp_jiffies32; + msk->last_data_recv = tcp_jiffies32; + msk->last_ack_recv = tcp_jiffies32;mptcp_pm_data_init (msk);
net/mptcp/protocol.h +3 -0
@@ -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;
Signature · 1 line
2.40.1
Mat Martineau
maintainerRe: [PATCH mptcp-next 1/3] mptcp: add last time fields in mptcp_sock
Quoted 36 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch adds "last time" fields
last_data_sent,last_data_recvandlast_ack_recvin structmptcp_sockto record the last timedata_sent,data_recvandack_recvhappened. They all are initialized astcp_jiffies32in__mptcp_init_sock(), but updated astcp_jiffies32too when data is sent in__subflow_push_pending(), data is received inmptcp_recvmsg(), and ack is received inack_update_msk().Signed-off-by Geliang Tang <[email protected]>---
net/mptcp/options.c | 1 + net/mptcp/protocol.c | 5 +++++ net/mptcp/protocol.h | 3 +++ 3 files changed, 9 insertions(+)net/mptcp/options.c +1
-0@@ -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 = tcp_jiffies32;mptcp_data_unlock (sk); trace_ack_update_msk(mp_opt->data_ack,net/mptcp/protocol.c +0
-0@@ -1556,6 +1556,7 @@ static int __subflow_push_pending(struct sock *sk, struct sock *ssk, err = copied;out:
net/mptcp/protocol.c
Quoted 1 line
net/mptcp/protocol.c +1
-0+ msk->last_data_sent = tcp_jiffies32;
Hi Geliang -
I think msk->last_data_sent should only be updated if err > 0.
net/mptcp/protocol.c static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len, · line 2266
Quoted 8 lines
return err; }net/mptcp/protocol.c +1
-0@@ -2262,6 +2263,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *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 = tcp_jiffies32;
This is too late in the receive process, to be comparable to TCP I think this timestamp should be set in __mptcp_move_skbs_from_subflow().
- Mat
Quoted 32 lines
net/mptcp/protocol.c +3
-0release_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 = false; msk->subflow_id =1 ; + msk->last_data_sent = tcp_jiffies32; + msk->last_data_recv = tcp_jiffies32; + msk->last_ack_recv = tcp_jiffies32;mptcp_pm_data_init (msk);net/mptcp/protocol.h +3
-0@@ -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;Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 2/3 mptcp: add last time fields in mptcp_info
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
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.
--- include/uapi/linux/mptcp.h | 3 +++ net/mptcp/sockopt.c | 5 +++++ 2 files changed, 8 insertions(+)
include/uapi/linux/mptcp.h +3 -0
@@ -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; };/* MPTCP Reset reason codes, rfc8684 */
net/mptcp/sockopt.c +5 -0
@@ -898,6 +898,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)struct sock *sk = (struct sock *)msk;u32 flags =0 ;bool slow; +u32 now;memset (info,0 ,sizeof (*info));
@@ -942,6 +943,10 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) info->mptcpi_bytes_retrans = msk->bytes_retrans; info->mptcpi_subflows_total = info->mptcpi_subflows +__mptcp_has_initial_subflow (msk); + now = tcp_jiffies32; + info->mptcpi_last_data_sent =jiffies_to_msecs (now - msk->last_data_sent); + info->mptcpi_last_data_recv =jiffies_to_msecs (now - msk->last_data_recv); + info->mptcpi_last_ack_recv =jiffies_to_msecs (now - msk->last_ack_recv);unlock_sock_fast (sk, slow); }EXPORT_SYMBOL_GPL (mptcp_diag_fill_info);
Signature · 1 line
2.40.1
Mat Martineau
maintainerRe: [PATCH mptcp-next 2/3] mptcp: add last time fields in mptcp_info
Quoted 20 lines · Geliang Tang
From: Geliang Tang <[email protected]>
Similar to
tcpi_last_data_sent,tcpi_last_data_recvandtcpi_last_ack_recvexposed with TCP, this patch exposes the last time "an action happened" for MPTCP inmptcp_info, namedmptcpi_last_data_sent,mptcpi_last_data_recvandmptcpi_last_ack_recv, calculated Inmptcp_diag_fill_info()as the time deltas between now and the newly added last time fields inmptcp_sock.Signed-off-by Geliang Tang <[email protected]>---
include/uapi/linux/mptcp.h| 3 +++net/mptcp/sockopt.c| 5 +++++2 files changed, 8 insertions(+)include/uapi/linux/mptcp.h +0
-0
include/uapi/linux/mptcp.h struct mptcp_info { · line 60
Quoted 3 lines
include/uapi/linux/mptcp.h +0
-0@@ -58,6 +58,9 @@ struct mptcp_info {__u64 mptcpi_bytes_received;__u64 mptcpi_bytes_acked;__u8 mptcpi_subflows_total;
Hi Geliang -
Should add three reserved bytes after mptcpi_subflows_total, otherwise we lose them to alignment. See other uapi header files with "reserved", "reserved2", etc.
- Mat
Quoted 34 lines
include/uapi/linux/mptcp.h +3
-0+__u32 mptcpi_last_data_sent; +__u32 mptcpi_last_data_recv; +__u32 mptcpi_last_ack_recv; };/* MPTCP Reset reason codes, rfc8684 */ net/mptcp/sockopt.c +5
-0@@ -898,6 +898,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)struct sock *sk = (struct sock *)msk;u32 flags =0 ;bool slow; +u32 now;memset (info,0 ,sizeof (*info));@@ -942,6 +943,10 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) info->mptcpi_bytes_retrans = msk->bytes_retrans; info->mptcpi_subflows_total = info->mptcpi_subflows +__mptcp_has_initial_subflow (msk); + now = tcp_jiffies32; + info->mptcpi_last_data_sent =jiffies_to_msecs (now - msk->last_data_sent); + info->mptcpi_last_data_recv =jiffies_to_msecs (now - msk->last_data_recv); + info->mptcpi_last_ack_recv =jiffies_to_msecs (now - msk->last_ack_recv);unlock_sock_fast (sk, slow); }EXPORT_SYMBOL_GPL (mptcp_diag_fill_info);Signature · 1 line
2.40.1
Geliang Tang
reviewerPATCH 3/3 selftests: mptcp: add last time actions tests
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
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().
--- .../testing/selftests/net/mptcp/mptcp_join.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+)
tools/testing/selftests/net/mptcp/mptcp_join.sh +21 -0
@@ -1855,6 +1855,25 @@ chk_subflows_total() fi } +show_mptcp_info() +{ + local info + + for info in "${@}"; do + local cnt1 + local cnt2 + + cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info" "$info") + cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info" "$info") + print_check "mptcp_info ${info:0:15}=$cnt1:$cnt2" + if [ -z "$cnt1" ] || [ -z "$cnt2" ]; then + print_skip + else + print_ok + fi + done +} + chk_link_usage() { local ns=$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 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 pm_nl_del_endpoint $ns2 2 10.0.2.2 sleep 0.5
Signature · 1 line
2.40.1
Mat Martineau
maintainerRe: [PATCH mptcp-next 3/3] selftests: mptcp: add last time actions tests
tools/testing/selftests/net/mptcp/mptcp_join.sh
Quoted 15 lines · Geliang Tang
From: Geliang Tang <[email protected]>
This patch adds a new helper
show_mptcp_info()to show the counters inmptcp_infoof the given infos. Use it to show newly addedlast_data_sent,last_data_recvandlast_ack_recvinmptcp_infoinendpoint_tests().Signed-off-by Geliang Tang <[email protected]>---
.../testing/selftests/net/mptcp/mptcp_join.sh| 21 +++++++++++++++++++1 file changed, 21 insertions(+)tools/testing/selftests/net/mptcp/mptcp_join.sh +0
-0
Hi Geliang -
diag.sh would be a better location for new mptcp_info tests. Could check that the timestamps move forward when data is sent or received, that would verify functionality more than the informational messages below.
Thanks,
Mat
Quoted 47 lines
tools/testing/selftests/net/mptcp/mptcp_join.sh +21
-0@@ -1855,6 +1855,25 @@ chk_subflows_total() fi } +show_mptcp_info() +{ + local info + + for info in "${@}"; do + local cnt1 + local cnt2 + + cnt1=$(ss -N $ns1 -inmHM | mptcp_lib_get_info_value "$info" "$info") + cnt2=$(ss -N $ns2 -inmHM | mptcp_lib_get_info_value "$info" "$info") + print_check "mptcp_info ${info:0:15}=$cnt1:$cnt2" + if [ -z "$cnt1" ] || [ -z "$cnt2" ]; then + print_skip + else + print_ok + fi + done +} + chk_link_usage() { local ns=$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 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 pm_nl_del_endpoint $ns2 2 10.0.2.2 sleep 0.5Signature · 1 line
2.40.1
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal: Success! ✅
- KVM Validation: debug: Unstable: 2 failed test(s): packetdrill_sockopts selftest_mptcp_join 🔴
- KVM Validation: btf (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/8323279037
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/75ec3d556008
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=836000
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)