From: netdev-bot+sashiko@kernel.org
To: geliang@kernel.org
Cc: mptcp@lists.linux.dev, kuba@kernel.org
Subject: Re: [PATCH mptcp-next v29 6/8] mptcp: remove CB offset field
Date: Fri, 20 Nov 2026 18:41:52 +0000 [thread overview]
Message-ID: <179520011242.3133.5608778876652732838@kernel.org> (raw)
In-Reply-To: <fbc3299b9062220507c5e1d50c13eae8c513b6f4.1795063943.git.tanggeliang@kylinos.cn>
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 2
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The resync skip branch this patch adds to
__mptcp_recvmsg_mskq() and mptcp_recv_skb() runs when the reader…
- [Medium] Before this patch, __mptcp_move_skb() (partial-packet path)
and __mptcp_ofo_queue() moved CB offset/map_seq up to msk->ack_seq.
- [Low] The commit message says only that the CB offset field is removed
and that end_seq changes meaning.
- [Low] The commit message justifies the explicit
__mptcp_sync_rcv_sequence() call in __mptcp_move_skb() as needed 'when…
--
mptcp: remove CB offset field
This commit drops the per-skb MPTCP CB offset field. A new msk-level
copied_seq now tracks the bytes already copied to user space, as TCP
does. end_seq now stores map_seq + copy_len, and mptcp_dsn() and
mptcp_end_dsn() derive the DSNs from map_seq, end_seq and skb->len.
> Note that the explicit synchronization in __mptcp_move_skb() is needed to
> ensure that the TFO skb in the receive queue got its map_seq synched
> before the next skb lands into the receive queue when spooling the backlog
> at mptcp_release_cb() time, as the release CB synchronization will happen
> later.
[Severity: Low]
Is this description accurate? Both mptcp_release_cb() and
mptcp_move_skbs() handle MPTCP_SYNC_SEQ at the top of every loop
iteration. That happens before mptcp_can_spool_backlog() splices the
backlog:
net/mptcp/protocol.c:mptcp_release_cb() {
...
if (__test_and_clear_bit(MPTCP_SYNC_SEQ, &msk->cb_flags)) {
msk->copied_seq += msk->tfo_iasn;
__mptcp_sync_rcv_sequence(sk);
}
spool_bl = mptcp_can_spool_backlog(sk, &skbs);
...
}
The earlier commit "mptcp: drop the cant_coalesce CB field" describes
the same ordering.
The other caller of __mptcp_move_skb() is the BH path through
__mptcp_move_skbs_from_subflow(). It only runs when the msk is not owned,
and in that case subflow_set_remote_key() has already updated copied_seq
and synced map_seq together.
So the sync in __mptcp_move_skb() seems to matter only when tfo_iasn is
0 (TFO followed by fallback before the remote key arrives). In that case
it leaves map_seq unchanged and just clears rcvd_dummy_seq.
The map_seq sync and the copied_seq += tfo_iasn update are now separate.
They stay consistent only if __mptcp_move_skb() never runs while
MPTCP_SYNC_SEQ is pending. Could the commit message state that invariant
instead?
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 1a5d1f97c0875..1ed232a4e8b4d 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -168,7 +168,8 @@ static bool __mptcp_try_coalesce(struct sock *sk, struct sk_buff *to,
> int limit = READ_ONCE(sk->sk_rcvbuf);
>
> if (MPTCP_SKB_CB(from)->map_seq != mptcp_end_dsn(to) ||
> - MPTCP_SKB_CB(from)->offset ||
> + (MPTCP_SKB_CB(from)->flags | MPTCP_SKB_CB(to)->flags) &
> + MPTCP_SKB_CB_F_OFFSET ||
> ((to->len + from->len) > (limit >> 3)) ||
> !skb_try_coalesce(to, from, fragstolen, delta))
> return false;
[Severity: Low]
This isn't a bug, but the commit message leaves out two changes. First,
offset is replaced by a new u16 flags field that carries
MPTCP_SKB_CB_F_OFFSET. Second, __mptcp_try_coalesce() now also refuses
to coalesce when the destination skb (to) has an initial offset. Before
this patch, only MPTCP_SKB_CB(from)->offset blocked coalescing.
The new restriction on to looks necessary with the new end_seq encoding.
Copying from->end_seq into a to skb that has an offset would make
mptcp_dsn(to) collapse to map_seq.
It is still a behaviour change. Skbs with an offset are common with
reinjection, where subflow_check_data_avail() discards prefixes that were
already acked. Such skbs can no longer absorb later in-sequence skbs, in
the receive queue or in the OFO queue.
Why MPTCP_SKB_CB_F_OFFSET is tied to TCPHDR_FLAGS_MASK only becomes
clear in the later commit "mptcp: sync mptcp skb cb layout with tcp
one".
Could the changelog mention the new flags field and the coalescing
change?
[ ... ]
> @@ -495,10 +496,6 @@ static bool __mptcp_move_skb(struct sock *sk, struct sk_buff *skb)
> /* Partial packet */
> if (after64(mptcp_end_dsn(skb), msk->ack_seq)) {
> copy_len = mptcp_end_dsn(skb) - msk->ack_seq;
> - MPTCP_SKB_CB(skb)->offset += msk->ack_seq -
> - MPTCP_SKB_CB(skb)->map_seq;
> - MPTCP_SKB_CB(skb)->map_seq += msk->ack_seq -
> - MPTCP_SKB_CB(skb)->map_seq;
> goto insert;
> }
[Severity: Medium]
Without this clamping, can the reader deliver a different number of
bytes than the copy_len credited to bytes_received?
Before this patch, both this partial path and __mptcp_ofo_queue() moved
offset and map_seq up to msk->ack_seq. The reader therefore delivered
exactly copy_len bytes. Now the reader computes the offset from its own
copied_seq:
offset = *seq - MPTCP_SKB_CB(skb)->map_seq;
data_len = skb->len - offset;
bytes_received, however, is still credited relative to ack_seq. The two
diverge once ack_seq moves without matching queued data. One example is
the DATA_FIN increment in mptcp_check_data_fin():
WRITE_ONCE(msk->ack_seq, msk->ack_seq + 1);
Say a peer DATA_FIN at F has been processed, so ack_seq is F+1 and the
reader's copied_seq is F. The peer then sends a 15-byte mapping starting
at F-5:
subflow_check_data_avail()
mptcp_subflow_discard_data() /* drops 6 bytes, up to ack_seq */
mptcp_init_skb() /* offset 6, map_seq F-5, copy_len 9 */
__mptcp_move_skb() /* dsn == ack_seq, bytes_received += 9 */
__mptcp_recvmsg_mskq() /* offset = F - (F-5) = 5, copies 10 */
Does the reader then give user space a byte the subflow had already
discarded as a duplicate, and add 10 to bytes_consumed? That would make
bytes_consumed larger than bytes_received and wrap the u64 subtraction
in mptcp_data_avail(). The effects would be:
- SIOCINQ and TCP_CM_INQ report INT_MAX
- rcvbuf autotuning is skipped
- EPOLLIN is always reported
- mptcp_close() does an MP_FASTCLOSE instead of a graceful close
If the peer instead sends in-sequence data at F+1, map_seq is after
copied_seq. The new resync branch in the reader then silently drops the
whole payload.
Nothing in the rx path seems to reject data after DATA_FIN.
mptcp_data_ready() only checks subflow->closing, and
__mptcp_add_backlog() only drops in TCP_CLOSE. The final patch in the
series still leaves this partial path unclamped.
[ ... ]
> @@ -2208,33 +2202,39 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, struct msghdr *msg,
[ ... ]
> skb_queue_walk_safe(&sk->sk_receive_queue, skb, tmp) {
> - u32 delta, offset = MPTCP_SKB_CB(skb)->offset;
> - u32 data_len = skb->len - offset;
> + u32 data_len;
> + u64 offset;
> u32 count;
> int err;
>
> - if (flags & MSG_PEEK) {
> - /* skip already peeked skbs */
> - if (total_data_len + data_len <= copied_total) {
> - total_data_len += data_len;
> + if (unlikely(before64(*seq, MPTCP_SKB_CB(skb)->map_seq))) {
> + *seq = mptcp_end_dsn(skb);
> + msk->bytes_consumed += skb->len;
> + if (!(flags & MSG_PEEK))
> + mptcp_eat_recv_skb(sk, skb);
> + else
> *last = skb;
> - continue;
> - }
> + continue;
> + }
[Severity: Medium]
Should bytes_consumed be updated here when MSG_PEEK is set? With
MSG_PEEK the skb stays queued (*last = skb) and msk->copied_seq does not
move. The normal copy path in this same function only updates
bytes_consumed when !(flags & MSG_PEEK).
mptcp_recvmsg() also rebuilds peek_seq from copied_seq after
mptcp_move_skbs() and after sk_wait_data():
if (flags & MSG_PEEK)
peek_seq = msk->copied_seq + copied;
This throws away the jump to mptcp_end_dsn(skb) that the branch just
made, so the branch fires again for the same skb. Every later peek adds
skb->len again. So does the final real read, whether through recvmsg()
or through mptcp_recv_skb() for read_sock and splice:
net/mptcp/protocol.c:mptcp_recv_skb() {
...
if (unlikely(before64(msk->copied_seq,
MPTCP_SKB_CB(skb)->map_seq))) {
msk->copied_seq = mptcp_end_dsn(skb);
msk->bytes_consumed += skb->len;
mptcp_eat_recv_skb(sk, skb);
continue;
}
...
}
Can bytes_consumed then grow past bytes_received and wrap the u64
subtraction in mptcp_data_avail()?
return READ_ONCE(msk->bytes_received) - READ_ONCE(msk->bytes_consumed);
The branch is reachable once ack_seq is ahead of the queued data. For
example, after a DATA_FIN at F, mptcp_check_data_fin() bumps ack_seq to
F+1. If the peer then sends in-sequence data mapped at F+1,
subflow_check_data_avail() and __mptcp_add_backlog() accept it in
CLOSE_WAIT. The reader at copied_seq == F is before map_seq F+1, so it
takes the skip branch.
The consequences would be:
- mptcp_inq_hint() returns INT_MAX
- rcvbuf autotuning is skipped in mptcp_rcv_space_adjust()
- mptcp_epollin_ready() always returns true
- mptcp_close() picks MP_FASTCLOSE because of apparent unread data
The skipped payload is also dropped without a MIB counter or a warning.
The commit message does not mention this new way of dropping data.
The final patch in the series still has the unconditional
bytes_consumed += skb->len in both __mptcp_recvmsg_mskq() and
mptcp_recv_skb().
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795063943.git.tanggeliang%40kylinos.cn
next prev parent reply other threads:[~2026-11-20 18:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 5:10 [PATCH mptcp-next v29 0/8] Reduce the differences between TCP and MPTCP for TLS usage Geliang Tang
2026-11-19 5:10 ` [PATCH mptcp-net v29 1/8] mptcp: clear rcv_data_fin_seq in mptcp_disconnect Geliang Tang
2026-11-20 18:41 ` netdev-bot+sashiko
2026-11-19 5:10 ` [PATCH mptcp-net v29 2/8] mptcp: fix TFO SIOCINQ overflow in mptcp_inq_hint Geliang Tang
2026-11-19 5:26 ` sashiko-bot
2026-11-20 18:41 ` netdev-bot+sashiko
2026-11-19 5:10 ` [PATCH mptcp-next v29 3/8] mptcp: drop the mptcp_ooo_try_coalesce() helper Geliang Tang
2026-11-19 5:10 ` [PATCH mptcp-next v29 4/8] mptcp: drop the cant_coalesce CB field Geliang Tang
2026-11-20 18:41 ` netdev-bot+sashiko
2026-11-19 5:10 ` [PATCH mptcp-next v29 5/8] mptcp: encapsulate CB DSN field access with helpers Geliang Tang
2026-11-20 18:41 ` netdev-bot+sashiko
2026-11-19 5:10 ` [PATCH mptcp-next v29 6/8] mptcp: remove CB offset field Geliang Tang
2026-11-20 18:41 ` netdev-bot+sashiko [this message]
2026-11-19 5:10 ` [PATCH mptcp-next v29 7/8] mptcp: sync mptcp skb cb layout with tcp one Geliang Tang
2026-11-19 5:43 ` sashiko-bot
2026-11-20 18:41 ` netdev-bot+sashiko
2026-11-19 5:10 ` [PATCH mptcp-next v29 8/8] mptcp: defer read_sock cleanup to mptcp_worker Geliang Tang
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=179520011242.3133.5608778876652732838@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=geliang@kernel.org \
--cc=kuba@kernel.org \
--cc=mptcp@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.