MPTCP Linux Development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kalpan Jani" <kalpan.jani@mpiricsoftware.com>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH net-next] mptcp: normalize seq numbers reported in mptcp_info
Date: Tue, 25 Aug 2026 11:51:35 +0000	[thread overview]
Message-ID: <20260825115135.B746F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260825113355.3573376-1-kalpan.jani@mpiricsoftware.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Asymmetric normalization of local and remote sequence numbers creates an off-by-one inconsistency in MPTCP_INFO.
--

--- Patch [1]: [PATCH net-next] mptcp: normalize seq numbers reported in mptcp_info ---
commit 6231029f4c06cd4480ab1f97fc9151acd4862390
Author: Kalpan Jani <kalpan.jani@mpiricsoftware.com>

mptcp: normalize seq numbers reported in mptcp_info

This commit normalizes the sequence numbers reported by mptcp_info.
It caches the local and remote initial sequence numbers and subtracts them
in mptcp_diag_fill_info() so the diagnostic fields start near 0.

Link: https://github.com/multipath-tcp/mptcp_net-next/issues/445

> diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c
> index fcf6feb2a9eb5..0468099b19bfc 100644
> --- a/net/mptcp/sockopt.c
> +++ b/net/mptcp/sockopt.c
[ ... ]
> @@ -1010,7 +1010,7 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>  	slow = lock_sock_fast(sk);
>  	info->mptcpi_csum_enabled = READ_ONCE(msk->csum_enabled);
>  	info->mptcpi_token = msk->token;
> -	info->mptcpi_write_seq = msk->write_seq;
> +	info->mptcpi_write_seq = msk->write_seq - msk->local_idsn;
>  	info->mptcpi_retransmits = inet_csk(sk)->icsk_retransmits;
>  	info->mptcpi_bytes_sent = msk->bytes_sent;
>  	info->mptcpi_bytes_received = msk->bytes_received;
[ ... ]
> @@ -1024,8 +1024,8 @@ void mptcp_diag_fill_info(struct mptcp_sock *msk, struct mptcp_info *info)
>  
>  	mptcp_data_lock(sk);
>  	info->mptcpi_last_ack_recv = jiffies_to_msecs(now - msk->last_ack_recv);
> -	info->mptcpi_snd_una = msk->snd_una;
> -	info->mptcpi_rcv_nxt = msk->ack_seq;
> +	info->mptcpi_snd_una = msk->snd_una - msk->local_idsn;
> +	info->mptcpi_rcv_nxt = msk->ack_seq - msk->remote_idsn;
>  	info->mptcpi_bytes_acked = msk->bytes_acked;
>  	mptcp_data_unlock(sk);
>  }
> diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c
> index af81ad5e699d1..4fa19835c4055 100644
> --- a/net/mptcp/subflow.c
> +++ b/net/mptcp/subflow.c
> @@ -465,6 +465,7 @@ void __mptcp_sync_state(struct sock *sk, int state)
>  		 * even for the FASTOPEN scenarios
>  		 */
>  		WRITE_ONCE(msk->write_seq, subflow->idsn + 1);
> +		WRITE_ONCE(msk->local_idsn, subflow->idsn);
>  		WRITE_ONCE(msk->snd_nxt, msk->write_seq);
>  		mptcp_set_state(sk, state);
>  		sk->sk_state_change(sk);
[ ... ]
> @@ -491,6 +492,7 @@ static void subflow_set_remote_key(struct mptcp_sock *msk,
>  
>  	WRITE_ONCE(msk->remote_key, subflow->remote_key);
>  	WRITE_ONCE(msk->ack_seq, subflow->iasn);
> +	WRITE_ONCE(msk->remote_idsn, subflow->iasn);

[Severity: Medium]
Will this result in an asymmetric baseline where mptcpi_write_seq and
mptcpi_snd_una start at 1, while mptcpi_rcv_nxt starts at 0?

Looking at subflow_set_remote_key(), subflow->iasn is incremented before it is
assigned to msk->remote_idsn:

	mptcp_crypto_key_sha(subflow->remote_key, NULL, &subflow->iasn);
	subflow->iasn++;

However, in __mptcp_sync_state(), msk->local_idsn is assigned the unincremented
subflow->idsn:

	WRITE_ONCE(msk->write_seq, subflow->idsn + 1);
	WRITE_ONCE(msk->local_idsn, subflow->idsn);

When these are subtracted in mptcp_diag_fill_info(), msk->write_seq (which is
subflow->idsn + 1) minus msk->local_idsn results in 1, while msk->ack_seq minus
msk->remote_idsn results in 0.

Should msk->local_idsn and msk->remote_idsn both use either the incremented or
unincremented hash to ensure the normalized sequences start at the same value?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260825113355.3573376-1-kalpan.jani@mpiricsoftware.com?part=1

  reply	other threads:[~2026-08-25 11:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25 11:33 [PATCH net-next] mptcp: normalize seq numbers reported in mptcp_info Kalpan Jani
2026-08-25 11:51 ` sashiko-bot [this message]
2026-08-25 12:48 ` MPTCP CI
2026-08-26  6:03 ` [PATCH net-next v2] " Kalpan Jani
2026-08-26  7:26   ` MPTCP CI
2026-08-26  9:48   ` Kalpan Jani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260825115135.B746F1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kalpan.jani@mpiricsoftware.com \
    --cc=mptcp@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox