From nobody Wed Apr 1 23:27:55 2026 Received: from out-177.mta0.migadu.com (out-177.mta0.migadu.com [91.218.175.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1D8A397E9D for ; Tue, 31 Mar 2026 09:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774948133; cv=none; b=VjLisi7D+e6VRMYPXhGRExQZPcl0mcbf3z3xzTM85KA0kRWPpNx6GmTaryF/oMYelc0ltx/YjAehmHAa2xox3ECwvVis6btJjDXN8FjTX6TuEm/XANomEuudV6Kow6vsyJL9B5pHQ7dHELHGxNg4CBQoMCOE4kxVr5vz4Qni9/w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774948133; c=relaxed/simple; bh=elMmdLOrpTKl4qBuCEJAl0CE3HIKPSe6Ubuw1f/aaFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nYw7CzKKV0t4No8R/2XF/o4apacJSP7KHBVpke8OYt8cL2Gt88F641+Qt+bfz71qtosGaKBakhrEIJyo7+0e769LW2LImrRCfzEBdMUD4P0yzs68CTk2vYbZklRLGQgnkjgvh9r9R80yCdOAOEPi0NRY7SnEiPpyEhqZl620O64= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=TarAf+Z3; arc=none smtp.client-ip=91.218.175.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="TarAf+Z3" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774948129; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fcYDBZs3rhWln/EMaIzHIR9xKBxU+t4O+m7ah8aEOyU=; b=TarAf+Z33/u4rrsoAOJ1qVJmTTf3HG6n2kNxoYi9xgUswu3KwE/NtE7A/O1x4/9FV7Jfs9 QHeR4OJoNJ8yGNya7mx6IdUm3Pf3miJIkIKPE8DWbAshrfZYL+OBovc7zjpjv7d5HjepIc efBoXMpZDKkogQpZLCH2EWMu/b9pQHc= From: Gang Yan To: mptcp@lists.linux.dev Cc: Gang Yan Subject: [PATCH mptcp-next v2 1/2] mptcp: reduce 'overhead' from u16 to u8 Date: Tue, 31 Mar 2026 17:08:08 +0800 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Gang Yan The 'overhead' in struct mptcp_data_frag can safely use u8, as it represents 'alignment + sizeof(mptcp_data_frag)'. With a maximum alignment of 7('ALIGN(1, sizeof(long)) - 1'), the overhead is at most 47, well below U8_MAX and validated with BUILD_BUG_ON(). This patch also adds a field named 'unused' for further extensions. Signed-off-by: Gang Yan Reviewed-by: Matthieu Baerts (NGI0) Suggested-by: Paolo Abeni --- net/mptcp/protocol.c | 4 ++++ net/mptcp/protocol.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 46fedfa05a54..01690a84ea6d 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4624,6 +4624,10 @@ void __init mptcp_proto_init(void) inet_register_protosw(&mptcp_protosw); =20 BUILD_BUG_ON(sizeof(struct mptcp_skb_cb) > sizeof_field(struct sk_buff, c= b)); + /* ensure 'overhead' (alignment + sizeof(struct mptcp_data_frag)) fits in= u8. + * 'ALIGN(1, sizeof(long)) - 1' represents the maximum of alignment. + */ + BUILD_BUG_ON(ALIGN(1, sizeof(long)) - 1 + sizeof(struct mptcp_data_frag) = > U8_MAX); } =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index f5d4d7d030f2..afdead91a4d7 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -264,7 +264,8 @@ struct mptcp_data_frag { u64 data_seq; u16 data_len; u16 offset; - u16 overhead; + u8 overhead; + u8 __unused; u16 already_sent; struct page *page; }; --=20 2.43.0 From nobody Wed Apr 1 23:27:55 2026 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FF7A3EC2C7 for ; Tue, 31 Mar 2026 09:08:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774948135; cv=none; b=PRIPJVq6tWGYEYeLh3vM0Y2GozyPJUn4+f7fpAWe0tGGB3rORhv261MtTyRWyimwzpy+HNg/dQJ1MLSZC9krTqF5qnPKO1imQySyladnVXCRLvZgcozXdArsnUM7QKMkgbB6ixBmzfmOkgvlr462bibxCGA5BFJNi3nnQP1fJ38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774948135; c=relaxed/simple; bh=L7z8mxjEKyyoD+jnBOupQf3hnK1tRzp/USnQWM7AlzI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfzVeae7ctexC80V4jjkz7vmz4xPeRxoUk2qoxEvX/rU8lvxpVwH/ALifrdJ+qM3JYAQQUgM7N+CfUQUtyc2Yxoy6u8TJbbZjLI15sl4sYu/nmdrPxJrdsADOzJbLA/xbjGwELe77EuRiZ6eP5/wowyDh6p36nOrrPzQqDgNJZs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tJTtf7aU; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="tJTtf7aU" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774948131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cA3snmR3/R3H1vjoGHVkWgrWXv+6oGnnRe0mqDjj9cw=; b=tJTtf7aU2ohEmgYGv1AOFadIw8Eney+yIy42XGpjXP3f5WvErEFMToo4MuLgEGCv6J/0KT baVaxH/ySslU+zXxHhrLF9ebgKXGaMjNzz1h7qMqBhhKOF7PAYei11sIphYjtAEwjTPvnG OP/8pFzhjw9nXjKgZax23ALD1S871D4= From: Gang Yan To: mptcp@lists.linux.dev Cc: Gang Yan Subject: [PATCH mptcp-next v2 2/2] mptcp: preserve MSG_EOR semantics in sendmsg path Date: Tue, 31 Mar 2026 17:08:09 +0800 Message-ID: <0bed96b3828c0a67950993fc0dd9233c17b94abd.1774947296.git.yangang@kylinos.cn> In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Gang Yan Extend MPTCP's sendmsg handling to recognize and honor the MSG_EOR flag, which marks the end of a record for application-level message boundaries. Data fragments tagged with MSG_EOR are explicitly marked in the mptcp_data_frag structure and skb context to prevent unintended coalescing with subsequent data chunks. This ensures the intent of applications using MSG_EOR is preserved across MPTCP subflows, maintaining consistent message segmentation behavior. Signed-off-by: Gang Yan Reviewed-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 24 +++++++++++++++++++++--- net/mptcp/protocol.h | 3 ++- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 01690a84ea6d..dafa178f43c5 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1032,7 +1032,8 @@ static bool mptcp_frag_can_collapse_to(const struct m= ptcp_sock *msk, const struct page_frag *pfrag, const struct mptcp_data_frag *df) { - return df && pfrag->page =3D=3D df->page && + return df && !df->eor && + pfrag->page =3D=3D df->page && pfrag->size - pfrag->offset > 0 && pfrag->offset =3D=3D (df->offset + df->data_len) && df->data_seq + df->data_len =3D=3D msk->write_seq; @@ -1174,6 +1175,7 @@ mptcp_carve_data_frag(const struct mptcp_sock *msk, s= truct page_frag *pfrag, dfrag->offset =3D offset + sizeof(struct mptcp_data_frag); dfrag->already_sent =3D 0; dfrag->page =3D pfrag->page; + dfrag->eor =3D 0; =20 return dfrag; } @@ -1435,6 +1437,13 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, mptcp_update_infinite_map(msk, ssk, mpext); trace_mptcp_sendmsg_frag(mpext); mptcp_subflow_ctx(ssk)->rel_write_seq +=3D 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 >=3D dfrag->data_len) + TCP_SKB_CB(skb)->eor =3D 1; + return copy; } =20 @@ -1895,7 +1904,8 @@ static int mptcp_sendmsg(struct sock *sk, struct msgh= dr *msg, size_t len) long timeo; =20 /* silently ignore everything else */ - msg->msg_flags &=3D MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | MSG_FASTOPEN; + msg->msg_flags &=3D MSG_MORE | MSG_DONTWAIT | MSG_NOSIGNAL | + MSG_FASTOPEN | MSG_EOR; =20 lock_sock(sk); =20 @@ -2002,8 +2012,16 @@ static int mptcp_sendmsg(struct sock *sk, struct msg= hdr *msg, size_t len) goto do_error; } =20 - if (copied) + if (copied) { + /* mark the last dfrag with EOR if MSG_EOR was set */ + if (msg->msg_flags & MSG_EOR) { + struct mptcp_data_frag *dfrag =3D mptcp_pending_tail(sk); + + if (dfrag) + dfrag->eor =3D 1; + } __mptcp_push_pending(sk, msg->msg_flags); + } =20 out: release_sock(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index afdead91a4d7..db96f2945cbd 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -265,7 +265,8 @@ struct mptcp_data_frag { u16 data_len; u16 offset; u8 overhead; - u8 __unused; + u8 eor:1, + __unused:7; u16 already_sent; struct page *page; }; --=20 2.43.0