All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Geliang Tang" <geliang@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-next v8] mptcp: count the DATA_FIN in mptcp_inq_hint
Date: Sat, 05 Dec 2026 22:40:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-251968@kernel.org> (raw)
In-Reply-To: <29b6798cd39edaab5dcd58f10148067edecb4f1e.1796509287.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] mptcp: mptcp_inq_hint() reports INQ=1 before SOCK_DONE
  causing recvmsg EAGAIN
- [Low] mptcp: unused u64 *seq parameter in static helper
  mptcp_pending_eof()
--

commit 2e71023ce38283df6ab91e55af965d48b4b59289
Author: Geliang Tang <geliang@kernel.org>

mptcp: count the DATA_FIN in mptcp_inq_hint

This commit updates mptcp_inq_hint() to count a pending DATA_FIN in
TCP_CM_INQ even while payload is still queued, introducing
mptcp_check_fin_eof() and mptcp_pending_eof().

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 14fca55d46199..09380154ee55b 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c

[ ... ]

> @@ -588,6 +588,22 @@ static bool mptcp_pending_data_fin(struct sock *sk, u64 *seq)
>  	return false;
>  }
>  
> +static bool mptcp_check_fin_eof(const struct mptcp_sock *msk)
> +{
> +	return !__mptcp_check_fallback(msk) ||
> +	       (msk->first && sock_flag(msk->first, SOCK_DONE));
> +}
> +
> +static bool mptcp_pending_eof(const struct sock *sk, u64 *seq)
> +{
> +	const struct mptcp_sock *msk = mptcp_sk(sk);
> +
> +	if (!mptcp_pending_data_fin(sk, seq))
> +		return false;
> +
> +	return mptcp_check_fin_eof(msk);
> +}

[Severity: Low]
Is the seq parameter of mptcp_pending_eof() needed?

The only caller is mptcp_inq_hint(), which passes NULL.  Passing seq to
mptcp_pending_data_fin() before mptcp_check_fin_eof() would also write
*seq even when mptcp_pending_eof() returns false.

Dropping the parameter and calling mptcp_pending_data_fin(sk, NULL)
directly avoids this.

[ ... ]

> @@ -2480,22 +2495,15 @@ static bool mptcp_move_skbs(struct sock *sk)
>  static unsigned int mptcp_inq_hint(const struct sock *sk)
>  {
>  	const struct mptcp_sock *msk = mptcp_sk(sk);
> -	const struct sk_buff *skb;
> -
> -	skb = skb_peek(&sk->sk_receive_queue);
> -	if (skb) {
> -		u64 hint_val = mptcp_data_avail(msk);
> +	u64 hint_val = mptcp_data_avail(msk);
>  
> -		if (hint_val >= INT_MAX)
> -			return INT_MAX;
> -
> -		return (unsigned int)hint_val;
> -	}
> +	if (hint_val >= INT_MAX)
> +		return INT_MAX;
>  
> -	if (sock_flag(sk, SOCK_DONE))
> -		return 1;
> +	if (sock_flag(sk, SOCK_DONE) || mptcp_pending_eof(sk, NULL))
> +		hint_val += 1;
>  
> -	return 0;
> +	return (unsigned int)hint_val;
>  }

[Severity: Medium]
Can mptcp_inq_hint() now advertise TCP_CM_INQ = 1 on an empty receive
queue before SOCK_DONE or RCV_SHUTDOWN is set, causing a non-blocking
recvmsg() to return -EAGAIN instead of EOF?

When payload and a DATA_FIN arrive in softirq while the socket is not
owned by userspace, move_skbs_to_msk() queues the payload directly on
sk_receive_queue and defers mptcp_check_data_fin() to mptcp_worker().
If userspace drains the queue before the worker runs, msk->backlog_list
is empty so mptcp_recvmsg() skips mptcp_move_skbs():

<softirq>                        userspace
mptcp_data_ready()
  move_skbs_to_msk()
    enqueue on sk_receive_queue
    mptcp_schedule_work(sk)
                                 mptcp_recvmsg()
                                   drains sk_receive_queue (avail == 0)
                                   backlog_list empty, skips move_skbs
                                   mptcp_inq_hint() -> returns 1
                                 recvmsg(MSG_DONTWAIT)
                                   SOCK_DONE & RCV_SHUTDOWN still unset
                                   returns -EAGAIN  <-- expected 0 (EOF)

Because TCP_CM_INQ = 1 tells a TCP_INQ reader to issue another read for
EOF without polling, this causes a spurious -EAGAIN until mptcp_worker()
runs.  Calling mptcp_check_data_fin(sk) under lock_sock(sk) in
mptcp_recvmsg() would set SOCK_DONE and RCV_SHUTDOWN synchronously.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/29b6798cd39edaab5dcd58f10148067edecb4f1e.1796509287.git.tanggeliang@kylinos.cn?part=1

      reply	other threads:[~2026-12-05 22:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05 22:26 [PATCH mptcp-next v8] mptcp: count the DATA_FIN in mptcp_inq_hint Geliang Tang
2026-12-05 22:40 ` sashiko-bot [this message]

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=sashiko-outbox-251968@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=geliang@kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.