From: Gang Yan <gang.yan@linux.dev>
To: mptcp@lists.linux.dev
Cc: Gang Yan <yangang@kylinos.cn>
Subject: [RFC mptcp-next] mptcp: support MSG_EOR in mptcp_sendmsg
Date: Mon, 2 Feb 2026 12:09:16 +0800 [thread overview]
Message-ID: <20260202040916.626066-1-gang.yan@linux.dev> (raw)
From: Gang Yan <yangang@kylinos.cn>
This patch adds support for the MSG_EOR flag in MPTCP's sendmsg path,
ensuring that data fragments marked with MSG_EOR are properly handled
to prevent coalescing with subsequent data.
Key changes:
1. Added an 'eor' field to struct mptcp_data_frag to track MSG_EOR marking
2. Initialize the eor field to 0 in mptcp_carve_data_frag()
3. In mptcp_sendmsg_frag(), when sending the last chunk of a data fragment
that has MSG_EOR set, mark the corresponding skb with TCP_SKB_CB(skb)->eor = 1
to prevent coalescing with subsequent data
4. Modified mptcp_sendmsg() to:
- Preserve MSG_EOR flag in msg_flags filtering
- Mark the last pending data fragment with eor = 1 when MSG_EOR is set
in the message flags
This ensures that applications using MSG_EOR to indicate record boundaries
have their intent preserved across MPTCP subflows, maintaining proper
message segmentation semantics.
Signed-off-by: Gang Yan <yangang@kylinos.cn>
---
Notes:
Hi Matt,
I create two packetdrill scripts to test the 'MSG_EOR' in
single/multi subflow(s). The link is attached below:
https://github.com/multipath-tcp/packetdrill/compare/mptcp-net-next...Dwyane-Yan:packetdrill:mptcp-net-next
Please ignore the indent problems, I will fix them when
the 'MSG_EOR' patch is accepted.
Thanks
net/mptcp/protocol.c | 22 +++++++++++++++++++---
net/mptcp/protocol.h | 1 +
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index c88882062c40..b8200765506f 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -1174,6 +1174,7 @@ mptcp_carve_data_frag(const struct mptcp_sock *msk, struct page_frag *pfrag,
dfrag->offset = offset + sizeof(struct mptcp_data_frag);
dfrag->already_sent = 0;
dfrag->page = pfrag->page;
+ dfrag->eor = 0;
return dfrag;
}
@@ -1434,6 +1435,13 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct sock *ssk,
mptcp_update_infinite_map(msk, ssk, mpext);
trace_mptcp_sendmsg_frag(mpext);
mptcp_subflow_ctx(ssk)->rel_write_seq += copy;
+
+ /* If this is the last chunk of a dfrag with MSG_EOR set
+ * mark the skb to prevent coalescing with subsequent data
+ */
+ if (dfrag->eor && info->sent + copy >= dfrag->data_len)
+ TCP_SKB_CB(skb)->eor = 1;
+
return copy;
}
@@ -1894,7 +1902,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
long timeo;
/* silently ignore everything else */
- msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_FASTOPEN;
+ msg->msg_flags &= MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL |
+ MSG_FASTOPEN | MSG_EOR;
lock_sock(sk);
@@ -2001,9 +2010,16 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
goto do_error;
}
- if (copied)
- __mptcp_push_pending(sk, msg->msg_flags);
+ if (copied) {
+ /* Mark the last dfrag with EOR if MSG_EOR was set */
+ if (msg->msg_flags & MSG_EOR) {
+ struct mptcp_data_frag *dfrag = mptcp_pending_tail(sk);
+ if (dfrag)
+ dfrag->eor = 1;
+ }
+ __mptcp_push_pending(sk, msg->msg_flags);
+ }
out:
release_sock(sk);
return copied;
diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index cd5266099993..5bfe1002242d 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -267,6 +267,7 @@ struct mptcp_data_frag {
u16 overhead;
u16 already_sent;
struct page *page;
+ u8 eor; /* Is MSG_EOR marked? Prevents coalescing with next frag */
};
/* Arbitrary compromise between as low as possible to react timely to subflow
--
2.43.0
next reply other threads:[~2026-02-02 4:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 4:09 Gang Yan [this message]
2026-02-02 5:36 ` [RFC mptcp-next] mptcp: support MSG_EOR in mptcp_sendmsg MPTCP CI
2026-02-02 10:28 ` Matthieu Baerts
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260202040916.626066-1-gang.yan@linux.dev \
--to=gang.yan@linux.dev \
--cc=mptcp@lists.linux.dev \
--cc=yangang@kylinos.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.