mptcp: add MSG_ZEROCOPY support
Subsystems (4)
Geliang Tang
reviewerv8 cover mptcp: add MSG_ZEROCOPY support
From: Geliang Tang <[email protected]>
This series adds MSG_ZEROCOPY support for MPTCP sockets, allowing userspace to transmit data without intermediate kernel copies, and provides corresponding selftests to exercise the new path.
Patch 1 fixes an uninitialized memory leak in the IPv4 error queue handling for zerocopy completion notifications by adding an early check for SO_EE_ORIGIN_ZEROCOPY.
Patch 2 is a small cleanup along the mptcp_sendmsg path.
Patch 3 removes the redundant orig_offset parameter from mptcp_carve_data_frag() since it merely duplicates pfrag->offset.
Patch 4 implements the core MSG_ZEROCOPY support. The design follows TCP's reference-counting model, with a single ubuf_info per sendmsg, tracked by three reference buckets: one held by sendmsg itself, one per MPTCP dfrag in the retransmission queue, and one per subflow SKB. Completion is reported only after all bytes are acknowledged at both the MPTCP and subflow levels. The feature is silently downgraded to a regular copy in cases where zero-copy cannot be safely performed (MSG_FASTOPEN, fallback mode, or memory pressure). The new mptcp_sendmsg_zerocopy_iter() helper caps pg_len to U16_MAX (reverting the excess from the iov_iter on overflow) and returns -EFAULT when pg_off exceeds U16_MAX (which can happen on 256KB-page kernels like PowerPC and Hexagon), so the u16 dfrag->data_len and dfrag->offset fields cannot wrap. The caller accumulates the per-iteration byte count via the ssize_t return value.
Patch 5 handles SO_ZEROCOPY in setsockopt.
Patch 6 adds a new 'zerocopy' I/O mode to the mptcp_connect selftest to enable testing and performance validation of the zero-copy send path.
Patch 7 adds a wrapper script to run the zerocopy selftest as part of the regular test suite, ensuring the zero-copy path is exercised in CI.
v8:
- Add pg_off + pg_len overflow check in mptcp_sendmsg_zerocopy_iter() to cap the sum at U16_MAX, preventing silent wraparound in dfrag->offset during partial ACK processing.
- Reorder kzalloc_obj() before sk_wmem_schedule() to eliminate erroneous sk_forward_alloc_add() on allocation failure path.
- Update caller to handle -EAGAIN/-ENOMEM by jumping to wait_for_memory, preserving blocking socket semantics.
- Refactor wait_for_completions_zc() to use clock_gettime(CLOCK_MONOTONIC) instead of loop counter, preventing premature exit when poll() returns immediately after shut_wr().
- Add retry loop in do_sendmsg_zc() to handle short writes from sendmsg(MSG_ZEROCOPY).
- Skip wait_for_completions_zc() when size is 0 to avoid 5-second stall on MPTFO transfers.
v7:
- Add the pg_len / pg_off defensive truncation directly inside mptcp_sendmsg_zerocopy_iter() (the new helper in patch 5). When iov_iter_get_pages2() returns more than U16_MAX bytes, the excess
is reverted from the iov_iter so the next iteration picks it up
cleanly. When the page offset exceeds U16_MAX (on 256KB-page
kernels like PowerPC and Hexagon), the call returns -EFAULT
instead of silently truncating. The non-zerocopy path is left
untouched.
- Refactor mptcp_sendmsg_zerocopy_iter() to return the per-iteration
byte count as ssize_t so the caller can simply accumulate via
copied += ret; this drops a ssize_t *copied out-parameter.
- Clean up and fix the zerocopy completion path in mptcp_connect.c
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
v6:
- Add patch 2 to widen offset field in struct mptcp_data_frag from u16 to
u32 to support page sizes up to 4GB on architectures with large page
sizes (256KB on PowerPC and Hexagon). This prevents offset wrap-around
when page fragment offset exceeds 65535.
- Add patch 5 to fix uninitialized memory leak in IPv4 error queue
handling for zerocopy completion notifications. Add early check for SO_EE_ORIGIN_ZEROCOPY in ipv4_datagram_support_cmsg() to prevent
reading uninitialized memory from ip_hdr(skb)->saddr.
- Refactor zerocopy completion notification draining logic in selftests.
Extract process_zc_cmsg() helper to process individual control messages. Extract drain_errqueue() helper to handle error queue draining.
Simplify wait_for_zc_completions() main loop from 6 levels to 3 levels.
Move variables to their actual usage scope for better maintainability.
- Use batched polling (200ms intervals with 5s total timeout) to drain completion notifications for large transfers that may generate multiple completion events.
- Parse error queue messages to verify all sent data has been ACKed before breaking the completion loop.
- Reset msg_controllen each iteration of the inner reap loop to prevent truncation of control messages.
- Use >= instead of > in the MPTFO size adjustment so file_size reaches 0
when the whole file is sent via fast open.
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
v5:
- A new patch to align struct mptcp_data_frag to 8 bytes on 32-bit.
- Prevent coalescing of dfrags with different ubuf instances into the same subflow skb to avoid premature completion notifications.
- Return -EFAULT instead of -EAGAIN when iov_iter_get_pages2() returns 0
to properly signal iterator exhaustion.
- Account for dfrag metadata overhead in sk_wmem_queued_add() to prevent bypassing socket memory limits.
- Widen data_len field from u16 to u32 to prevent truncation on 64KB-page kernels (ARM64, PPC64).
- In selftests, use batched polling (200ms intervals with 5s total timeout)
to drain completion notifications for large transfers that may generate multiple completion events.
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
v4:
- two more cleanups, patch 2 and patch 7.
- net/mptcp/protocol.c, mptcp_sendmsg_frag(): pull the type-mismatch
check out of the if (can_coalesce) block and use the standard
skb_zcopy_pure() helper; mptcp_sendmsg_zerocopy_iter() now
calls iov_iter_revert() before put_page() in the kzalloc failure
path so a retry starts from the same iterator offset.
- tools/testing/selftests/net/mptcp/mptcp_connect.c, copyfd_io_zc():
reset msg_controllen each iteration of the inner reap loop using a
do {} while block; use >= instead of > in the MPTFO size
adjustment so file_size reaches 0 when the whole file is sent via
fast open.
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
v3:
- Force fresh skb when mixing zerocopy and kernel-copy fragments.
- Simplify zero-copy availability check by using SOCK_ZEROCOPY flag
directly.
- Validate SO_ZEROCOPY value in setsockopt and avoid affecting
fallback subflow.
- In selftests, drain MPTFO partial data, use poll+recvmsg for completion notifications with timeout, and verify getsockopt round-trip.
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
v2:
- patch 2, never mix PURE_ZEROCOPY frags with kernel-copy frags in the
same skb; handle fallback, return values.
- patch 3, a new patch to handle SO_ZEROCOPY in setsockopt.
- patch 4, set SO_ZEROCOPY, handle listen_mode, error queue.
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
v1:
- https://patchwork.kernel.org/project/mptcp/cover/[email protected]/
Geliang Tang (7):
ipv4: fix uninitialized memory in zerocopy cmsg
mptcp: use local variable tp in sendmsg_frag
mptcp: remove redundant orig_offset in carve_data_frag
mptcp: add MSG_ZEROCOPY support
mptcp: handle SO_ZEROCOPY in setsockopt
selftests: mptcp: connect: add zerocopy io mode
selftests: mptcp: connect: cover zerocopy mode
net/ipv4/ip_sockglue.c | 6 + net/mptcp/protocol.c | 165 +++++++++++++-- net/mptcp/protocol.h | 1 + net/mptcp/sockopt.c | 17 +- tools/testing/selftests/net/mptcp/Makefile | 1 + .../selftests/net/mptcp/mptcp_connect.c | 192 +++++++++++++++++- .../net/mptcp/mptcp_connect_zerocopy.sh | 5 + 7 files changed, 372 insertions(+), 15 deletions(-) create mode 100755 tools/testing/selftests/net/mptcp/mptcp_connect_zerocopy.sh
Signature · 1 line
2.55.0
Geliang Tang
reviewerPATCH v8 1/7 ipv4: fix uninitialized memory in zerocopy cmsg
From: Geliang Tang <[email protected]>
When SOF_TIMESTAMPING_OPT_CMSG is enabled and applications read MSG_ZEROCOPY completion notifications from the error queue, the ipv4_datagram_support_cmsg() function attempts to read ip_hdr(skb)->saddr to populate IP_PKTINFO cmsg data. However, zerocopy completion notification skbs don't have IP headers, causing this read to access uninitialized memory which is then leaked to userspace via put_cmsg().
This is because the function checks PKTINFO_SKB_CB(skb)->ipi_ifindex (which aliases the ops pointer in ubuf_info_msgzc stored in skb->cb), and if non-NULL, proceeds to read ip_hdr(skb)->saddr without verifying that the skb actually has an IP header.
Fix this by adding an early check for SO_EE_ORIGIN_ZEROCOPY and returning false, since zerocopy completion notifications don't have IP headers and IP_PKTINFO cmsg is not applicable to them.
--- net/ipv4/ip_sockglue.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/ipv4/ip_sockglue.c +6 -0
@@ -504,6 +504,12 @@ static bool ipv4_datagram_support_cmsg(const struct sock *sk,if (ee_origin ==SO_EE_ORIGIN_LOCAL )return false; +/* Zerocopy completion notifications don't have IP headers, +* so IP_PKTINFO cmsg is not applicable. +*/ +if (ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return false; +/* Support IP_PKTINFO on tstamp packets if requested, to correlate * timestamp with egress dev. Not possible for packets without iif * or without payload (SOF_TIMESTAMPING_OPT_TSONLY).
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 1/7] ipv4: fix uninitialized memory in zerocopy cmsg
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] ipv4: non-existent bug claimed in ipv4_datagram_support_cmsg() - [Low] ipv4: inaccurate Fixes…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] ipv4: non-existent bug claimed in ipv4_datagram_support_cmsg()
- [Low] ipv4: inaccurate Fixes trailer in ipv4_datagram_support_cmsg() commit
--
commit 700237f41e9bcbea5b22f49b39d9b8d4e38cf887
Author: Geliang Tang <[email protected]>
Quoted 14 lines
ipv4: fix uninitialized memory in zerocopy cmsg
When
SOF_TIMESTAMPING_OPT_CMSGis enabled and applications readMSG_ZEROCOPYcompletion notifications from the error queue, theipv4_datagram_support_cmsg()function attempts to read ip_hdr(skb)->saddr to populateIP_PKTINFOcmsg data. However, zerocopy completion notification skbs don't have IP headers, causing this read to access uninitialized memory which is then leaked to userspace viaput_cmsg().This is because the function checks PKTINFO_SKB_CB(skb)->ipi_ifindex (which aliases the ops pointer in
ubuf_info_msgzcstored inskb->cb), and if non-NULL, proceeds to read ip_hdr(skb)->saddr without verifying that the skb actually has an IP header.
Quoted 6 lines
Fix this by adding an early check for
SO_EE_ORIGIN_ZEROCOPYand returning false, since zerocopy completion notifications don't have IP headers andIP_PKTINFOcmsg is not applicable to them.Fixes 829ae9d61165 ("net-timestamp: allow reading recv cmsg on errqueue with origin tstamp")Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
Is this Fixes: tag accurate?
Commit 829ae9d61165 ("net-timestamp: allow reading recv cmsg on errqueue with origin tstamp") explicitly required ee_origin == SO_EE_ORIGIN_TIMESTAMPING and predated SO_EE_ORIGIN_ZEROCOPY, which was added later in commit 52267790ef52 ("sock: add MSG_ZEROCOPY").
net/ipv4/ip_sockglue.c static bool ipv4_datagram_support_cmsg(const struct sock *sk, · line 511
Quoted 13 lines
net/ipv4/ip_sockglue.c +5
-0@@ -504,6 +504,12 @@ static bool ipv4_datagram_support_cmsg(const struct sock *sk,if (ee_origin ==SO_EE_ORIGIN_LOCAL )return false; +/* Zerocopy completion notifications don't have IP headers, +* so IP_PKTINFO cmsg is not applicable. +*/ +if (ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return false;
[Severity: Medium]
Can ipv4_datagram_support_cmsg() actually reach ip_hdr(skb)->saddr for a SO_EE_ORIGIN_ZEROCOPY notification skb?
Before queueing a zerocopy completion notification onto sk_error_queue, __msg_zerocopy_callback() overwrites ubuf_info_msgzc in skb->cb (and note that struct ubuf_info has not had an ops pointer since commit ecca9bb2c855 ("net:
replace Callbacks inside ubuf_info with single function")):
net/core/skbuff.c:__msg_zerocopy_callback() {
...
serr = SKB_EXT_ERR(skb);
memset(serr, 0, sizeof(*serr));
serr->ee.ee_errno = 0;
serr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY;
...
}Because SKB_EXT_ERR(skb) and PKTINFO_SKB_CB(skb) both sit at the start of skb->cb, memset(serr, 0, sizeof(*serr)) zeroes PKTINFO_SKB_CB(skb)->ipi_ifindex (which aliases serr->header.h4.iif). The existing !info->ipi_ifindex check in ipv4_datagram_support_cmsg() therefore already returns false for every SO_EE_ORIGIN_ZEROCOPY skb before ip_hdr(skb)->saddr is read.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
[email protected]
AI reviewRe: [PATCH mptcp-next v8 1/7] ipv4: fix uninitialized memory in zerocopy cmsg
In reply to Geliang TangThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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 commit message describes an uninitialized-memory leak that cannot happen in the current tree.
- [Low] The commit metadata has an author/sign-off identity mismatch.
--
ipv4: fix uninitialized memory in zerocopy cmsg
This patch adds an early return to ipv4_datagram_support_cmsg() when ee_origin is SO_EE_ORIGIN_ZEROCOPY. The stated reason is that the IP_PKTINFO path reads ip_hdr(skb)->saddr on zerocopy completion skbs, which have no IP header, and so leaks uninitialized memory to userspace.
Quoted 2 lines
Fixes 829ae9d61165 ("net-timestamp: allow reading recv cmsg on errqueue with origin tstamp")Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
This isn't a bug, but the author address ([email protected]) doesn't match the Signed-off-by address ([email protected]). checkpatch reports this as FROM_SIGN_OFF_MISMATCH.
Could the sign-off use the author address, or the author be changed to match? The other patches in this series have the same mismatch.
Quoted 5 lines
net/ipv4/ip_sockglue.c +0
-0
net/ipv4/ip_sockglue.c static bool ipv4_datagram_support_cmsg(const struct sock *sk, · line 512
Quoted 9 lines
net/ipv4/ip_sockglue.c +6
-0@@ -504,6 +504,12 @@ static bool ipv4_datagram_support_cmsg(const struct sock *sk,if (ee_origin ==SO_EE_ORIGIN_LOCAL )return false; +/* Zerocopy completion notifications don't have IP headers, +* so IP_PKTINFO cmsg is not applicable. +*/ +if (ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return false; +
[Severity: Medium]
Before this patch, could ipv4_datagram_support_cmsg() ever reach ip_hdr(skb)->saddr for a zerocopy notification?
The commit message says ipi_ifindex "aliases the ops pointer in ubuf_info_msgzc stored in skb->cb" and is non-zero. But the only producer of SO_EE_ORIGIN_ZEROCOPY error queue skbs, __msg_zerocopy_callback() in net/core/skbuff.c, clears skb->cb before it queues the skb:
net/core/skbuff.c:__msg_zerocopy_callback() {
...
serr = SKB_EXT_ERR(skb);
memset(serr, 0, sizeof(*serr));
serr->ee.ee_errno = 0;
serr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY;
...
}It copies len, id and zerocopy out of uarg before the memset. So by the time the skb reaches sk_error_queue, the ubuf_info_msgzc contents, including ops, are gone.
struct sock_exterr_skb starts with header.h4, and struct inet_skb_parm starts with int iif. PKTINFO_SKB_CB(skb) is a cast of skb->cb, and ipi_ifindex is the first int of struct in_pktinfo. So it reads the same zeroed bytes at cb offset 0.
skb_zerocopy_notify_extend() only updates ee.ee_data. Neither sock_dequeue_err_skb() nor ip_recv_error() writes header before this call.
Given that, wouldn't the existing check already return false for every zerocopy notification?
info = PKTINFO_SKB_CB(skb); if (!(READ_ONCE(sk->sk_tsflags) & SOF_TIMESTAMPING_OPT_CMSG) || !info->ipi_ifindex) return false;
If so, the new check does not change runtime behavior. The "fix uninitialized memory" subject and the Fixes: tag, which would pull this into stable, don't seem to match the code.
Could the commit message describe this as a clarity or hardening change, and the Fixes: tag be dropped?
Also, if the premise were correct, wouldn't ip6_datagram_support_cmsg() in net/ipv6/datagram.c have the same problem? It is gated only on IP6CB(skb)->iif:
if (serr->ee.ee_origin == SO_EE_ORIGIN_LOCAL) return false; if (!IP6CB(skb)->iif) return false;
This patch does not change it.
Quoted 3 lines
net/ipv4/ip_sockglue.c +0
-0/* Support IP_PKTINFO on tstamp packets if requested, to correlate * timestamp with egress dev. Not possible for packets without iif * or without payload (SOF_TIMESTAMPING_OPT_TSONLY).
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Geliang Tang
reviewerPATCH v8 2/7 mptcp: use local variable tp in sendmsg_frag
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
In mptcp_sendmsg_frag(), tcp_sk(ssk) is called multiple times. Introduce a local variable 'tp' to hold the tcp_sock pointer and use it throughout the function. This avoids repeated dereferencing and improves code readability, with no functional change.
--- net/mptcp/protocol.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
net/mptcp/protocol.c +4 -3
@@ -1443,6 +1443,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,u64 data_seq = dfrag->data_seq + info->sent;int offset = dfrag->offset + info->sent;struct mptcp_sock *msk =mptcp_sk (sk); +struct tcp_sock *tp =tcp_sk (ssk);bool zero_window_probe = false;struct mptcp_ext *mpext =NULL ;bool can_coalesce = false;
@@ -1478,14 +1479,14 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, mpext =mptcp_get_ext (skb);if (!mptcp_skb_can_collapse_to (data_seq, skb, mpext)) {TCP_SKB_CB (skb)->eor =1 ; -tcp_mark_push (tcp_sk (ssk), skb); +tcp_mark_push (tp, skb); goto alloc_skb; } i =skb_shinfo (skb)->nr_frags; can_coalesce =skb_can_coalesce (skb, i, dfrag->page, offset);if (!can_coalesce && i >=READ_ONCE (net_hotdata.sysctl_max_skb_frags)) { -tcp_mark_push (tcp_sk (ssk), skb); +tcp_mark_push (tp, skb); goto alloc_skb; }
@@ -1539,7 +1540,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, skb->truesize += copy;sk_wmem_queued_add (ssk, copy);sk_mem_charge (ssk, copy); -WRITE_ONCE (tcp_sk (ssk)->write_seq,tcp_sk (ssk)->write_seq + copy); +WRITE_ONCE (tp->write_seq, tp->write_seq + copy);TCP_SKB_CB (skb)->end_seq += copy;tcp_skb_pcount_set (skb,0 );
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 2/7] mptcp: use local variable tp in sendmsg_frag
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message of "mptcp: use local variable tp in sendmsg_frag" gets the reason for the change wrong.
- [Low] The commit author address does not match any Signed-off-by address.
--
mptcp: use local variable tp in sendmsg_frag
This commit adds a local tcp_sock pointer tp to mptcp_sendmsg_frag() in net/mptcp/protocol.c. It replaces the repeated tcp_sk(ssk) calls in the tcp_mark_push() calls and the write_seq update.
Quoted 6 lines
mptcp: use local variable tp in
sendmsg_fragIn
mptcp_sendmsg_frag(),tcp_sk(ssk)is called multiple times. Introduce a local variable 'tp' to hold thetcp_sockpointer and use it throughout the function. This avoids repeated dereferencing and improves code readability, with no functional change.
[Severity: Low]
Is "avoids repeated dereferencing" accurate here? tcp_sk() does not read any memory. It only converts the pointer at compile time:
include/linux/tcp.h:
#define tcp_sk(ptr) container_of_const(ptr, struct tcp_sock, inet_conn.icsk_inet.sk)
inet_conn.icsk_inet.sk is the first member at every level of nesting, so the conversion is effectively a cast. The compiler should emit the same code with or without the new variable.
Could the commit message drop the dereferencing wording and keep only the readability reason? The "no functional change" part looks correct.
Quoted 2 lines
Suggested-by Paolo Abeni <[email protected]>Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
The author address and the sign-off address are different. The author is Geliang Tang <[email protected]>, but the only Signed-off-by uses [email protected].
checkpatch.pl reports this as FROM_SIGN_OFF_MISMATCH. The other patches in the series have the same mismatch.
The mismatch may have come from an in-body From: line being dropped when the patch was applied. Could the series be resent with a matching author address, or with an in-body "From: Geliang Tang <[email protected]>" line?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Geliang Tang
reviewerPATCH v8 3/7 mptcp: remove redundant orig_offset in carve_data_frag
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
mptcp_carve_data_frag() already receives struct page_frag via its 'pfrag' parameter, making the separate 'orig_offset' parameter redundant since it merely duplicates pfrag->offset.
Simplify the function signature by removing this unnecessary parameter and directly accessing the offset from struct pfrag internally.
--- net/mptcp/protocol.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/mptcp/protocol.c +3 -3
@@ -1302,9 +1302,9 @@ static bool mptcp_page_frag_refill(struct sock *sk, struct page_frag *pfrag) }static struct mptcp_data_frag * -mptcp_carve_data_frag (const struct mptcp_sock *msk,struct page_frag *pfrag, -int orig_offset) +mptcp_carve_data_frag (const struct mptcp_sock *msk,struct page_frag *pfrag) { +int orig_offset = pfrag->offset;int offset =ALIGN (orig_offset,sizeof (long ));struct mptcp_data_frag *dfrag;
@@ -2103,7 +2103,7 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (!mptcp_page_frag_refill (sk, pfrag)) goto wait_for_memory; - dfrag =mptcp_carve_data_frag (msk, pfrag, pfrag->offset); + dfrag =mptcp_carve_data_frag (msk, pfrag); frag_truesize = dfrag->overhead; }
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 3/7] mptcp: remove redundant orig_offset in carve_data_frag
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you…
Thank you for your contribution! Sashiko AI review found more severe issue(s) in other patches of this series. This mail is only an FYI, in case you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The author address does not match the sign-off address.
--
mptcp: remove redundant orig_offset in carve_data_frag
This commit removes the orig_offset parameter from mptcp_carve_data_frag() in net/mptcp/protocol.c. The function now reads pfrag->offset itself, and the single caller in mptcp_sendmsg() is updated to match.
Quoted 1 line
Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
This isn't a bug, but the author and sign-off addresses don't match. The commit author is:
Author: Geliang Tang <[email protected]>
The only trailer is:
None of the Signed-off-by lines use the author address. checkpatch.pl reports this as "From:/Signed-off-by: email address mismatch".
The other patches in the series (5677cf0e039b..c0158d2e0084) have the same mismatch, so no later patch in the series fixes it.
Could a Signed-off-by be added for [email protected]? Alternatively, the author could be set to the address that signed off.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Geliang Tang
reviewerPATCH v8 4/7 mptcp: add MSG_ZEROCOPY support
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
This patch enables MSG_ZEROCOPY support for MPTCP sockets, allowing user-space to transmit data without intermediate kernel copies.
The implementation follows the same lifecycle model as TCP:
A single ubuf_info_msgzc is allocated per sendmsg via msg_zerocopy_realloc(). Its reference count consists of three parts:
one 'caller' reference held until sendmsg returns, one reference per MPTCP dfrag in the retransmission queue (released when the dfrag is acked and cleared), and one reference per subflow skb that consumes dfrag bytes (released by TCP's skb_zcopy_clear() when the skb is acked). Completion is reported only after all bytes are acknowledged at both MPTCP and subflow levels.
User pages are pinned via iov_iter_get_pages2() and stored directly in a newly allocated mptcp_data_frag. The dfrag takes one reference on the ubuf_info and one on the page. Subflow skbs take additional page references via get_page() and are marked with skb_zcopy_set() and SKBFL_PURE_ZEROCOPY, mirroring TCP's behavior and bypassing kernel memory accounting for those pages.
The feature is silently downgraded to regular copy when MSG_FASTOPEN is set or the application has not opted in via setsockopt(SO_ZEROCOPY). If msg_zerocopy_realloc() fails (e.g. RLIMIT_MEMLOCK pressure), sendmsg(2) aborts with -ENOBUFS.
The implementation prevents coalescing of dfrags with different ubuf instances into the same subflow skb to avoid premature completion
notifications: a coalescing break is taken when the skb's pure-zerocopy state differs from the incoming dfrag, and another when both dfrags have ubuf instances but they differ. The new mptcp_sendmsg_zerocopy_iter() helper caps pg_len to U16_MAX (reverting the excess from the iov_iter when iov_iter_get_pages2() returns more than that) and returns -EFAULT when pg_off exceeds U16_MAX (which can happen on 256KB-page kernels like PowerPC and Hexagon), so the u16 dfrag->data_len and dfrag->offset fields cannot wrap. The caller accumulates the per-iteration byte count via the ssize_t return value. The non-zerocopy path is left untouched.
When iov_iter_get_pages2() returns 0, the function returns -EFAULT to properly signal iterator exhaustion.
--- net/mptcp/protocol.c | 152 +++++++++++++++++++++++++++++++++++++++++-- net/mptcp/protocol.h | 1 + 2 files changed, 146 insertions(+), 7 deletions(-)
net/mptcp/protocol.c +145 -7
@@ -1186,9 +1186,11 @@ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk, df->data_seq + df->data_len == msk->write_seq; } -static void dfrag_uncharge (struct sock *sk,int len) +static void dfrag_uncharge (struct sock *sk,int len, +struct mptcp_data_frag *dfrag) { -sk_mem_uncharge (sk, len); +if (!dfrag->ubuf) +sk_mem_uncharge (sk, len);sk_wmem_queued_add (sk, -len); }
@@ -1197,7 +1199,13 @@ static void dfrag_clear(struct sock *sk, struct mptcp_data_frag *dfrag)int len = dfrag->data_len + dfrag->overhead;list_del (&dfrag->list); -dfrag_uncharge (sk, len); +dfrag_uncharge (sk, len, dfrag); +if (dfrag->ubuf) { +net_zcopy_put (dfrag->ubuf); +put_page (dfrag->page); +kfree (dfrag); +return ; + }put_page (dfrag->page); }
@@ -1242,7 +1250,7 @@ static void __mptcp_clean_una(struct sock *sk) dfrag->data_len -= delta; dfrag->already_sent -= delta; -dfrag_uncharge (sk, delta); +dfrag_uncharge (sk, delta, dfrag); }/* all retransmitted data acked, recovery completed */
@@ -1316,6 +1324,7 @@ mptcp_carve_data_frag(const struct mptcp_sock *msk, struct page_frag *pfrag) dfrag->already_sent =0 ; dfrag->page = pfrag->page; dfrag->eor =0 ; + dfrag->ubuf =NULL ;return dfrag; }
@@ -1483,6 +1492,16 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, goto alloc_skb; } +if (skb_zcopy_pure (skb) != !!dfrag->ubuf) { +tcp_mark_push (tp, skb); + goto alloc_skb; + } +if (dfrag->ubuf &&skb_zcopy (skb) && +skb_zcopy (skb) != dfrag->ubuf) { +tcp_mark_push (tp, skb); + goto alloc_skb; + } + i =skb_shinfo (skb)->nr_frags; can_coalesce =skb_can_coalesce (skb, i, dfrag->page, offset);if (!can_coalesce && i >=READ_ONCE (net_hotdata.sysctl_max_skb_frags)) {
@@ -1523,7 +1542,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, } copy =min_t (size_t, copy, info->limit - info->sent); -if (!sk_wmem_schedule (ssk, copy)) { +if (!dfrag->ubuf && !sk_wmem_schedule (ssk, copy)) {tcp_remove_empty_skb (ssk);return -ENOMEM ; }
@@ -1533,13 +1552,19 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk, }else {get_page (dfrag->page);skb_fill_page_desc (skb, i, dfrag->page, offset, copy); + +if (dfrag->ubuf && !skb_zcopy (skb)) { +skb_zcopy_set (skb, dfrag->ubuf,NULL ); +skb_shinfo (skb)->flags |=SKBFL_PURE_ZEROCOPY ; + } } skb->len += copy; skb->data_len += copy; skb->truesize += copy;sk_wmem_queued_add (ssk, copy); -sk_mem_charge (ssk, copy); +if (!skb_zcopy_pure (skb)) +sk_mem_charge (ssk, copy);WRITE_ONCE (tp->write_seq, tp->write_seq + copy);TCP_SKB_CB (skb)->end_seq += copy;tcp_skb_pcount_set (skb,0 );
@@ -2040,22 +2065,110 @@ static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) } } +static ssize_t mptcp_sendmsg_zerocopy_iter (struct sock *sk,struct msghdr *msg, +struct ubuf_info *ubuf, +u32 copy_limit) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_data_frag *dfrag; +struct page *pages[1 ] = {}; +size_t pg_off =0 ; +ssize_t pg_len; + + pg_len =iov_iter_get_pages2 (&msg->msg_iter, pages, + copy_limit,1 , &pg_off); +if (pg_len <0 ) +return pg_len; +/* pg_len == 0 means the iterator is exhausted */ +if (pg_len ==0 ) +return -EFAULT ; + +if (pg_len >U16_MAX ) { +iov_iter_revert (&msg->msg_iter, pg_len -U16_MAX ); + pg_len =U16_MAX ; + } + +if (pg_off >U16_MAX ) { +iov_iter_revert (&msg->msg_iter, pg_len); +put_page (pages[0 ]); +return -EFAULT ; + } + +if (pg_off + pg_len >U16_MAX ) { +size_t len =U16_MAX - pg_off; + +iov_iter_revert (&msg->msg_iter, pg_len - len); + pg_len = len; +if (WARN_ON_ONCE (!pg_len)) { +put_page (pages[0 ]); +return -EFAULT ; + } + } + + dfrag =kzalloc_obj (*dfrag,GFP_KERNEL_ACCOUNT ); +if (!dfrag) { +iov_iter_revert (&msg->msg_iter, pg_len); +put_page (pages[0 ]); +return -ENOMEM ; + } + +if (!sk_wmem_schedule (sk, pg_len +sizeof (*dfrag))) { +kfree (dfrag); +iov_iter_revert (&msg->msg_iter, pg_len); +put_page (pages[0 ]); +return -EAGAIN ; + } + + dfrag->data_len = pg_len; + dfrag->data_seq = msk->write_seq; + dfrag->offset = pg_off; + dfrag->page = pages[0 ]; + dfrag->ubuf = ubuf; + dfrag->overhead =sizeof (struct mptcp_data_frag ); + +/* one ref for the dfrag; released in dfrag_clear */ +net_zcopy_get (ubuf); + +WRITE_ONCE (msk->write_seq, msk->write_seq + pg_len); +sk_wmem_queued_add (sk, pg_len + dfrag->overhead); + +list_add_tail (&dfrag->list, &msk->rtx_queue); +if (!msk->first_pending) + msk->first_pending = dfrag; + +return pg_len; +} +static int mptcp_sendmsg (struct sock *sk,struct msghdr *msg,size_t len) {struct mptcp_sock *msk =mptcp_sk (sk); +struct ubuf_info *ubuf =NULL ;struct page_frag *pfrag;size_t copied =0 ; +bool zc = false;int ret =0 ;long timeo;/* silently ignore everything else */ msg->msg_flags &=MSG_MORE |MSG_DONTWAIT |MSG_NOSIGNAL | -MSG_FASTOPEN |MSG_EOR ; +MSG_FASTOPEN |MSG_EOR |MSG_ZEROCOPY ;lock_sock (sk);mptcp_rps_record_subflows (msk); +if (msg->msg_flags &MSG_FASTOPEN || !sock_flag (sk,SOCK_ZEROCOPY )) + msg->msg_flags &= ~MSG_ZEROCOPY ; + +if ((msg->msg_flags &MSG_ZEROCOPY ) && len) { + ubuf =msg_zerocopy_realloc (sk, len,NULL , false); +if (!ubuf) { + ret = -ENOBUFS ; + goto do_error; + } + zc = true; + } +if (unlikely (inet_test_bit (DEFER_CONNECT , sk) || msg->msg_flags &MSG_FASTOPEN )) {int copied_syn =0 ;
@@ -2094,6 +2207,25 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (!copy_limit) goto wait_for_memory; +if (zc) { + ret =mptcp_sendmsg_zerocopy_iter (sk, msg, ubuf, + copy_limit); +if (ret == -EAGAIN || ret == -ENOMEM ) + goto wait_for_memory; +if (ret == -EFAULT ) { +if (copied) + goto do_error; +net_zcopy_put_abort (ubuf, true); + zc = false; + ubuf =NULL ; + }else if (ret <0 ) { + goto do_error; + }else { + copied += ret; +continue ; + } + } +/* reuse tail pfrag, if possible, or carve a new one from the * page allocator */
@@ -2169,6 +2301,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } out: +if (zc) +net_zcopy_put (ubuf);release_sock (sk);return copied;
@@ -2179,6 +2313,10 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) } copied =sk_stream_error (sk, msg->msg_flags, ret); +if (zc) { +net_zcopy_put_abort (ubuf, true); + zc = false; + } goto out; }
net/mptcp/protocol.h +1 -0
@@ -285,6 +285,7 @@ struct mptcp_data_frag {u8 eor;/* currently using 1 bit */ u16 already_sent;struct page *page; +struct ubuf_info *ubuf; };/* Arbitrary compromise between as low as possible to react timely to subflow
Signature · 1 line
2.55.0
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [High] mptcp: off-by-one U16_MAX check in mptcp_sendmsg_zerocopy_iter() - [Medium] mptcp: unbalanced…
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [High] mptcp: off-by-one U16_MAX check in mptcp_sendmsg_zerocopy_iter()
- [Medium] mptcp: unbalanced sk_wmem_schedule() in mptcp_sendmsg_zerocopy_iter()
- [Medium] mptcp: missing DEFER_CONNECT check for MSG_ZEROCOPY in mptcp_sendmsg()
- [Medium] mptcp: missing zerocopy notification on copy fallback in mptcp_sendmsg()
--
commit 6f18d9c0894cba580b4859b23fbe02de7c4fe368
Author: Geliang Tang <[email protected]>
mptcp: add MSG_ZEROCOPY support
This commit adds MSG_ZEROCOPY support to MPTCP sockets by pinning user pages into mptcp_data_frag entries and tracking completion across both the MPTCP retransmission queue and subflow skbs.
Quoted 17 lines
net/mptcp/protocol.c +4
-2@@ -1186,9 +1186,11 @@ static bool mptcp_frag_can_collapse_to(const struct mptcp_sock *msk, df->data_seq + df->data_len == msk->write_seq; } -static void dfrag_uncharge (struct sock *sk,int len) +static void dfrag_uncharge (struct sock *sk,int len, +struct mptcp_data_frag *dfrag) { -sk_mem_uncharge (sk, len); +if (!dfrag->ubuf) +sk_mem_uncharge (sk, len);sk_wmem_queued_add (sk, -len); }
[ ... ]
Quoted 33 lines
net/mptcp/protocol.c +29
-0@@ -2040,22 +2065,110 @@ static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) } } +static ssize_t mptcp_sendmsg_zerocopy_iter (struct sock *sk,struct msghdr *msg, +struct ubuf_info *ubuf, +u32 copy_limit) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_data_frag *dfrag; +struct page *pages[1 ] = {}; +size_t pg_off =0 ; +ssize_t pg_len; + + pg_len =iov_iter_get_pages2 (&msg->msg_iter, pages, + copy_limit,1 , &pg_off); +if (pg_len <0 ) +return pg_len; +/* pg_len == 0 means the iterator is exhausted */ +if (pg_len ==0 ) +return -EFAULT ; + +if (pg_len >U16_MAX ) { +iov_iter_revert (&msg->msg_iter, pg_len -U16_MAX ); + pg_len =U16_MAX ; + } + +if (pg_off >U16_MAX ) { +iov_iter_revert (&msg->msg_iter, pg_len); +put_page (pages[0 ]); +return -EFAULT ; + } +
net/mptcp/protocol.c static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) · line 2106
Quoted 10 lines
net/mptcp/protocol.c +10
-0+if (pg_off + pg_len >U16_MAX ) { +size_t len =U16_MAX - pg_off; + +iov_iter_revert (&msg->msg_iter, pg_len - len); + pg_len = len; +if (WARN_ON_ONCE (!pg_len)) { +put_page (pages[0 ]); +return -EFAULT ; + } + }
[Severity: High]
Does pg_off + pg_len > U16_MAX trigger WARN_ON_ONCE(!pg_len) and return -EFAULT whenever pg_off reaches U16_MAX on a kernel with PAGE_SIZE >= 64 KiB?
On a 64 KiB page kernel, sending a 64 KiB page-aligned buffer caps the first dfrag at U16_MAX (65535) bytes and leaves msg->msg_iter at page offset 65535 with 1 byte left. On the next iteration, pg_off is U16_MAX, so pg_off > U16_MAX is false and len = U16_MAX - pg_off is 0.
Since dfrag->offset and dfrag->data_len are u16 and partial-ACK advancement in __mptcp_clean_una() only adds delta < dfrag->data_len, capping pg_off + pg_len at U16_MAX + 1 avoids overflowing either field while allowing the final byte at offset 65535.
Quoted 4 lines
net/mptcp/protocol.c +4
-0+ + dfrag =kzalloc_obj (*dfrag,GFP_KERNEL_ACCOUNT ); +if (!dfrag) { +iov_iter_revert (&msg->msg_iter, pg_len);
net/mptcp/protocol.c static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) · line 2120
Quoted 10 lines
net/mptcp/protocol.c +10
-0+put_page (pages[0 ]); +return -ENOMEM ; + } + +if (!sk_wmem_schedule (sk, pg_len +sizeof (*dfrag))) { +kfree (dfrag); +iov_iter_revert (&msg->msg_iter, pg_len); +put_page (pages[0 ]); +return -EAGAIN ; + }
[Severity: Medium]
Should mptcp_sendmsg_zerocopy_iter() skip sk_wmem_schedule() here, the same way mptcp_sendmsg_frag() skips it for zerocopy dfrags?
Calling sk_wmem_schedule(sk, pg_len + sizeof(*dfrag)) raises sk->sk_forward_alloc and charges protocol memory, but this path never deducts it with sk_mem_charge() or sk_forward_alloc_add(), and dfrag_uncharge() skips sk_mem_uncharge() when dfrag->ubuf is set. The forward-allocated pages stay pinned on sk until the socket closes, and zerocopy sends can fail with -EAGAIN under socket memory pressure even though zerocopy pages bypass socket memory accounting.
[ ... ]
Quoted 15 lines
net/mptcp/protocol.c +5
-1@@ -2062,15 +2175,27 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)/* silently ignore everything else */ msg->msg_flags &=MSG_MORE |MSG_DONTWAIT |MSG_NOSIGNAL | -MSG_FASTOPEN |MSG_EOR ; +MSG_FASTOPEN |MSG_EOR |MSG_ZEROCOPY ;lock_sock (sk);mptcp_rps_record_subflows (msk); +if (msg->msg_flags &MSG_FASTOPEN || !sock_flag (sk,SOCK_ZEROCOPY )) + msg->msg_flags &= ~MSG_ZEROCOPY ; + +if ((msg->msg_flags &MSG_ZEROCOPY ) && len) {
net/mptcp/protocol.c static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · line 2197
Quoted 10 lines
net/mptcp/protocol.c +8
-0+ ubuf =msg_zerocopy_realloc (sk, len,NULL , false); +if (!ubuf) { + ret = -ENOBUFS ; + goto do_error; + } + zc = true; + } +if (unlikely (inet_test_bit (DEFER_CONNECT , sk) || msg->msg_flags &MSG_FASTOPEN )) {
[Severity: Medium]
Does the MSG_ZEROCOPY downgrade check also need to test inet_test_bit(DEFER_CONNECT, sk)?
When TCP_FASTOPEN_CONNECT sets DEFER_CONNECT and sendmsg() is called with MSG_ZEROCOPY (without MSG_FASTOPEN), mptcp_sendmsg() allocates ubuf and then enters mptcp_sendmsg_fastopen(), which passes NULL for uarg to tcp_sendmsg_fastopen():
net/mptcp/protocol.c:mptcp_sendmsg_fastopen() {
...
ret = tcp_sendmsg_fastopen(ssk, msg, copied_syn, len, NULL);
...
}The SYN payload is copied without taking a reference on ubuf or clearing ubuf->zerocopy, so when mptcp_sendmsg() jumps to out: and calls net_zcopy_put(ubuf), it immediately queues a zerocopy completion notification while the SYN data is still in flight.
[ ... ]
Quoted 5 lines
net/mptcp/protocol.c +1
-0@@ -2094,6 +2207,25 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (!copy_limit) goto wait_for_memory; +if (zc) {
net/mptcp/protocol.c static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · line 2220
Quoted 10 lines
net/mptcp/protocol.c +10
-0+ ret =mptcp_sendmsg_zerocopy_iter (sk, msg, ubuf, + copy_limit); +if (ret == -EAGAIN || ret == -ENOMEM ) + goto wait_for_memory; +if (ret == -EFAULT ) { +if (copied) + goto do_error; +net_zcopy_put_abort (ubuf, true); + zc = false; + ubuf =NULL ;
[Severity: Medium]
Does calling net_zcopy_put_abort() before falling back to the regular copy path suppress the required MSG_ZEROCOPY completion notification when the copy succeeds?
net_zcopy_put_abort() decrements sk->sk_zckey and zeroes uarg->len, so when the loop falls through to do_copy_data_nocache() and returns a positive byte count, no SO_EE_ORIGIN_ZEROCOPY notification (with SO_EE_CODE_ZEROCOPY_COPIED) is queued on sk->sk_error_queue. Applications waiting for a completion per successful MSG_ZEROCOPY sendmsg() call will lose track of sk_zckey or hang on MSG_ERRQUEUE.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=4
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider.
Critical: 0 · High: 1 · Medium: 5 · 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).
- [High] On 64K-page kernels (arm64 with 64K pages, ppc64le by default), mptcp_sendmsg_zerocopy_iter() in net/mptcp/protocol.c has an off-by-…
- [Medium] mptcp_poll() never reports EPOLLERR for a non-empty sk_error_queue, but MSG_ZEROCOPY completions for MPTCP are queued on…
- [Medium] A MSG_ZEROCOPY sendmsg() can return success without being assigned a notification ID.
- [Medium] mptcp_sendmsg_zerocopy_iter() leaks a page reference when iov_iter_get_pages2() returns 0.
- [Medium] mptcp: missing DEFER_CONNECT check for MSG_ZEROCOPY in mptcp_sendmsg()
- [Medium] mptcp: unbalanced sk_wmem_schedule() in mptcp_sendmsg_zerocopy_iter()
- [Low] Documentation/networking/msg_zerocopy.rst still says 'The feature is currently implemented for TCP, UDP and VSOCK (with virtio…
- [Low] The commit author is 'Geliang Tang <[email protected]>' but the only Signed-off-by is 'Geliang Tang <[email protected]>'.
--
mptcp: add MSG_ZEROCOPY support
This commit adds MSG_ZEROCOPY support to MPTCP sockets. It pins user pages with iov_iter_get_pages2() and stores them in a separately allocated mptcp_data_frag that holds a reference on the ubuf_info. Subflow skbs are marked with skb_zcopy_set() and SKBFL_PURE_ZEROCOPY, the same way TCP does it.
Quoted 1 line
Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
The Author is Geliang Tang <[email protected]>, but the only sign-off uses a different address. checkpatch.pl reports a From:/Signed-off-by: email address mismatch for this.
Could the author and sign-off addresses be made to match, or could an explicit matching From: line be added?
Quoted 4 lines
net/mptcp/protocol.c +0
-0
[ ... ]
Quoted 11 lines
net/mptcp/protocol.c +7
-0@@ -1998,22 +2023,110 @@ static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) } } +static ssize_t mptcp_sendmsg_zerocopy_iter (struct sock *sk,struct msghdr *msg, +struct ubuf_info *ubuf, +u32 copy_limit) +{ +struct mptcp_sock *msk =mptcp_sk (sk); +struct mptcp_data_frag *dfrag; +struct page *pages[1 ] = {};
net/mptcp/protocol.c static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) · line 2042
Quoted 10 lines
net/mptcp/protocol.c +10
-0+size_t pg_off =0 ; +ssize_t pg_len; + + pg_len =iov_iter_get_pages2 (&msg->msg_iter, pages, + copy_limit,1 , &pg_off); +if (pg_len <0 ) +return pg_len; +/* pg_len == 0 means the iterator is exhausted */ +if (pg_len ==0 ) +return -EFAULT ;
[Severity: Medium]
Can this leak a page reference? Every other error exit in this helper calls put_page(pages[0]), but this one does not.
For ITER_BVEC iterators, __iov_iter_get_pages_alloc() can take a reference and still return 0. Take a current bvec segment with zero length and a bv_offset that is not page aligned:
first_bvec_segment() caps maxsize to 0 want_pages_array() still returns n = 1, because *start != 0 folio_get() is called on the page stored in pages[0] maxsize = min(0, ...) = 0 is returned
It isn't clear whether any real in-kernel caller builds such an iterator. Even so, would something like this be safer?
if (pg_len == 0) {
if (pages[0])
put_page(pages[0]);
return -EFAULT;
}Quoted 12 lines
net/mptcp/protocol.c +12
-0+ +if (pg_len >U16_MAX ) { +iov_iter_revert (&msg->msg_iter, pg_len -U16_MAX ); + pg_len =U16_MAX ; + } + +if (pg_off >U16_MAX ) { +iov_iter_revert (&msg->msg_iter, pg_len); +put_page (pages[0 ]); +return -EFAULT ; + } +
net/mptcp/protocol.c static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) · line 2106
Quoted 10 lines
net/mptcp/protocol.c +10
-0+if (pg_off + pg_len >U16_MAX ) { +size_t len =U16_MAX - pg_off; + +iov_iter_revert (&msg->msg_iter, pg_len - len); + pg_len = len; +if (WARN_ON_ONCE (!pg_len)) { +put_page (pages[0 ]); +return -EFAULT ; + } + }
[Severity: Medium]
Is this sk_wmem_schedule() balanced anywhere?
When sk->sk_forward_alloc is smaller than pg_len + sizeof(*dfrag), __sk_mem_schedule() grows sk_forward_alloc in page units. It also charges tcp_memory_allocated and the socket memcg. The copy path in mptcp_sendmsg() consumes that with sk_forward_alloc_add(sk, -total_ts), but nothing here calls sk_mem_charge(). On the release side, dfrag_uncharge() now skips sk_mem_uncharge() for zerocopy dfrags, so sk_mem_reclaim() is not reached from that path either.
Take a socket that only does MSG_ZEROCOPY sends. The forward allocation from the first schedule can be up to roughly 17 pages on 4K page kernels, since pg_len can be close to 64K. It stays charged to the protocol and to the memcg until another path reclaims it or the socket is closed.
This also makes zerocopy sends subject to the protocol memory limits. Under tcp memory pressure __sk_mem_schedule() can fail. The -EAGAIN return then sends mptcp_sendmsg() into wait_for_memory, even though no socket memory is actually charged for this data.
The commit message says these pages bypass kernel memory accounting. tcp_sendmsg_locked() likewise skips tcp_wmem_schedule() for pure zerocopy skbs.
Should this call be dropped, to match TCP and the dfrag_uncharge() change? Or should the dfrag be charged with sk_mem_charge() here and uncharged normally in dfrag_uncharge()?
[Severity: High]
On 64K page kernels, can userspace trigger this WARN_ON_ONCE()?
With maxpages == 1, iov_iter_get_pages2() gives pg_off + pg_len <= PAGE_SIZE, which is 65536 here. For a page-aligned buffer, the first pass gets pg_off = 0 and pg_len = 65536. The pg_len > U16_MAX check caps that to 65535 and reverts one byte.
The next pass then gets pg_off = 65535 and pg_len = 1. The pg_off > U16_MAX check is false, but pg_off + pg_len > U16_MAX is true, so:
len = U16_MAX - pg_off; /* 0 */
pg_len = len;
if (WARN_ON_ONCE(!pg_len)) {The warning fires and -EFAULT is returned. The same thing happens for any chunk that ends exactly at the end of a 64K page, because that chunk gets trimmed by one byte.
In mptcp_sendmsg() this becomes a short write when copied > 0. When the remainder is retried (copied == 0), the zerocopy request is aborted and the data is copied instead. With panic_on_warn, an unprivileged user with SO_ZEROCOPY set can crash the system this way.
Is the stricter bound needed? In __mptcp_clean_una(), dfrag->offset only grows by delta < data_len, so pg_off + pg_len == 65536 seems to still fit both u16 fields. Would checking against U16_MAX + 1 be enough here?
[ ... ]
Quoted 4 lines
net/mptcp/protocol.c +1
-0static int mptcp_sendmsg (struct sock *sk,struct msghdr *msg,size_t len) {struct mptcp_sock *msk =mptcp_sk (sk); +struct ubuf_info *ubuf =NULL ;
net/mptcp/protocol.c static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) · line 2154
Quoted 10 lines
net/mptcp/protocol.c +2
-1struct page_frag *pfrag;size_t copied =0 ; +bool zc = false;int ret =0 ;long timeo;/* silently ignore everything else */ msg->msg_flags &=MSG_MORE |MSG_DONTWAIT |MSG_NOSIGNAL | -MSG_FASTOPEN |MSG_EOR ; +MSG_FASTOPEN |MSG_EOR |MSG_ZEROCOPY ;
[Severity: Low]
This isn't a bug, but Documentation/networking/msg_zerocopy.rst still says:
The feature is currently implemented for TCP, UDP and VSOCK (with virtio transport) sockets.
Should MPTCP be added there, along with any MPTCP-specific behaviour? Documentation/networking/ is not changed anywhere in the series.
net/mptcp/protocol.c static void mptcp_rps_record_subflows(const struct mptcp_sock *msk) · line 2164
Quoted 10 lines
net/mptcp/protocol.c +5
-0lock_sock (sk);mptcp_rps_record_subflows (msk); +if (msg->msg_flags &MSG_FASTOPEN || !sock_flag (sk,SOCK_ZEROCOPY )) + msg->msg_flags &= ~MSG_ZEROCOPY ; + +if ((msg->msg_flags &MSG_ZEROCOPY ) && len) { + ubuf =msg_zerocopy_realloc (sk, len,NULL , false);
[Severity: Medium]
Does MSG_ZEROCOPY also need to be dropped when DEFER_CONNECT is set?
The downgrade here only tests MSG_FASTOPEN. The fastopen branch just below is also entered when inet_test_bit(DEFER_CONNECT, sk) is set. After setsockopt(TCP_FASTOPEN_CONNECT) and connect(), a plain sendmsg(MSG_ZEROCOPY) therefore allocates ubuf with zc = true and then goes through mptcp_sendmsg_fastopen().
mptcp_sendmsg_fastopen() passes a NULL uarg to tcp_sendmsg_fastopen(). The bytes placed in the SYN are copied, but the ubuf is never attached to the SYN skb and uarg->zerocopy is never cleared. When that call returns -EINPROGRESS with copied_syn > 0, we jump to out: and net_zcopy_put(ubuf) drops the last reference. The completion is then queued immediately, while the SYN data is still unacknowledged. It is also reported without SO_EE_CODE_ZEROCOPY_COPIED, even though every byte was copied.
The user buffer was copied, so reusing it is not unsafe. Still, the application gets a wrong report for this send. This also doesn't match the commit message, which says zerocopy is downgraded for fastopen.
TCP hands its uarg to tcp_sendmsg_fastopen() for this case. Would it be simpler to add the DEFER_CONNECT test to the downgrade condition, or should the ubuf be passed through the MPTCP fastopen path the same way TCP does it?
[Severity: Medium]
Zerocopy completions are now queued on the msk sk_error_queue. Does mptcp_poll() need to report EPOLLERR when that queue is not empty?
msg_zerocopy_alloc() allocates the notification skb with sock_omalloc() on the msk. __msg_zerocopy_callback() queues it on sk->sk_error_queue and calls sk_error_report().
mptcp_poll() only checks sk_err:
net/mptcp/protocol.c:mptcp_poll() {
...
if (READ_ONCE(sk->sk_err))
mask |= EPOLLERR;
...
}tcp_poll() also checks the error queue:
net/ipv4/tcp.c:tcp_poll() {
...
if (READ_ONCE(sk->sk_err) ||
!skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR;
...
}Documentation/networking/msg_zerocopy.rst says poll() blocks until a notification is outstanding and then sets POLLERR. Its example uses poll(&pfd, 1, -1) with events = 0.
On an MPTCP socket the completion does wake the waiter. The recomputed mask has no EPOLLERR, though, so the waiter goes back to sleep.
The comment in mptcp_recvmsg() also looks stale now:
/* MSG_ERRQUEUE is really a no-op till we support IP_RECVERR */
The selftest in this series polls with a 200ms timeout and drains the queue again, which hides this.
Quoted 7 lines
net/mptcp/protocol.c +7
-0+if (!ubuf) { + ret = -ENOBUFS ; + goto do_error; + } + zc = true; + } +
[ ... ]
Quoted 5 lines
net/mptcp/protocol.c +1
-0@@ -2052,6 +2165,25 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)if (!copy_limit) goto wait_for_memory; +if (zc) {
net/mptcp/protocol.c static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len) · line 2178
Quoted 10 lines
net/mptcp/protocol.c +10
-0+ ret =mptcp_sendmsg_zerocopy_iter (sk, msg, ubuf, + copy_limit); +if (ret == -EAGAIN || ret == -ENOMEM ) + goto wait_for_memory; +if (ret == -EFAULT ) { +if (copied) + goto do_error; +net_zcopy_put_abort (ubuf, true); + zc = false; + ubuf =NULL ;
[Severity: Medium]
Can a MSG_ZEROCOPY sendmsg() return success here without being given a notification ID?
When mptcp_sendmsg_zerocopy_iter() returns -EFAULT with copied == 0, net_zcopy_put_abort() ends up in msg_zerocopy_put_abort():
atomic_dec(&sk->sk_zckey);
uarg_to_msgzc(uarg)->len--;As a result, __msg_zerocopy_callback() frees the uarg later without queueing a notification. The loop then carries on through the copy path. If the copy succeeds, sendmsg() returns a positive byte count with no ID and no completion.
Documentation/networking/msg_zerocopy.rst says "Each send call with MSG_ZEROCOPY that successfully sends data increments the counter."
TCP only aborts the uarg on its out_err path, where nothing was sent. When it falls back to copying on a successful send, it keeps the uarg and reports SO_EE_CODE_ZEROCOPY_COPIED.
This path can be reached on 64K page kernels on every retry after the short write described above (pg_off == 65535). On 256K page kernels it can be reached through the pg_off > U16_MAX case. Applications that count successful sends and wait for the matching completion IDs would wait forever.
The commit message describes this -EFAULT only as signalling iterator exhaustion:
When iov_iter_get_pages2() returns 0, the function returns -EFAULT to properly signal iterator exhaustion.
It doesn't mention the silent downgrade to copy. Should this path keep the uarg and clear uarg->zerocopy, the way TCP does?
Quoted 8 lines
net/mptcp/protocol.c +8
-0+ }else if (ret <0 ) { + goto do_error; + }else { + copied += ret; +continue ; + } + } +
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Geliang Tang
reviewerPATCH v8 5/7 mptcp: handle SO_ZEROCOPY in setsockopt
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
SO_ZEROCOPY is currently rejected by MPTCP setsockopt with -EOPNOTSUPP, even though the matching MSG_ZEROCOPY path in mptcp_sendmsg() is wired up. As a result MSG_ZEROCOPY silently falls back to a copy on MPTCP sockets because the opt-in flag is never set.
Expose SO_ZEROCOPY through the SOL_SOCKET setsockopt dispatcher. The new mptcp_setsockopt_sol_socket_zerocopy() helper validates that val is 0 or 1 (matching standard TCP sk_setsockopt) and flips SOCK_ZEROCOPY on the msk only. mptcp_sendmsg() consults the same flag directly, so opt-in is honoured on every data path without any cross-socket propagation.
--- net/mptcp/sockopt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
net/mptcp/sockopt.c +16 -1
@@ -184,6 +184,19 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnamreturn 0 ; } +static int mptcp_setsockopt_sol_socket_zerocopy (struct mptcp_sock *msk,int val) +{ +struct sock *sk = (struct sock *)msk; + +if (val !=0 && val !=1 ) +return -EINVAL ; + +lock_sock (sk); +sock_valbool_flag (sk,SOCK_ZEROCOPY , val); +release_sock (sk); +return 0 ; +} +static int mptcp_setsockopt_sol_socket_int (struct mptcp_sock *msk,int optname,sockptr_t optval,unsigned int optlen)
@@ -212,6 +225,8 @@ static int mptcp_setsockopt_sol_socket_int(struct mptcp_sock *msk, int optname,case SO_TIMESTAMPNS_OLD :case SO_TIMESTAMPNS_NEW :return mptcp_setsockopt_sol_socket_tstamp (msk, optname, val); +case SO_ZEROCOPY : +return mptcp_setsockopt_sol_socket_zerocopy (msk, val); }return -ENOPROTOOPT ;
@@ -351,6 +366,7 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname,case SO_TIMESTAMP_NEW :case SO_TIMESTAMPNS_OLD :case SO_TIMESTAMPNS_NEW : +case SO_ZEROCOPY :return mptcp_setsockopt_sol_socket_int (msk, optname, optval, optlen);case SO_TIMESTAMPING_OLD :
@@ -396,7 +412,6 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname,* SO_CNX_ADVICE is currently unsupported, could possibly be relevant, * but likely needs careful design * -* SO_ZEROCOPY is currently unsupported, TODO in sndmsg * SO_TXTIME is currently unsupported */
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 5/7] mptcp: handle SO_ZEROCOPY in setsockopt
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] mptcp: SO_ZEROCOPY lost on passive TCP fallback in mptcp_stream_accept() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] mptcp: SO_ZEROCOPY lost on passive TCP fallback in mptcp_stream_accept()
--
commit 9eb510c1b5396bee88c876458fbf9feb12e69c9b
Author: Geliang Tang <[email protected]>
mptcp: handle SO_ZEROCOPY in setsockopt
This commit adds SO_ZEROCOPY support to MPTCP setsockopt by setting SOCK_ZEROCOPY on the MPTCP socket.
Quoted 10 lines
net/mptcp/sockopt.c +2
-0@@ -184,6 +184,19 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnamreturn 0 ; } +static int mptcp_setsockopt_sol_socket_zerocopy (struct mptcp_sock *msk,int val) +{
net/mptcp/sockopt.c static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam · line 198
Quoted 10 lines
net/mptcp/sockopt.c +10
-0+struct sock *sk = (struct sock *)msk; + +if (val !=0 && val !=1 ) +return -EINVAL ; + +lock_sock (sk); +sock_valbool_flag (sk,SOCK_ZEROCOPY , val); +release_sock (sk); +return 0 ; +}
[Severity: Medium]
Does setting SOCK_ZEROCOPY only on msk lose the option when a listening MPTCP socket accepts a non-MP_CAPABLE peer and falls back to plain TCP?
On passive fallback, subflow_syn_recv_sock() clones the child socket from the listening TCP subflow (msk->first) rather than from msk, and mptcp_stream_accept() grafts that plain TCP child onto newsock with plain TCP ops. Because mptcp_setsockopt_sol_socket_zerocopy() and sync_socket_options() do not propagate SOCK_ZEROCOPY to subflows, the accepted fallback socket has SOCK_ZEROCOPY cleared: subsequent getsockopt(SO_ZEROCOPY) returns 0 and sendmsg(MSG_ZEROCOPY) silently falls back to copying in tcp_sendmsg_locked() without queuing completion notifications on MSG_ERRQUEUE.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
[email protected]
AI reviewRe: [PATCH mptcp-next v8 5/7] mptcp: handle SO_ZEROCOPY in setsockopt
In reply to Geliang TangThank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider.
Critical: 0 · High: 3 · 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).
- [High] mptcp_poll() in net/mptcp/protocol.c only sets EPOLLERR from READ_ONCE(sk->sk_err) (line 4696).
- [High] This patch lets unprivileged users turn on SOCK_ZEROCOPY on the msk, which exposes a gap in pinned-page accounting in…
- [High] On kernels with PAGE_SIZE >= 65536 (for example arm64 or ppc64le built with 64K pages), mptcp_sendmsg_zerocopy_iter()…
- [Medium] Now that SO_ZEROCOPY can be set on MPTCP, mptcp_sendmsg() (net/mptcp/protocol.c:2118-2119) clears MSG_ZEROCOPY whenever…
- [Medium] mptcp: SO_ZEROCOPY lost on passive TCP fallback in mptcp_stream_accept()
- [Low] The comment in mptcp_recvmsg() (net/mptcp/protocol.c:2530), '/* MSG_ERRQUEUE is really a no-op till we support IP_RECVERR */', is now…
- [Low] Documentation/networking/msg_zerocopy.rst says 'The feature is currently implemented for TCP, UDP and VSOCK (with virtio transport)…
--
mptcp: handle SO_ZEROCOPY in setsockopt
This patch lets SO_ZEROCOPY be set on MPTCP sockets through the SOL_SOCKET setsockopt dispatcher. The new helper, mptcp_setsockopt_sol_socket_zerocopy(), accepts 0 or 1 and toggles SOCK_ZEROCOPY on the msk. mptcp_sendmsg() then checks that flag to enable the MSG_ZEROCOPY path.
Quoted 7 lines
net/mptcp/sockopt.c +0
-0@@ -175,6 +175,19 @@ static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnamreturn 0 ; }
net/mptcp/sockopt.c static int mptcp_setsockopt_sol_socket_tstamp(struct mptcp_sock *msk, int optnam · line 186
Quoted 10 lines
net/mptcp/sockopt.c +9
-0+static int mptcp_setsockopt_sol_socket_zerocopy (struct mptcp_sock *msk,int val) +{ +struct sock *sk = (struct sock *)msk; + +if (val !=0 && val !=1 ) +return -EINVAL ; + +lock_sock (sk); +sock_valbool_flag (sk,SOCK_ZEROCOPY , val);
[Severity: Medium]
Does SOCK_ZEROCOPY survive a passive fallback to plain TCP?
This sets the flag only on the msk. It doesn't bump msk->setsockopt_seq the way mptcp_sol_socket_sync_intval() does. sync_socket_options() copies SOCK_KEEPOPEN, SOCK_LINGER and SOCK_DBG to the subflows, but not SOCK_ZEROCOPY. So the listening subflow msk->first never gets the flag, whether SO_ZEROCOPY is set before or after listen().
Now suppose a non-MP_CAPABLE client connects to such a listener. subflow_syn_recv_sock() creates the child through listener->icsk_af_ops->syn_recv_sock(). That clones it from the listening TCP subflow, so the child inherits the ssk's sk_flags rather than the msk's. The fallback path then calls mptcp_subflow_drop_ctx() on the child and returns it without ever calling mptcp_sk_clone_init().
mptcp_stream_accept() then takes the tcpfallback branch. __inet_accept() grafts the plain TCP child onto newsock, and the ops are switched to mptcp_fallback_tcp_ops(). From that point sendmsg() goes to tcp_sendmsg_locked() and getsockopt() goes to sk_getsockopt(), both on the TCP child, where SOCK_ZEROCOPY is clear.
TCP zerocopy servers commonly set SO_ZEROCOPY on the listener and rely on accepted sockets inheriting it. With this patch, getsockopt(SO_ZEROCOPY) on the accepted socket returns 0. A sendmsg(MSG_ZEROCOPY) is silently copied and no SO_EE_ORIGIN_ZEROCOPY notification is queued. An application waiting on MSG_ERRQUEUE for one completion per send could stall.
This also conflicts with the commit message's claim that setting the flag on the msk alone is honoured on every data path without any cross-socket propagation.
Should SOCK_ZEROCOPY be propagated to the subflows in sync_socket_options(), as SOCK_DBG is, with a setsockopt_seq bump here? Or would you rather copy it from the msk in the fallback accept path?
[Severity: High]
Will poll() ever report the zerocopy completions that this enables?
mptcp_sendmsg() calls msg_zerocopy_realloc() on the msk. The SO_EE_ORIGIN_ZEROCOPY notifications therefore go on msk->sk_error_queue, and sk_err stays 0. mptcp_poll() in net/mptcp/protocol.c only checks sk_err:
net/mptcp/protocol.c:mptcp_poll() {
...
if (READ_ONCE(sk->sk_err))
mask |= EPOLLERR;
...
}tcp_poll() checks the error queue as well:
net/ipv4/tcp.c:tcp_poll() {
...
if (READ_ONCE(sk->sk_err) ||
!skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR;
...
}Documentation/networking/msg_zerocopy.rst says poll "will set POLLERR in its output flags" while a notification is outstanding. Its example uses poll(&pfd, 1, -1).
When __msg_zerocopy_callback() calls sk_error_report(), the waiter wakes up and runs mptcp_poll() again. It gets no EPOLLERR and goes back to sleep. Level-triggered epoll misses the event in the same way.
Wouldn't an application that follows the documented pattern on an MPTCP socket block forever, with the uncollected notifications still holding optmem?
The selftest added later in the series ("selftests: mptcp: connect: add zerocopy io mode") doesn't catch this. wait_for_completions_zc() calls recvmsg(MSG_ERRQUEUE) itself and limits each poll() to 200 ms. No later patch in the series changes mptcp_poll().
[Severity: High]
With this opt-in in place, can userspace hit the WARN_ON_ONCE() in mptcp_sendmsg_zerocopy_iter() on kernels built with 64K pages?
net/mptcp/protocol.c:mptcp_sendmsg_zerocopy_iter() {
...
if (pg_len > U16_MAX) {
iov_iter_revert(&msg->msg_iter, pg_len - U16_MAX);
pg_len = U16_MAX;
}
if (pg_off > U16_MAX) {
...
}
if (pg_off + pg_len > U16_MAX) {
size_t len = U16_MAX - pg_off;
iov_iter_revert(&msg->msg_iter, pg_len - len);
pg_len = len;
if (WARN_ON_ONCE(!pg_len)) {
put_page(pages[0]);
return -EFAULT;
}
}
...
}With PAGE_SIZE == 65536, take a sendmsg(MSG_ZEROCOPY) of 64KB or more from a page-aligned buffer. The first call gets pg_off == 0 and pg_len == 65536, and reverting one byte clamps pg_len to 65535.
The next iteration gets the last byte of the same page, with pg_off == 65535 and pg_len == 1. The pg_off > U16_MAX check doesn't catch pg_off == U16_MAX, so len becomes 0 and the WARN fires. Sending a single byte from buf + 65535 triggers it directly.
The function then returns -EFAULT. mptcp_sendmsg() either returns a short write or aborts the ubuf and falls back to copying. On 64K-page systems zerocopy would keep falling back to copying. With panic_on_warn set, the first such send would panic the kernel.
This code was added by the previous patch, but it only becomes reachable now that SOCK_ZEROCOPY can be set on the msk.
[Severity: High]
Does this opt-in let an unprivileged user pin far more user pages than the send buffer should allow?
Each mptcp_sendmsg_zerocopy_iter() call pins one full user page. It charges the msk only for the bytes used plus the dfrag header:
net/mptcp/protocol.c:mptcp_sendmsg_zerocopy_iter() {
...
pg_len = iov_iter_get_pages2(&msg->msg_iter, pages,
copy_limit, 1, &pg_off);
...
dfrag->overhead = sizeof(struct mptcp_data_frag);
...
sk_wmem_queued_add(sk, pg_len + dfrag->overhead);
...
}With ITER_IOVEC, a 1-byte iovec segment gives pg_len == 1 but still pins a whole page. On 64-bit, each pinned page then adds only about 49 bytes to sk_wmem_queued.
The only per-socket limit in the send loop is mptcp_send_limit(), which compares sk_wmem_queued against sk_sndbuf. One msk could therefore pin roughly sk_sndbuf / 49 pages.
For comparison, TCP charges the page-aligned size of each pinned page in zerocopy_fill_skb_from_iter():
skb->truesize += PAGE_ALIGN(copied + start);
The subflow side doesn't account for the pages either. For pure-zerocopy skbs, mptcp_sendmsg_frag() adds only copy:
skb->truesize += copy; sk_wmem_queued_add(ssk, copy); if (!skb_zcopy_pure(skb)) sk_mem_charge(ssk, copy);
dfrag_uncharge() also skips sk_mem_uncharge() for ubuf dfrags.
mm_account_pinned_pages() charges RLIMIT_MEMLOCK by byte length:
num_pg = (size >> PAGE_SHIFT) + 2; /* worst case */
So 1024 one-byte iovecs on 1024 different pages are charged as 2 pages.
The pages stay pinned while the data sits unacknowledged in msk->rtx_queue, for example when the local peer never reads.
Should the dfrag be charged for the full pinned page, as TCP does?
[Severity: Medium]
Now that applications can opt in, is it intended that MSG_FASTOPEN sends silently drop MSG_ZEROCOPY without queueing a completion notification?
net/mptcp/protocol.c:mptcp_sendmsg() {
...
if (msg->msg_flags & MSG_FASTOPEN || !sock_flag(sk, SOCK_ZEROCOPY))
msg->msg_flags &= ~MSG_ZEROCOPY;
...
}For these sends msg_zerocopy_realloc() is never called. sk_zckey doesn't advance and no notification is queued.
Documentation/networking/msg_zerocopy.rst describes MSG_ZEROCOPY as "a contract that the kernel will queue a completion notification".
TCP keeps that contract on the fastopen path:
net/ipv4/tcp.c:tcp_sendmsg_locked() {
...
err = tcp_sendmsg_fastopen(sk, msg, &copied_syn, size, uarg);
...
}The tcp_zerocopy_fastopen-client.pkt and -server.pkt packetdrill tests check this behaviour. In its non-SG fallback cases, TCP queues a "copied" notification (SO_EE_CODE_ZEROCOPY_COPIED) instead.
A TCP application that uses sendto(MSG_FASTOPEN | MSG_ZEROCOPY) and waits for one notification per send would get nothing on MPTCP. It could wait forever.
The previous patch's commit message says this downgrade is intentional. This patch is what makes it visible to userspace.
Quoted 4 lines
net/mptcp/sockopt.c +4
-0+release_sock (sk); +return 0 ; +} +
[ ... ]
net/mptcp/sockopt.c static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, · line 362
Quoted 7 lines
net/mptcp/sockopt.c +1
-0@@ -342,6 +357,7 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname,case SO_TIMESTAMP_NEW :case SO_TIMESTAMPNS_OLD :case SO_TIMESTAMPNS_NEW : +case SO_ZEROCOPY :return mptcp_setsockopt_sol_socket_int (msk, optname, optval, optlen);
[Severity: Low]
This isn't a bug, but Documentation/networking/msg_zerocopy.rst still says:
The feature is currently implemented for TCP, UDP and VSOCK (with virtio transport) sockets.
Should MPTCP be added there now that SO_ZEROCOPY is accepted on IPPROTO_MPTCP sockets? The list already leaves out RDS, so it was incomplete before this series.
[ ... ]
net/mptcp/sockopt.c static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname, · line 407
Quoted 7 lines
net/mptcp/sockopt.c +0
-1@@ -387,7 +403,6 @@ static int mptcp_setsockopt_sol_socket(struct mptcp_sock *msk, int optname,* SO_CNX_ADVICE is currently unsupported, could possibly be relevant, * but likely needs careful design * -* SO_ZEROCOPY is currently unsupported, TODO in sndmsg * SO_TXTIME is currently unsupported */
[Severity: Low]
This isn't a bug, but the matching comment in mptcp_recvmsg() in net/mptcp/protocol.c is now out of date:
/* MSG_ERRQUEUE is really a no-op till we support IP_RECVERR */ if (unlikely(flags & MSG_ERRQUEUE)) return inet_recv_error(sk, msg, len);
Userspace now uses recvmsg(MSG_ERRQUEUE) to collect the zerocopy completion notifications. Should that comment be updated as well?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Geliang Tang
reviewerPATCH v8 6/7 selftests: mptcp: connect: add zerocopy io mode
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Add a new I/O mode 'zerocopy' to the mptcp_connect selftest, which uses sendmsg() with the MSG_ZEROCOPY flag to transmit data. This enables testing and performance validation of the zero-copy send path for both TCP and MPTCP connections.
This mode is useful for benchmarking and for verifying correctness of MSG_ZEROCOPY handling in the MPTCP stack.
The completion notification draining uses batched polling to handle large transfers that may generate multiple completion events across different TCP segments.
--- .../selftests/net/mptcp/mptcp_connect.c | 192 +++++++++++++++++- 1 file changed, 191 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +191 -1
@@ -33,6 +33,7 @@#include <linux/tcp.h> #include <linux/time_types.h> #include <linux/sockios.h> +#include <linux/errqueue.h> #include <linux/compiler.h> extern int optind;
@@ -53,6 +54,7 @@ enum cfg_mode {CFG_MODE_MMAP ,CFG_MODE_SENDFILE ,CFG_MODE_SPLICE , + CFG_MODE_ZEROCOPY, }; enum cfg_peek {
@@ -125,7 +127,7 @@ static void die_usage(void)fprintf (stderr,"\t-j -- add additional sleep at connection start and tear down " "-- for MPJ tests\n" );fprintf (stderr,"\t-l -- listens mode, accepts incoming connection\n" ); -fprintf (stderr,"\t-m [poll|mmap|sendfile|splice] -- use poll(default)/mmap+write/sendfile/splice\n" ); +fprintf (stderr,"\t-m [poll|mmap|sendfile|splice|zerocopy] -- use poll(default)/mmap+write/sendfile/splice/zerocopy\n" );fprintf (stderr,"\t-M mark -- set socket packet mark\n" );fprintf (stderr,"\t-o option -- test sockopt <option>\n" );fprintf (stderr,"\t-p num -- use port num\n" );
@@ -1014,6 +1016,180 @@ static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,return err; } +static bool process_cmsg_zc (struct msghdr *errmsg) +{ +struct sock_extended_err *serr; +struct cmsghdr *cm; + +for (cm =CMSG_FIRSTHDR (errmsg); cm; cm =CMSG_NXTHDR (errmsg, cm)) { +if (cm->cmsg_level !=SOL_IP && cm->cmsg_level !=SOL_IPV6 ) +continue ; +if (cm->cmsg_type !=IP_RECVERR && + cm->cmsg_type !=IPV6_RECVERR ) +continue ; + + serr = (struct sock_extended_err *)CMSG_DATA (cm); +if (serr->ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return true; + } + +return false; +} + +static bool drain_errqueue_zc (int peerfd) +{ +size_t ctl_len =CMSG_SPACE (sizeof (struct sock_extended_err )); +struct msghdr errmsg = {}; +bool found = false; +char *ctl; + + ctl =malloc (ctl_len); +if (!ctl) { +perror ("malloc ctl" ); +return false; + } + + errmsg.msg_control = ctl; + +while (!found) { + errmsg.msg_controllen = ctl_len; +if (recvmsg (peerfd, &errmsg,MSG_ERRQUEUE ) <0 ) +break ; + + found =process_cmsg_zc (&errmsg); + } + +free (ctl); +return found; +} + +static void wait_for_completions_zc (int peerfd) +{ +struct pollfd pfd = { .fd = peerfd, .events =POLLERR }; +struct timespec start, now; +int timeout_ms =5000 ; + +if (cfg_time >0 ) + timeout_ms = cfg_time; + +clock_gettime (CLOCK_MONOTONIC , &start); +for (;;) { +long elapsed_ms, remaining_ms; + +if (drain_errqueue_zc (peerfd)) +break ; + +clock_gettime (CLOCK_MONOTONIC , &now); + elapsed_ms = (now.tv_sec - start.tv_sec) *1000L + + (now.tv_nsec - start.tv_nsec) /1000000L ; +if (elapsed_ms >= timeout_ms) +break ; + + remaining_ms = timeout_ms - elapsed_ms; +if (remaining_ms >200 ) + remaining_ms =200 ; +if (poll (&pfd,1 , remaining_ms) <0 ) +break ; + } +} + +static int do_sendmsg_zc (int infd,int peerfd,size_t size, +struct wstate *winfo) +{ +struct iovec iov = {}; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + }; +size_t sent =0 ; +ssize_t ret; +void *buf; +int err; + + err =spool_buf (peerfd, winfo); +if (err) +return err; + + buf =malloc (size); +if (!buf) { +perror ("malloc" ); +return 1 ; + } + +if (read (infd, buf, size) != (ssize_t )size) { +perror ("read input" ); + err =1 ; + goto out; + } + +while (sent < size) { + iov.iov_base = buf + sent; + iov.iov_len = size - sent; + + ret =sendmsg (peerfd, &msg,MSG_ZEROCOPY ); +if (ret <=0 ) { +if (ret <0 ) { +perror ("sendmsg MSG_ZEROCOPY" ); + err =1 ; + } +break ; + } + sent += ret; + } +if (sent != size) +fprintf (stderr,"sendmsg short: %zu/%zu bytes queued\n" , + sent, size); + +if (size >0 ) +wait_for_completions_zc (peerfd); + +out: +free (buf); +return err; +} + +static int copyfd_io_zc (int infd,int peerfd,int outfd,unsigned int size, +bool *in_closed_after_out,struct wstate *winfo) +{ +socklen_t len; +int on =1 ; +int err; + +set_sndbuf (peerfd, size *2 ); + + len =sizeof (on); +if (setsockopt (peerfd,SOL_SOCKET ,SO_ZEROCOPY , &on, len)) { +perror ("setsockopt SO_ZEROCOPY" ); +return 1 ; + } + + on =-1 ; +if (getsockopt (peerfd,SOL_SOCKET ,SO_ZEROCOPY , &on, &len) || + on !=1 ) { +perror ("getsockopt SO_ZEROCOPY" ); +return 1 ; + } + +if (listen_mode) { + err =do_recvfile (peerfd, outfd); +if (err) +return err; + + err =do_sendmsg_zc (infd, peerfd, size, winfo); + }else { + err =do_sendmsg_zc (infd, peerfd, size, winfo); +if (err) +return err; + +shut_wr (peerfd); + + err =do_recvfile (peerfd, outfd); + *in_closed_after_out = true; + } + +return err; +} +static int copyfd_io (int infd,int peerfd,int outfd,bool close_peerfd,struct wstate *winfo) {bool in_closed_after_out = false;
@@ -1054,6 +1230,17 @@ static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd, struct &in_closed_after_out, winfo);break ; +case CFG_MODE_ZEROCOPY : + file_size =get_infd_size (infd); +if (file_size <0 ) +return file_size; +if (cfg_sockopt_types.mptfo && winfo->total_len && + file_size >= winfo->total_len) + file_size -= winfo->total_len; + ret =copyfd_io_zc (infd, peerfd, outfd, file_size, + &in_closed_after_out, winfo); +break ; +default :fprintf (stderr,"Invalid mode %d\n" , cfg_mode);
@@ -1470,6 +1657,8 @@ int parse_mode(const char *mode)return CFG_MODE_SENDFILE ;if (!strcasecmp (mode,"splice" ))return CFG_MODE_SPLICE ; +if (!strcasecmp (mode,"zerocopy" )) +return CFG_MODE_ZEROCOPY ;fprintf (stderr,"Unknown test mode: %s\n" , mode);fprintf (stderr,"Supported modes are:\n" );
@@ -1477,6 +1666,7 @@ int parse_mode(const char *mode)fprintf (stderr,"\t\t\"mmap\" - send entire input file (mmap+write), then read response (-l will read input first)\n" );fprintf (stderr,"\t\t\"sendfile\" - send entire input file (sendfile), then read response (-l will read input first)\n" );fprintf (stderr,"\t\t\"splice\" - send entire input file (splice), then read response (-l will read input first)\n" ); +fprintf (stderr,"\t\t\"zerocopy\" - send entire input file (zerocopy), then read response (-l will read input first)\n" );die_usage ();
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 6/7] selftests: mptcp: connect: add zerocopy io mode
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [Medium] selftests: mptcp: premature buffer free in do_sendmsg_zc() after first cmsg - [Medium] selftests…
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [Medium] selftests: mptcp: premature buffer free in do_sendmsg_zc() after first cmsg
- [Medium] selftests: mptcp: undersized msg_control buffer in drain_errqueue_zc()
- [Medium] selftests: mptcp: ignored zc errors and wait on 0 sent in do_sendmsg_zc()
- [Medium] selftests: mptcp: unconditional set_sndbuf() and 0-size MPTFO in copyfd_io_zc()
- [Low] selftests: mptcp: int overflow in size * 2 and unlooped read in do_sendmsg_zc()
--
commit 0f0d4fe1bd34bb0fc128a15413afd453172d8483
Author: Geliang Tang <[email protected]>
selftests: mptcp: connect: add zerocopy io mode
This commit adds a 'zerocopy' I/O mode to the mptcp_connect selftest that transmits data using sendmsg() with MSG_ZEROCOPY and drains completion notifications from the socket error queue.
Quoted 4 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +0
-0
[ ... ]
Quoted 22 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +18
-0@@ -1014,6 +1016,180 @@ static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,return err; } +static bool process_cmsg_zc (struct msghdr *errmsg) +{ +struct sock_extended_err *serr; +struct cmsghdr *cm; + +for (cm =CMSG_FIRSTHDR (errmsg); cm; cm =CMSG_NXTHDR (errmsg, cm)) { +if (cm->cmsg_level !=SOL_IP && cm->cmsg_level !=SOL_IPV6 ) +continue ; +if (cm->cmsg_type !=IP_RECVERR && + cm->cmsg_type !=IPV6_RECVERR ) +continue ; + + serr = (struct sock_extended_err *)CMSG_DATA (cm); +if (serr->ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return true; + } + +return false;
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1046
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+} + +static bool drain_errqueue_zc (int peerfd) +{ +size_t ctl_len =CMSG_SPACE (sizeof (struct sock_extended_err )); +struct msghdr errmsg = {}; +bool found = false; +char *ctl; + + ctl =malloc (ctl_len);
[Severity: Medium]
Is ctl_len large enough for the control messages queued on the error queue?
ip_recv_error() and ipv6_recv_error() append an offender sockaddr_in or sockaddr_in6 after struct sock_extended_err, so a buffer of CMSG_SPACE(sizeof(struct sock_extended_err)) triggers MSG_CTRUNC on every recvmsg(MSG_ERRQUEUE) call. They also call sock_recv_timestamp() before queuing IP_RECVERR or IPV6_RECVERR, so running with -c TIMESTAMPNS fills the entire 32-byte control buffer with the timestamp cmsg and drops the zero-copy completion cmsg, leaving wait_for_completions_zc() to stall until timeout.
Quoted 24 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +24
-0+if (!ctl) { +perror ("malloc ctl" ); +return false; + } + + errmsg.msg_control = ctl; + +while (!found) { + errmsg.msg_controllen = ctl_len; +if (recvmsg (peerfd, &errmsg,MSG_ERRQUEUE ) <0 ) +break ; + + found =process_cmsg_zc (&errmsg); + } + +free (ctl); +return found; +} + +static void wait_for_completions_zc (int peerfd) +{ +struct pollfd pfd = { .fd = peerfd, .events =POLLERR }; +struct timespec start, now; +int timeout_ms =5000 ;
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1080
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+ +if (cfg_time >0 ) + timeout_ms = cfg_time; + +clock_gettime (CLOCK_MONOTONIC , &start); +for (;;) { +long elapsed_ms, remaining_ms; + +if (drain_errqueue_zc (peerfd)) +break ;
[Severity: Medium]
Does wait_for_completions_zc() return as soon as the first SO_EE_ORIGIN_ZEROCOPY notification arrives rather than waiting for all issued sendmsg(MSG_ZEROCOPY) calls to complete?
Each sendmsg() in do_sendmsg_zc() allocates a new notification ID in mptcp_sendmsg() via msg_zerocopy_realloc() (and in TCP whenever the 512 KB byte limit is exceeded), so transfers larger than SO_SNDBUF (clamped to sysctl_wmem_max) produce multiple completion IDs. Stopping after the first cmsg without checking the completed [serr->ee_info, serr->ee_data] range against the number of sendmsg() calls causes do_sendmsg_zc() to call free(buf) while later zero-copy segments are still pinned and in flight, and leaves unread notifications on sk_error_queue.
Quoted 33 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +33
-0+ +clock_gettime (CLOCK_MONOTONIC , &now); + elapsed_ms = (now.tv_sec - start.tv_sec) *1000L + + (now.tv_nsec - start.tv_nsec) /1000000L ; +if (elapsed_ms >= timeout_ms) +break ; + + remaining_ms = timeout_ms - elapsed_ms; +if (remaining_ms >200 ) + remaining_ms =200 ; +if (poll (&pfd,1 , remaining_ms) <0 ) +break ; + } +} + +static int do_sendmsg_zc (int infd,int peerfd,size_t size, +struct wstate *winfo) +{ +struct iovec iov = {}; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + }; +size_t sent =0 ; +ssize_t ret; +void *buf; +int err; + + err =spool_buf (peerfd, winfo); +if (err) +return err; + + buf =malloc (size);
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1123
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+if (!buf) { +perror ("malloc" ); +return 1 ; + } + +if (read (infd, buf, size) != (ssize_t )size) { +perror ("read input" ); + err =1 ; + goto out; + }
[Severity: Low]
Can a single unlooped read(infd, buf, size) fail on partial reads or EINTR for large input files? In addition, set_sndbuf(peerfd, size * 2) in copyfd_io_zc() multiplies unsigned int size by 2, which overflows signed int in setsockopt(SO_SNDBUF) when size exceeds INT_MAX / 2.
Quoted 11 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +11
-0+ +while (sent < size) { + iov.iov_base = buf + sent; + iov.iov_len = size - sent; + + ret =sendmsg (peerfd, &msg,MSG_ZEROCOPY ); +if (ret <=0 ) { +if (ret <0 ) { +perror ("sendmsg MSG_ZEROCOPY" ); + err =1 ; + }
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1144
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+break ; + } + sent += ret; + } +if (sent != size) +fprintf (stderr,"sendmsg short: %zu/%zu bytes queued\n" , + sent, size); + +if (size >0 ) +wait_for_completions_zc (peerfd);
[Severity: Medium]
Should do_sendmsg_zc() check sent > 0 instead of size > 0 before calling wait_for_completions_zc(), and propagate completion and short-send failures?
If the first sendmsg() fails (for example with ENOBUFS when RLIMIT_MEMLOCK is exceeded), sent is 0 and no completion will ever be queued, yet wait_for_completions_zc() still blocks for the full 5000 ms timeout. Furthermore, wait_for_completions_zc() returns void (ignoring poll_timeout from -t) so completion timeouts, poll() errors, and malloc() failures in drain_errqueue_zc() return 0 from do_sendmsg_zc(); process_cmsg_zc() does not check serr->ee_errno or SO_EE_CODE_ZEROCOPY_COPIED; and a 0 return from sendmsg() with sent < size logs "sendmsg short" without setting err = 1.
Quoted 14 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +14
-0+ +out: +free (buf); +return err; +} + +static int copyfd_io_zc (int infd,int peerfd,int outfd,unsigned int size, +bool *in_closed_after_out,struct wstate *winfo) +{ +socklen_t len; +int on =1 ; +int err; + +set_sndbuf (peerfd, size *2 );
[ ... ]
Quoted 4 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +0
-0@@ -1054,6 +1230,17 @@ static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd, struct &in_closed_after_out, winfo);break ;
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io(int infd, int peerfd, int outfd, bool close_peerfd, struct · line 1242
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+case CFG_MODE_ZEROCOPY : + file_size =get_infd_size (infd); +if (file_size <0 ) +return file_size; +if (cfg_sockopt_types.mptfo && winfo->total_len && + file_size >= winfo->total_len) + file_size -= winfo->total_len; + ret =copyfd_io_zc (infd, peerfd, outfd, file_size, + &in_closed_after_out, winfo); +break ;
[Severity: Medium]
What happens when -o MPTFO is used with an input file of 8192 bytes or smaller, or when -S is passed to configure SO_SNDBUF?
When MPTFO is enabled and the input file fits in winfo->buf (8192 bytes), sock_connect_mptcp() reads the entire file into winfo->buf, so file_size -= winfo->total_len reduces size to 0; copyfd_io_zc() then calls set_sndbuf(peerfd, 0) and do_sendmsg_zc() calls malloc(0), which fails the test on libcs where malloc(0) returns NULL. In addition, calling set_sndbuf(peerfd, size * 2) unconditionally in copyfd_io_zc() overrides any -S cfg_sndbuf option and sets SOCK_SNDBUF_LOCK, disabling TCP and MPTCP send buffer autotuning.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
[email protected]
AI reviewRe: [PATCH mptcp-next v8 6/7] selftests: mptcp: connect: add zerocopy io mode
In reply to Geliang TangThank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 3 · Low: 3
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] In tools/testing/selftests/net/mptcp/mptcp_connect.c, wait_for_completions_zc() does not actually check that MSG_ZEROCOPY…
- [Medium] mptcp_poll() in net/mptcp/protocol.c sets EPOLLERR only when READ_ONCE(sk->sk_err) is set.
- [Medium] selftests: mptcp: undersized msg_control buffer in drain_errqueue_zc()
- [Low] Author/Signed-off-by mismatch.
- [Low] The zerocopy mode changes how the existing -T and -S options of mptcp_connect behave.
- [Low] The comment in mptcp_recvmsg() (net/mptcp/protocol.c) says '/* MSG_ERRQUEUE is really a no-op till we support IP_RECVERR */'.
--
selftests: mptcp: connect: add zerocopy io mode
This adds a zerocopy I/O mode to the mptcp_connect selftest. The mode enables SO_ZEROCOPY and sends the input file with sendmsg(MSG_ZEROCOPY). It then drains completion notifications from the socket error queue, polling up to a timeout.
Quoted 1 line
Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
This isn't a bug, but the Author line uses [email protected] and the only Signed-off-by uses [email protected]. checkpatch.pl reports this as FROM_SIGN_OFF_MISMATCH.
Could the From: address be changed, or a matching Signed-off-by be added?
Quoted 4 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +0
-0
[ ... ]
Quoted 6 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +2
-0@@ -1000,6 +1002,180 @@ static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,return err; } +static bool process_cmsg_zc (struct msghdr *errmsg) +{
[ ... ]
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+ serr = (struct sock_extended_err *)CMSG_DATA (cm); +if (serr->ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return true; + } + +return false; +} + +static bool drain_errqueue_zc (int peerfd) +{
[ ... ]
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1060
Quoted 7 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +7
-0+while (!found) { + errmsg.msg_controllen = ctl_len; +if (recvmsg (peerfd, &errmsg,MSG_ERRQUEUE ) <0 ) +break ; + + found =process_cmsg_zc (&errmsg); + }
[Severity: Low]
This loop depends on recvmsg(MSG_ERRQUEUE) returning zerocopy completions on an MPTCP socket. However, mptcp_recvmsg() in net/mptcp/protocol.c still says:
/* MSG_ERRQUEUE is really a no-op till we support IP_RECVERR */
if (unlikely(flags & MSG_ERRQUEUE))
return inet_recv_error(sk, msg, len);The earlier patch in this series, "mptcp: add MSG_ZEROCOPY support", makes __msg_zerocopy_callback() queue notifications on msk->sk_error_queue, so this path is no longer a no-op.
Should that comment be updated as part of the series?
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1073
Quoted 13 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +13
-0+ +free (ctl); +return found; +} + +static void wait_for_completions_zc (int peerfd) +{ +struct pollfd pfd = { .fd = peerfd, .events =POLLERR }; +struct timespec start, now; +int timeout_ms =5000 ; + +if (cfg_time >0 ) + timeout_ms = cfg_time;
[Severity: Low]
Is -T meant to double as the completion wait timeout? It is documented as the expected runtime of the whole transfer.
With -T, a late completion can use up the whole budget, and copyfd_io() then fails with "transfer slower than expected". Without -T, the same case passes silently after 5000 ms.
do_sendmsg_zc() also waits whenever size > 0, even when sendmsg() failed and nothing was queued:
if (size > 0)
wait_for_completions_zc(peerfd);In that case mptcp_sendmsg() calls net_zcopy_put_abort(), uarg->len drops to 0, and __msg_zerocopy_callback() skips the notification:
if (!uarg->len || sock_flag(sk, SOCK_DEAD))
goto release;As a result, the error path always stalls for the full timeout.
Separately, copyfd_io_zc() always does:
set_sndbuf(peerfd, size * 2);
This overrides any -S value already applied through
"if (cfg_sndbuf) set_sndbuf(fd, cfg_sndbuf)" and locks SO_SNDBUF, so -S is silently ignored in this mode.
Should this mode keep cfg_sndbuf when it is set?
Quoted 11 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +11
-0+ +clock_gettime (CLOCK_MONOTONIC , &start); +for (;;) { +long elapsed_ms, remaining_ms; + +if (drain_errqueue_zc (peerfd)) +break ; + +clock_gettime (CLOCK_MONOTONIC , &now); + elapsed_ms = (now.tv_sec - start.tv_sec) *1000L + + (now.tv_nsec - start.tv_nsec) /1000000L ;
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1094
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+if (elapsed_ms >= timeout_ms) +break ; + + remaining_ms = timeout_ms - elapsed_ms; +if (remaining_ms >200 ) + remaining_ms =200 ; +if (poll (&pfd,1 , remaining_ms) <0 ) +break ; + } +}
[Severity: Medium]
Will this poll() ever be woken by a zerocopy completion on an MPTCP socket?
mptcp_poll() in net/mptcp/protocol.c sets EPOLLERR only from sk_err:
if (READ_ONCE(sk->sk_err))
mask |= EPOLLERR;tcp_poll() also checks the error queue:
if (READ_ONCE(sk->sk_err) ||
!skb_queue_empty_lockless(&sk->sk_error_queue))
mask |= EPOLLERR;Since "mptcp: add MSG_ZEROCOPY support" earlier in this series, __msg_zerocopy_callback() queues completions on msk->sk_error_queue without setting sk_err. The poll-for-POLLERR pattern described in Documentation/networking/msg_zerocopy.rst therefore never wakes up on MPTCP sockets.
Here each poll() sleeps its full 200 ms cap before the next drain, which does not happen with TCP. Because the loop drains again unconditionally, the test also cannot catch the missing POLLERR.
Should mptcp_poll() check sk_error_queue the way tcp_poll() does?
Quoted 4 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +4
-0+ +static int do_sendmsg_zc (int infd,int peerfd,size_t size, +struct wstate *winfo) +{
[ ... ]
Quoted 15 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +15
-0+while (sent < size) { + iov.iov_base = buf + sent; + iov.iov_len = size - sent; + + ret =sendmsg (peerfd, &msg,MSG_ZEROCOPY ); +if (ret <=0 ) { +if (ret <0 ) { +perror ("sendmsg MSG_ZEROCOPY" ); + err =1 ; + } +break ; + } + sent += ret; + } +if (sent != size)
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1149
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +10
-0+fprintf (stderr,"sendmsg short: %zu/%zu bytes queued\n" , + sent, size); + +if (size >0 ) +wait_for_completions_zc (peerfd); + +out: +free (buf); +return err; +}
[Severity: Medium]
Does this check that the zerocopy completions actually arrived?
wait_for_completions_zc() returns void. If no notification arrives before the timeout, do_sendmsg_zc() still returns 0 and the test passes.
When a notification does arrive, drain_errqueue_zc() stops at the first one. process_cmsg_zc() only checks ee_origin, and nothing compares the [ee_info, ee_data] range with the number of sendmsg(MSG_ZEROCOPY) calls made above.
mptcp_sendmsg() allocates a new uarg for each call:
ubuf = msg_zerocopy_realloc(sk, len, NULL, false);
A short sendmsg() return therefore produces several IDs, and only the first is waited for. That can happen on a signal, on SO_SNDTIMEO, or on a partial copy followed by an error.
Could a kernel regression where completions never fire, or fire only partly, go unnoticed here? The data still arrives intact, so the test would pass.
On the timeout or partial path, free(buf) runs while skbs or dfrags may still reference the pinned pages. Is that safe? A later malloc(), for example on the next -I iteration in listen mode, could reuse the memory and overwrite data that is still in flight or queued for retransmit.
The commit message says:
The completion notification draining uses batched polling to handle large transfers that may generate multiple completion events across different TCP segments.
The loop accepts the first event, or none at all.
Should the test track the expected ID range and fail if it is not fully completed before the timeout?
[ ... ]
Quoted 171 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +167
-0@@ -1014,6 +1016,180 @@ static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size,return err; } +static bool process_cmsg_zc (struct msghdr *errmsg) +{ +struct sock_extended_err *serr; +struct cmsghdr *cm; + +for (cm =CMSG_FIRSTHDR (errmsg); cm; cm =CMSG_NXTHDR (errmsg, cm)) { +if (cm->cmsg_level !=SOL_IP && cm->cmsg_level !=SOL_IPV6 ) +continue ; +if (cm->cmsg_type !=IP_RECVERR && + cm->cmsg_type !=IPV6_RECVERR ) +continue ; + + serr = (struct sock_extended_err *)CMSG_DATA (cm); +if (serr->ee_origin ==SO_EE_ORIGIN_ZEROCOPY ) +return true; + } + +return false; +} + +static bool drain_errqueue_zc (int peerfd) +{ +size_t ctl_len =CMSG_SPACE (sizeof (struct sock_extended_err )); +struct msghdr errmsg = {}; +bool found = false; +char *ctl; + + ctl =malloc (ctl_len); +if (!ctl) { +perror ("malloc ctl" ); +return false; + } + + errmsg.msg_control = ctl; + +while (!found) { + errmsg.msg_controllen = ctl_len; +if (recvmsg (peerfd, &errmsg,MSG_ERRQUEUE ) <0 ) +break ; + + found =process_cmsg_zc (&errmsg); + } + +free (ctl); +return found; +} + +static void wait_for_completions_zc (int peerfd) +{ +struct pollfd pfd = { .fd = peerfd, .events =POLLERR }; +struct timespec start, now; +int timeout_ms =5000 ; + +if (cfg_time >0 ) + timeout_ms = cfg_time; + +clock_gettime (CLOCK_MONOTONIC , &start); +for (;;) { +long elapsed_ms, remaining_ms; + +if (drain_errqueue_zc (peerfd)) +break ; + +clock_gettime (CLOCK_MONOTONIC , &now); + elapsed_ms = (now.tv_sec - start.tv_sec) *1000L + + (now.tv_nsec - start.tv_nsec) /1000000L ; +if (elapsed_ms >= timeout_ms) +break ; + + remaining_ms = timeout_ms - elapsed_ms; +if (remaining_ms >200 ) + remaining_ms =200 ; +if (poll (&pfd,1 , remaining_ms) <0 ) +break ; + } +} + +static int do_sendmsg_zc (int infd,int peerfd,size_t size, +struct wstate *winfo) +{ +struct iovec iov = {}; +struct msghdr msg = { + .msg_iov = &iov, + .msg_iovlen =1 , + }; +size_t sent =0 ; +ssize_t ret; +void *buf; +int err; + + err =spool_buf (peerfd, winfo); +if (err) +return err; + + buf =malloc (size); +if (!buf) { +perror ("malloc" ); +return 1 ; + } + +if (read (infd, buf, size) != (ssize_t )size) { +perror ("read input" ); + err =1 ; + goto out; + } + +while (sent < size) { + iov.iov_base = buf + sent; + iov.iov_len = size - sent; + + ret =sendmsg (peerfd, &msg,MSG_ZEROCOPY ); +if (ret <=0 ) { +if (ret <0 ) { +perror ("sendmsg MSG_ZEROCOPY" ); + err =1 ; + } +break ; + } + sent += ret; + } +if (sent != size) +fprintf (stderr,"sendmsg short: %zu/%zu bytes queued\n" , + sent, size); + +if (size >0 ) +wait_for_completions_zc (peerfd); + +out: +free (buf); +return err; +} + +static int copyfd_io_zc (int infd,int peerfd,int outfd,unsigned int size, +bool *in_closed_after_out,struct wstate *winfo) +{ +socklen_t len; +int on =1 ; +int err; + +set_sndbuf (peerfd, size *2 ); + + len =sizeof (on); +if (setsockopt (peerfd,SOL_SOCKET ,SO_ZEROCOPY , &on, len)) { +perror ("setsockopt SO_ZEROCOPY" ); +return 1 ; + } + + on =-1 ; +if (getsockopt (peerfd,SOL_SOCKET ,SO_ZEROCOPY , &on, &len) || + on !=1 ) { +perror ("getsockopt SO_ZEROCOPY" ); +return 1 ; + } + +if (listen_mode) { + err =do_recvfile (peerfd, outfd); +if (err) +return err; + + err =do_sendmsg_zc (infd, peerfd, size, winfo); + }else { + err =do_sendmsg_zc (infd, peerfd, size, winfo); +if (err) +return err; + +shut_wr (peerfd); +
tools/testing/selftests/net/mptcp/mptcp_connect.c static int copyfd_io_splice(int infd, int peerfd, int outfd, unsigned int size, · line 1195
Quoted 10 lines
tools/testing/selftests/net/mptcp/mptcp_connect.c +7
-0+ err =do_recvfile (peerfd, outfd); + *in_closed_after_out = true; + } + +return err; +} +static int copyfd_io (int infd,int peerfd,int outfd,bool close_peerfd,struct wstate *winfo) {bool in_closed_after_out = false;
[Severity: Medium]
Is ctl_len big enough for what ip_recv_error() and ipv6_recv_error() write into the control buffer?
Both emit IP_RECVERR/IPV6_RECVERR with a payload made of struct sock_extended_err followed by the offender address, either struct sockaddr_in or struct sockaddr_in6. On 64-bit that is a CMSG_LEN() of 48 or 60 bytes. CMSG_SPACE(sizeof(struct sock_extended_err)) is only 32 bytes.
As a result, put_cmsg() sets MSG_CTRUNC on every MSG_ERRQUEUE read here. The sock_extended_err part survives the truncation, so the plain case works, but only by accident.
The problem gets worse when timestamps are enabled. Both ip_recv_error() and ipv6_recv_error() call sock_recv_timestamp() before put_cmsg().
With -c TIMESTAMPNS, apply_cmsg_types() enables SO_TIMESTAMPNS_NEW. The 32-byte timestamp cmsg then fills the whole buffer and leaves msg_controllen at 0. put_cmsg() drops the IP_RECVERR cmsg entirely, but the error queue skb is still consumed.
process_cmsg_zc() never sees SO_EE_ORIGIN_ZEROCOPY, so the notification is lost. wait_for_completions_zc() then keeps polling until the timeout, and the test still passes.
Should the buffer be sized for the full errhdr with a sockaddr_in6, plus room for any timestamp cmsgs? A fixed array with headroom, like the control buffer in do_recv_completion() in tools/testing/selftests/net/msg_zerocopy.c, would do.
Checking MSG_CTRUNC in errmsg.msg_flags would also make this kind of truncation visible instead of silently losing completions.
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Geliang Tang
reviewerPATCH v8 7/7 selftests: mptcp: connect: cover zerocopy mode
In reply to Geliang TangFrom: Geliang Tang <[email protected]>
Add a new test script mptcp_connect_zerocopy.sh to run the mptcp_connect selftest with the zerocopy I/O mode. This ensures the MSG_ZEROCOPY path is exercised in the regular test suite.
The script follows the same pattern as the existing mmap, sendfile, and splice test wrappers, invoking mptcp_connect.sh with the -m zerocopy option.
--- tools/testing/selftests/net/mptcp/Makefile | 1 + tools/testing/selftests/net/mptcp/mptcp_connect_zerocopy.sh | 5 +++++ 2 files changed, 6 insertions(+) create mode 100755 tools/testing/selftests/net/mptcp/mptcp_connect_zerocopy.sh
tools/testing/selftests/net/mptcp/Makefile +1 -0
@@ -12,6 +12,7 @@ TEST_PROGS := \ mptcp_connect_mmap.sh \ mptcp_connect_sendfile.sh \ mptcp_connect_splice.sh \ + mptcp_connect_zerocopy.sh \ mptcp_join.sh \ mptcp_sockopt.sh \ pm_netlink.sh \
tools/testing/selftests/net/mptcp/mptcp_connect_zerocopy.sh new file +5 -0
@@ -0,0 +1,5 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +MPTCP_LIB_KSFT_TEST="$(basename "${0}" .sh)" \ + "$(dirname "${0}")/mptcp_connect.sh" -m zerocopy "${@}"
Signature · 1 line
2.55.0
[email protected]
AI reviewRe: [PATCH mptcp-next v8 7/7] selftests: mptcp: connect: cover zerocopy mode
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
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 new wrapper mptcp_connect_zerocopy.sh is added to TEST_PROGS in tools/testing/selftests/net/mptcp/Makefile.
- [Low] The commit author is 'Geliang Tang <[email protected]>', but the only Signed-off-by line is 'Geliang Tang <[email protected]>'.
--
selftests: mptcp: connect: cover zerocopy mode
This commit adds a wrapper script, mptcp_connect_zerocopy.sh, which runs mptcp_connect.sh with -m zerocopy. It also adds the script to TEST_PROGS so that the MSG_ZEROCOPY mode runs as part of the regular mptcp selftests.
Quoted 1 line
Signed-off-by Geliang Tang <[email protected]>
[Severity: Low]
This isn't a bug, but the author is Geliang Tang <[email protected]>, while the only Signed-off-by line is for [email protected]. checkpatch reports this as FROM_SIGN_OFF_MISMATCH.
The other patches in the series have the same mismatch. When the series is resent, could a Signed-off-by be added for the author address, or the author be changed to match the sign-off?
[ ... ]
tools/testing/selftests/net/mptcp/mptcp_connect_zerocopy.sh line 5
Quoted 11 lines
tools/testing/selftests/net/mptcp/mptcp_connect_zerocopy.sh new file +5
-0@@ -0,0 +1,5 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +MPTCP_LIB_KSFT_TEST="$(basename "${0}" .sh)" \ + "$(dirname "${0}")/mptcp_connect.sh" -m zerocopy "${@}"
[Severity: Medium]
The commit message says this "ensures the MSG_ZEROCOPY path is exercised in the regular test suite". Can this wrapper fail if the zerocopy send path regresses?
The zerocopy mode was added to mptcp_connect.c earlier in this series. In that mode, the only zerocopy-specific checks that can fail seem to be the setsockopt() and getsockopt() calls for SO_ZEROCOPY. Otherwise the result only depends on the data arriving intact.
wait_for_completions_zc() returns void and leaves its poll loop on timeout:
tools/testing/selftests/net/mptcp/mptcp_connect.c:wait_for_completions_zc() {
...
if (elapsed_ms >= timeout_ms)
break;
...
}So if no SO_EE_ORIGIN_ZEROCOPY completion arrives, neither do_sendmsg_zc() nor its caller is told.
process_cmsg_zc() returns true on the first zerocopy notification:
tools/testing/selftests/net/mptcp/mptcp_connect.c:process_cmsg_zc() {
...
serr = (struct sock_extended_err *)CMSG_DATA(cm);
if (serr->ee_origin == SO_EE_ORIGIN_ZEROCOPY)
return true;
...
}It ignores ee_code, so SO_EE_CODE_ZEROCOPY_COPIED is accepted. It also does not check that the ee_info..ee_data range covers every sendmsg() call made in the while (sent < size) loop.
On the kernel side, mptcp_sendmsg() clears the flag without an error and uses the normal copy path:
net/mptcp/protocol.c:mptcp_sendmsg() {
...
if (msg->msg_flags & MSG_FASTOPEN || !sock_flag(sk, SOCK_ZEROCOPY))
msg->msg_flags &= ~MSG_ZEROCOPY;
...
}Several regressions would still give byte-identical output, and every subtest would pass:
- MSG_ZEROCOPY is masked off.
- mptcp_sendmsg_zerocopy_iter() is never reached.
- Completions are never sent, or are lost for later chunks (for example, a ubuf refcount leak).
- Pages are always copied.
The only visible symptom would be up to 5 seconds of extra run time per sending side.
Should the zerocopy mode in mptcp_connect.c fail when no completion arrives before the timeout? Should it also fail when the reported completion range does not cover all the sendmsg() calls?
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1795421388.git.tanggeliang%40kylinos.cn
Hi Geliang,
Thank you for your modifications, that's great!
Our CI did some validations and here is its report:
- KVM Validation: normal (except selftest_mptcp_join): Unstable: 1 failed test(s): packetdrill_regressions ⚠️
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Unstable: 4 failed test(s): regression:sched-mem-pressure regression:sched-rmem regression:sched-serverlim validation:sched-loss(2) ⚠️ (2 improvements, 105 new outliers to review)
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/45140657205
Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/ef940c87598b
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1219302
If there are some issues, you can reproduce them using the same environment as the one used by the CI thanks to a docker image, e.g.:
$ cd [kernel source code]
$ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
--pull always mptcp/mptcp-upstream-virtme-docker:latest \
auto-normalFor more details:
https://github.com/multipath-tcp/mptcp-upstream-virtme-docker
Please note that despite all the efforts that have been already done to have a stable tests suite when executed on a public CI like here, it is possible some reported issues are not due to your modifications. Still, do not hesitate to help us improve that ;-)
Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)