From nobody Thu Apr 25 01:04:21 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 220867484 for ; Thu, 4 May 2023 16:40:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683218409; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aufn6V7/vKjwjO0iPIY+KfPJUxnB5NFZC8y5CTaQyhk=; b=dGj4vJ06nsGyT2S3AhAuuXnxiwrleW40FBezHz6n/Iud9wGqMyLldZxTEESdS7TZCURw+a Rce/LBFoC40E6Xotu88I3gnVUmVRAzjQwck0Euk0WbFXyW4AW1p+AZ7jZpJuPAT+xKyn9U FeOz+33q7Gh9FXhkny8PDeyuDoK6K9Q= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-guai4iQRNfmVbqt1qKZOtA-1; Thu, 04 May 2023 12:40:08 -0400 X-MC-Unique: guai4iQRNfmVbqt1qKZOtA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 32436101A531 for ; Thu, 4 May 2023 16:40:08 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id B68321121331 for ; Thu, 4 May 2023 16:40:07 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 1/4] mptcp: add subflow unique id Date: Thu, 4 May 2023 18:39:59 +0200 Message-Id: <456718f354d8db508b2db8590d9b055d49c728e9.1683212362.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" The user-space need to preperly account the data received/sent by individual subflows. When additional subflows are created and/or closed during the MPTCP socket lifetime, the information currently exposed via MPTCP_TCPINFO are not enough: subflows are identifed only by the sequential position inside the info dumps, and that will change with the above mentioned events. To solve the above problem, this patch introduces a new subflow identifier that is unique inside the given mptcp socket scope. The initial subflow get the id 1 and the other subflows get incremental values at join time. The identifier is exposed to user-space overloading tcpi_fackets in MPTCP_TCPINFO. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts --- include/uapi/linux/mptcp.h | 3 +++ net/mptcp/protocol.c | 3 +++ net/mptcp/protocol.h | 5 ++++- net/mptcp/sockopt.c | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 32af2d278cb4..49bfbf85cb80 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -249,4 +249,7 @@ struct mptcp_subflow_addrs { #define MPTCP_TCPINFO 2 #define MPTCP_SUBFLOW_ADDRS 3 =20 +/* MPTCP_TCPINFO overload obsoleted tcp fields with MPTCP-specific info */ +#define tcpi_subflow_id tcpi_fackets + #endif /* _UAPI_MPTCP_H */ diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2d331b2d62b7..7f5c89315aad 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -96,6 +96,7 @@ static int __mptcp_socket_create(struct mptcp_sock *msk) list_add(&subflow->node, &msk->conn_list); sock_hold(ssock->sk); subflow->request_mptcp =3D 1; + subflow->subflow_id =3D msk->subflow_id++; =20 /* This is the first subflow, always with id 0 */ subflow->local_id_valid =3D 1; @@ -838,6 +839,7 @@ static bool __mptcp_finish_join(struct mptcp_sock *msk,= struct sock *ssk) if (sk->sk_socket && !ssk->sk_socket) mptcp_sock_graft(ssk, sk->sk_socket); =20 + mptcp_subflow_ctx(ssk)->subflow_id =3D msk->subflow_id++; mptcp_sockopt_sync_locked(msk, ssk); return true; } @@ -2726,6 +2728,7 @@ static int __mptcp_init_sock(struct sock *sk) WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk))); WRITE_ONCE(msk->allow_infinite_fallback, true); msk->recovery =3D false; + msk->subflow_id =3D 1; =20 mptcp_pm_data_init(msk); =20 diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 2d7b2c80a164..babf1230c84d 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -316,7 +316,8 @@ struct mptcp_sock { u64 rtt_us; /* last maximum rtt of subflows */ } rcvq_space; =20 - u32 setsockopt_seq; + u32 subflow_id; + u32 setsockopt_seq; char ca_name[TCP_CA_NAME_MAX]; struct mptcp_sock *dl_next; }; @@ -497,6 +498,8 @@ struct mptcp_subflow_context { u8 reset_reason:4; u8 stale_count; =20 + u32 subflow_id; + long delegated_status; unsigned long fail_tout; =20 diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index d4258869ac48..d2aa02e28917 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1032,6 +1032,7 @@ static int mptcp_getsockopt_tcpinfo(struct mptcp_sock= *msk, char __user *optval, struct tcp_info info; =20 tcp_get_info(ssk, &info); + info.tcpi_subflow_id =3D subflow->subflow_id; =20 if (copy_to_user(infoptr, &info, sfd.size_user)) { release_sock(sk); --=20 2.40.0 From nobody Thu Apr 25 01:04:21 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 36CFA79F2 for ; Thu, 4 May 2023 16:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683218414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YbdLu5mFrLc74Uv6ZSzAich4/7Cbd5Pbo5TEmmmGKss=; b=ZVv4l7MKgE3kseEm4hki+GTUTQokt3p7vXrRH0f3X94NXAomWX78IWvLfKtNSE6MxxK4JM rcjRUKeB+qyQw2aE1qsv/b3HV/thfWjvk1+qtyxOO8WFO5O2DY7fuaLA5P7g5zpUcTSYNa dilrqyFRyLudfBNEyvPtbceBi+XIMY0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-608-8F8lGnE2PKWAzw8Kd2OOeA-1; Thu, 04 May 2023 12:40:12 -0400 X-MC-Unique: 8F8lGnE2PKWAzw8Kd2OOeA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E7337811E7C for ; Thu, 4 May 2023 16:40:08 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7749D1121331 for ; Thu, 4 May 2023 16:40:08 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 2/4] mptcp: move snd_una update earlier for fallback socket. Date: Thu, 4 May 2023 18:40:00 +0200 Message-Id: <95bb74322004ed3969ac23cd8184b70a127368d0.1683212362.git.pabeni@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" That will avoid an unneeded conditional in both the fast-path and in the fallback case and will simplify a bit the next patch. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts --- net/mptcp/options.c | 6 ++++++ net/mptcp/protocol.c | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 8a8083207be4..4bdcd2b326bd 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1119,6 +1119,12 @@ bool mptcp_incoming_options(struct sock *sk, struct = sk_buff *skb) mptcp_data_lock(subflow->conn); if (sk_stream_memory_free(sk)) __mptcp_check_push(subflow->conn, sk); + + /* on fallback we just need to ignore the msk-level snd_una, as + * this is really plain TCP + */ + msk->snd_una =3D READ_ONCE(msk->snd_nxt); + __mptcp_data_acked(subflow->conn); mptcp_data_unlock(subflow->conn); return true; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 7f5c89315aad..8d674aef2f1e 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -998,12 +998,6 @@ static void __mptcp_clean_una(struct sock *sk) struct mptcp_data_frag *dtmp, *dfrag; u64 snd_una; =20 - /* on fallback we just need to ignore snd_una, as this is really - * plain TCP - */ - if (__mptcp_check_fallback(msk)) - msk->snd_una =3D READ_ONCE(msk->snd_nxt); - snd_una =3D msk->snd_una; list_for_each_entry_safe(dfrag, dtmp, &msk->rtx_queue, list) { if (after64(dfrag->data_seq + dfrag->data_len, snd_una)) --=20 2.40.0 From nobody Thu Apr 25 01:04:21 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 A83F87484 for ; Thu, 4 May 2023 16:40:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683218414; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wtGKh5zqSC8VB6YhOpZfWjDCxpB+8qEMSJM5vY3WhF8=; b=AwnArZTwVB2uiWk1GH8qLMaf1e4ktf1RLidQsY/zCSs1938Ro7hoXUVFqJrEOGAuh4KhbX QkJj3AggzLsID9zlOYJ3731IjIURdt448CnTi/CgtYOj3T48V9RoJawLMvnT5KZjm1cMk9 qYlnGu1hsWJ6HdLCeYEiMwW8rCwgsUE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-271-f93Rbc5SOpyicNgYEuZcww-1; Thu, 04 May 2023 12:40:11 -0400 X-MC-Unique: f93Rbc5SOpyicNgYEuZcww-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A96DA884ECC for ; Thu, 4 May 2023 16:40:09 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id 387BB1121331 for ; Thu, 4 May 2023 16:40:09 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 3/4] mptcp: track some aggregate data counters. Date: Thu, 4 May 2023 18:40:01 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Currently there are no data transfer counters accounting for all the subflows used by a given MPTCP socket. The user-space can compute such figures aggregating the subflow info, but that is inaccurate if any subflow is closed before the MPTCP socket itself. Add the new counters in the MPTCP socket itself and expose them via the existing diag and sockopt. While touching mptcp_diag_fill_info(), acquire the relevant locks before fetching the msk data, to ensure better data consistency Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts --- include/uapi/linux/mptcp.h | 5 +++++ net/mptcp/options.c | 10 ++++++++-- net/mptcp/protocol.c | 11 ++++++++++- net/mptcp/protocol.h | 4 ++++ net/mptcp/sockopt.c | 22 +++++++++++++++++----- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/include/uapi/linux/mptcp.h b/include/uapi/linux/mptcp.h index 49bfbf85cb80..868a77434ec5 100644 --- a/include/uapi/linux/mptcp.h +++ b/include/uapi/linux/mptcp.h @@ -123,6 +123,11 @@ struct mptcp_info { __u8 mptcpi_local_addr_used; __u8 mptcpi_local_addr_max; __u8 mptcpi_csum_enabled; + __u32 mptcpi_retransmits; + __u64 mptcpi_bytes_retrans; + __u64 mptcpi_bytes_sent; + __u64 mptcpi_bytes_received; + __u64 mptcpi_bytes_acked; }; =20 /* diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 4bdcd2b326bd..c254accb14de 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1026,6 +1026,12 @@ u64 __mptcp_expand_seq(u64 old_seq, u64 cur_seq) return cur_seq; } =20 +static void __mptcp_snd_una_update(struct mptcp_sock *msk, u64 new_snd_una) +{ + msk->bytes_acked +=3D new_snd_una - msk->snd_una; + msk->snd_una =3D new_snd_una; +} + static void ack_update_msk(struct mptcp_sock *msk, struct sock *ssk, struct mptcp_options_received *mp_opt) @@ -1057,7 +1063,7 @@ static void ack_update_msk(struct mptcp_sock *msk, __mptcp_check_push(sk, ssk); =20 if (after64(new_snd_una, old_snd_una)) { - msk->snd_una =3D new_snd_una; + __mptcp_snd_una_update(msk, new_snd_una); __mptcp_data_acked(sk); } mptcp_data_unlock(sk); @@ -1123,7 +1129,7 @@ bool mptcp_incoming_options(struct sock *sk, struct s= k_buff *skb) /* on fallback we just need to ignore the msk-level snd_una, as * this is really plain TCP */ - msk->snd_una =3D READ_ONCE(msk->snd_nxt); + __mptcp_snd_una_update(msk, READ_ONCE(msk->snd_nxt)); =20 __mptcp_data_acked(subflow->conn); mptcp_data_unlock(subflow->conn); diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 8d674aef2f1e..312bc8e32e93 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -378,6 +378,7 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, st= ruct sock *ssk, =20 if (MPTCP_SKB_CB(skb)->map_seq =3D=3D msk->ack_seq) { /* in sequence */ + msk->bytes_received +=3D copy_len; WRITE_ONCE(msk->ack_seq, msk->ack_seq + copy_len); tail =3D skb_peek_tail(&sk->sk_receive_queue); if (tail && mptcp_try_coalesce(sk, tail, skb)) @@ -761,6 +762,7 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk) MPTCP_SKB_CB(skb)->map_seq +=3D delta; __skb_queue_tail(&sk->sk_receive_queue, skb); } + msk->bytes_received +=3D end_seq - msk->ack_seq; msk->ack_seq =3D end_seq; moved =3D true; } @@ -1525,8 +1527,10 @@ static void mptcp_update_post_push(struct mptcp_sock= *msk, * that has been handed to the subflow for transmission * and skip update in case it was old dfrag. */ - if (likely(after64(snd_nxt_new, msk->snd_nxt))) + if (likely(after64(snd_nxt_new, msk->snd_nxt))) { + msk->bytes_sent +=3D snd_nxt_new - msk->snd_nxt; msk->snd_nxt =3D snd_nxt_new; + } } =20 void mptcp_check_and_set_pending(struct sock *sk) @@ -2585,6 +2589,7 @@ static void __mptcp_retrans(struct sock *sk) } if (copied) { dfrag->already_sent =3D max(dfrag->already_sent, info.sent); + msk->bytes_retrans +=3D copied; tcp_push(ssk, 0, info.mss_now, tcp_sk(ssk)->nonagle, info.size_goal); WRITE_ONCE(msk->allow_infinite_fallback, false); @@ -3098,6 +3103,10 @@ static int mptcp_disconnect(struct sock *sk, int fla= gs) WRITE_ONCE(msk->csum_enabled, mptcp_is_checksum_enabled(sock_net(sk))); mptcp_pm_data_reset(msk); mptcp_ca_reset(sk); + msk->bytes_acked =3D 0; + msk->bytes_received =3D 0; + msk->bytes_sent =3D 0; + msk->bytes_retrans =3D 0; =20 sk->sk_shutdown =3D 0; sk_error_report(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index babf1230c84d..8559d4f81654 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -262,10 +262,13 @@ struct mptcp_sock { u64 local_key; u64 remote_key; u64 write_seq; + u64 bytes_sent; u64 snd_nxt; + u64 bytes_received; u64 ack_seq; atomic64_t rcv_wnd_sent; u64 rcv_data_fin_seq; + u64 bytes_retrans; int rmem_fwd_alloc; struct sock *last_snd; int snd_burst; @@ -274,6 +277,7 @@ struct mptcp_sock { * recovery related fields are under data_lock * protection */ + u64 bytes_acked; u64 snd_una; u64 wnd_end; unsigned long timer_ival; diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index d2aa02e28917..2265387a5db2 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -888,7 +888,9 @@ static int mptcp_getsockopt_first_sf_only(struct mptcp_= sock *msk, int level, int =20 void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info) { + struct sock *sk =3D (struct sock *)msk; u32 flags =3D 0; + bool slow; =20 memset(info, 0, sizeof(*info)); =20 @@ -914,11 +916,21 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, str= uct mptcp_info *info) if (READ_ONCE(msk->can_ack)) flags |=3D MPTCP_INFO_FLAG_REMOTE_KEY_RECEIVED; info->mptcpi_flags =3D flags; - info->mptcpi_token =3D READ_ONCE(msk->token); - info->mptcpi_write_seq =3D READ_ONCE(msk->write_seq); - info->mptcpi_snd_una =3D READ_ONCE(msk->snd_una); - info->mptcpi_rcv_nxt =3D READ_ONCE(msk->ack_seq); - info->mptcpi_csum_enabled =3D READ_ONCE(msk->csum_enabled); + mptcp_data_lock(sk); + info->mptcpi_snd_una =3D msk->snd_una; + info->mptcpi_rcv_nxt =3D msk->ack_seq; + info->mptcpi_bytes_acked =3D msk->bytes_acked; + mptcp_data_unlock(sk); + + slow =3D lock_sock_fast(sk); + info->mptcpi_csum_enabled =3D msk->csum_enabled; + info->mptcpi_token =3D msk->token; + info->mptcpi_write_seq =3D msk->write_seq; + info->mptcpi_retransmits =3D inet_csk(sk)->icsk_retransmits; + info->mptcpi_bytes_sent =3D msk->bytes_sent; + info->mptcpi_bytes_received =3D msk->bytes_received; + info->mptcpi_bytes_retrans =3D msk->bytes_retrans; + unlock_sock_fast(sk, slow); } EXPORT_SYMBOL_GPL(mptcp_diag_fill_info); =20 --=20 2.40.0 From nobody Thu Apr 25 01:04:21 2024 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 46BF37E7 for ; Thu, 4 May 2023 16:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683218412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yoaN9Co0RE1kwiNkUoLTtI8ryt+zs8qoIO+TEn4OKgw=; b=S3EAsS5J/dy6luUh+L3Uu3IGdb/aotBwBGEFAursTrkWADki7K8ARoDkBtiGfpVV47j3J2 Dvm3aMqOGl93HMYPUegPJkLxmmTuWOD+9Gg+/HfyXOisxNbRRU6IwgDomcNFbkKF9Ad2Wk B/uiaxTXvoCWiJJpvHvDugUn591PeKA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-99-3zx9QauINhO5xpahCWqY-A-1; Thu, 04 May 2023 12:40:10 -0400 X-MC-Unique: 3zx9QauINhO5xpahCWqY-A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 693EF299E74A for ; Thu, 4 May 2023 16:40:10 +0000 (UTC) Received: from gerbillo.redhat.com (unknown [10.39.193.75]) by smtp.corp.redhat.com (Postfix) with ESMTP id ED6501121331 for ; Thu, 4 May 2023 16:40:09 +0000 (UTC) From: Paolo Abeni To: mptcp@lists.linux.dev Subject: [PATCH mptcp-next 4/4] selftests: mptcp: explicitly tests aggregate countes Date: Thu, 4 May 2023 18:40:02 +0200 Message-Id: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8"; x-default="true" Update the existing sockopt test-case to do some some basic checks on the newly added counters. Signed-off-by: Paolo Abeni Reviewed-by: Matthieu Baerts --- .../selftests/net/mptcp/mptcp_sockopt.c | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/test= ing/selftests/net/mptcp/mptcp_sockopt.c index ae61f39556ca..0c58de3ef339 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c +++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c @@ -51,6 +51,11 @@ struct mptcp_info { __u8 mptcpi_local_addr_used; __u8 mptcpi_local_addr_max; __u8 mptcpi_csum_enabled; + __u32 mptcpi_retransmits; + __u64 mptcpi_bytes_retrans; + __u64 mptcpi_bytes_sent; + __u64 mptcpi_bytes_received; + __u64 mptcpi_bytes_acked; }; =20 struct mptcp_subflow_data { @@ -83,6 +88,7 @@ struct mptcp_subflow_addrs { =20 struct so_state { struct mptcp_info mi; + struct mptcp_info last_sample; uint64_t mptcpi_rcv_delta; uint64_t tcpi_rcv_delta; }; @@ -320,6 +326,7 @@ static void do_getsockopt_mptcp_info(struct so_state *s= , int fd, size_t w) =20 assert(olen =3D=3D sizeof(i)); =20 + s->last_sample =3D i; if (s->mi.mptcpi_write_seq =3D=3D 0) s->mi =3D i; =20 @@ -556,6 +563,19 @@ static void process_one_client(int fd, int pipefd) do_getsockopts(&s, fd, ret, ret2); if (s.mptcpi_rcv_delta !=3D (uint64_t)ret + 1) xerror("mptcpi_rcv_delta %" PRIu64 ", expect %" PRIu64, s.mptcpi_rcv_del= ta, ret + 1, s.mptcpi_rcv_delta - ret); + if (s.last_sample.mptcpi_bytes_sent !=3D ret2) + xerror("mptcpi_bytes_sent %" PRIu64 ", expect %" PRIu64, + s.last_sample.mptcpi_bytes_sent, ret2, + s.last_sample.mptcpi_bytes_sent - ret2); + if (s.last_sample.mptcpi_bytes_received !=3D ret) + xerror("mptcpi_bytes_received %" PRIu64 ", expect %" PRIu64, + s.last_sample.mptcpi_bytes_received, ret, + s.last_sample.mptcpi_bytes_received - ret); + if (s.last_sample.mptcpi_bytes_acked !=3D ret) + xerror("mptcpi_bytes_acked %" PRIu64 ", expect %" PRIu64, + s.last_sample.mptcpi_bytes_acked, ret2, + s.last_sample.mptcpi_bytes_acked - ret2); + close(fd); } =20 --=20 2.40.0