MPTCP Linux Development
 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 v12 7/7] selftests: mptcp: cover msg_zerocopy test
Date: Mon, 30 Nov 2026 06:40:06 +0000	[thread overview]
Message-ID: <sashiko-outbox-240510@kernel.org> (raw)
In-Reply-To: <7e7e09aa0c307412e516ac35cadbe403c99d7a95.1796019473.git.tanggeliang@kylinos.cn>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [Medium] selftests: mptcp: missing zerocopy check in msg_zerocopy.sh
  wrapper
- [Medium] mptcp: unscheduled sk_mem_charge() without SG in
  mptcp_sendmsg_frag()
- [Medium] mptcp: zc cleared before mptcp_sendmsg_fastopen() in
  mptcp_sendmsg()
--

commit 1852c1fd7d811fa5bc6531df5e7b0dad74715d8f
Author: Geliang Tang <geliang@kernel.org>

selftests: mptcp: cover msg_zerocopy test

This commit adds a wrapper script and build rules to run the msg_zerocopy
test as part of the MPTCP selftest suite.

> diff --git a/tools/testing/selftests/net/mptcp/msg_zerocopy.sh b/tools/testing/selftests/net/mptcp/msg_zerocopy.sh
> new file mode 100755
> index 0000000000000..118fff27dc5cd
> --- /dev/null
> +++ b/tools/testing/selftests/net/mptcp/msg_zerocopy.sh
> @@ -0,0 +1,8 @@
> +#!/bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +
> +. "$(dirname "${0}")/mptcp_lib.sh"
> +
> +mptcp_lib_check_mptcp
> +
> +exec "$(dirname "${0}")/../msg_zerocopy.sh" "$@"

[Severity: Medium]
Does this wrapper actually check for MPTCP zerocopy support before running
../msg_zerocopy.sh?

mptcp_lib_check_mptcp() only checks that /proc/sys/net/mptcp/enabled exists.
On a kernel with MPTCP enabled but without MPTCP zerocopy support, running
this script executes the TCP and UDP zerocopy tests in ../msg_zerocopy.sh,
prints skip messages for the MPTCP subtests, and exits 0 (KSFT_PASS) instead
of KSFT_SKIP, while also bypassing SELFTESTS_MPTCP_LIB_EXPECT_ALL_FEATURES=1.
Checking for the feature symbol via mptcp_lib_kallsyms_has() (for example
"mptcp_sendmsg_zerocopy_iter$") before execing ../msg_zerocopy.sh would avoid
this.

[Severity: Medium]
In commit "mptcp: add MSG_ZEROCOPY support", can mptcp_sendmsg_frag() call
sk_mem_charge() without prior memory scheduling when the subflow route lacks
NETIF_F_SG?

net/mptcp/protocol.c:mptcp_sendmsg_frag() {
	...
		if (skb_zcopy_pure(skb) != !!dfrag->ubuf ||
		    (dfrag->ubuf && skb_zcopy(skb) &&
		     skb_zcopy(skb) != dfrag->ubuf)) {
			tcp_mark_push(tp, skb);
			goto alloc_skb;
		}
	...
	if (!dfrag->ubuf) {
		/* like TCP, allow some progress up to tcp_wmem[0] */
		avail = tcp_wmem_schedule(ssk, copy);
	...
		if (dfrag->ubuf && !skb_zcopy(skb)) {
			skb_zcopy_set(skb, dfrag->ubuf, NULL);
			if (ssk->sk_route_caps & NETIF_F_SG) {
				skb_shinfo(skb)->flags |= SKBFL_PURE_ZEROCOPY;
				zc = true;
			}
		}
	}

	if (!zc)
		zc = skb_zcopy_pure(skb);
	...
	if (!zc)
		sk_mem_charge(ssk, copy);
}

tcp_wmem_schedule() is skipped whenever dfrag->ubuf is set, but
SKBFL_PURE_ZEROCOPY and zc = true are only set when NETIF_F_SG is present on
the subflow route.  Without NETIF_F_SG, zc stays false, so sk_mem_charge()
charges unscheduled bytes against ssk->sk_forward_alloc (driving it negative),
and the next mptcp_sendmsg_frag() call fails skb_zcopy_pure(skb) !=
!!dfrag->ubuf and allocates a new skb for every fragment.

[Severity: Medium]
In commit "mptcp: add MSG_ZEROCOPY support", does mptcp_sendmsg() always pass
NULL instead of ubuf to mptcp_sendmsg_fastopen()?

net/mptcp/protocol.c:mptcp_sendmsg() {
	...
	if (unlikely(inet_test_bit(DEFER_CONNECT, sk) ||
		     msg->msg_flags & MSG_FASTOPEN)) {
		int copied_syn = 0;

		if (zc && (msg->msg_flags & MSG_FASTOPEN ||
			   inet_test_bit(DEFER_CONNECT, sk))) {
			uarg_to_msgzc(ubuf)->zerocopy = 0;
			zc = false;
		}

		ret = mptcp_sendmsg_fastopen(sk, msg, len, &copied_syn,
					     zc ? ubuf : NULL);
}

Because zc is cleared to false right before the call, zc ? ubuf : NULL always
evaluates to NULL.  tcp_send_syn_data() never attaches ubuf to the SYN+DATA
skb via skb_zcopy_set(), and when mptcp_sendmsg_fastopen() returns
-EINPROGRESS with copied_syn > 0, mptcp_sendmsg() jumps to out and calls
net_zcopy_put(ubuf), completing the zerocopy notification before the SYN data
is sent or acknowledged.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796019473.git.tanggeliang@kylinos.cn?part=7

  reply	other threads:[~2026-11-30  6:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  6:25 [PATCH mptcp-next v12 0/7] mptcp: add MSG_ZEROCOPY support Geliang Tang
2026-11-30  6:25 ` [PATCH mptcp-next v12 1/7] mptcp: use local variable tp in sendmsg_frag Geliang Tang
2026-11-30  6:29   ` sashiko-bot
2026-11-30  6:25 ` [PATCH mptcp-next v12 2/7] mptcp: remove redundant orig_offset in carve_data_frag Geliang Tang
2026-11-30  6:25 ` [PATCH mptcp-next v12 3/7] mptcp: add MSG_ZEROCOPY support Geliang Tang
2026-11-30  6:56   ` sashiko-bot
2026-11-30  6:25 ` [PATCH mptcp-next v12 4/7] mptcp: handle SO_ZEROCOPY in setsockopt Geliang Tang
2026-11-30  6:25 ` [PATCH mptcp-next v12 5/7] Documentation: msg_zerocopy: add MPTCP support Geliang Tang
2026-11-30  6:25 ` [PATCH mptcp-next v12 6/7] selftests: net: " Geliang Tang
2026-11-30  6:25 ` [PATCH mptcp-next v12 7/7] selftests: mptcp: cover msg_zerocopy test Geliang Tang
2026-11-30  6:40   ` sashiko-bot [this message]
2026-11-30  7:30 ` [PATCH mptcp-next v12 0/7] mptcp: add MSG_ZEROCOPY support MPTCP CI

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-240510@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox