From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A2BB018C933; Thu, 28 May 2026 03:11:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937894; cv=none; b=ek89of3gUsLRVxIn69NfuS/O47Fs8I0NvG/yjUYRGyoEmD7k1Vx0OSGBPY7m0BUulOCngCgdu8dgn70+q5RXJt4rAT6DfMNQegV8KWVglW4VFDpmStjIxFQ3mScLEmD3nWPA0sLLIPTRmIvGmNqwCtT4y0gMYq+WqpCWAba9big= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937894; c=relaxed/simple; bh=ZMNuIVT8gV8ZN6nKIeG2ScAwpDxPEviwNrWCPBg4o50=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tMq6NKjMogHM7Mh/+2rnJsVJmeofdJ57BSYPihznPQlxTpmCwnz85Ui+D+uyW8GDgBwNrE2/7uv92d48ZC66os13dBtQmNL6+yIfw2oKIn7hU1tD8Eaw7Z5M4eK7Zfa3PZ9ZuCCR5rahNMErIG/wu9djRYe2GTZTa3dUSMGkfg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EykKuMgj; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EykKuMgj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F02A11F00A3A; Thu, 28 May 2026 03:11:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937893; bh=KVemK4auRRniSZlXG4406d5EhydMfgsXDt+TRcAqsZM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EykKuMgj03gMuLQOj3o1AIgKvtmgGBM8DHNrKutO+1iaDAojjho67lVlS5CaToFch taSn951lGHAbUFONOES4Tdhhjf14dmzAtlEPyW5+Y9VCXAEnWnPyeMec10oDvve6FE +4ChgVeg8Zy1oa2Oy0YuD1vsILiPrnK7HwNtZXM9VcS4xeTsCRwt+XPTlCm1CF9gCF 7Pl2X7oUwZGdBlA8lLMjaAcIJpPwLKq2yNm9H09CtMEWyZSJtlLC6tcIr4O+UIQBNp YD14HI3E3QEZy9PpfVRqyj9XJDjPV40DNmXdWq9wf6QIikdGn0a3jla0hGg+Y3oKDR bwFg+uF7F23IA== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 01/11] nvmet-tcp: define accept tcp_proto struct Date: Thu, 28 May 2026 11:10:35 +0800 Message-ID: <4b377515d055f8097f4268f9570bc8d5e4e0dba8.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang To handle accepted sockets, this patch adds struct nvmet_tcp_proto to hold accept socket operations (no_linger, set_priority, set_tos, ops). A proto field is added to struct nvmet_tcp_queue, which points to the appropriate protocol structure. A TCP version is defined and assigned to queue->proto for TCP connections. Also modify nvmet_tcp_set_queue_sock() and nvmet_tcp_done_recv_pdu() to use queue->proto for socket operations and fabrics callbacks. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/target/tcp.c | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 20f150d17a96..01c23fb15b79 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -145,6 +145,13 @@ enum nvmet_tcp_queue_state { NVMET_TCP_Q_FAILED, }; =20 +struct nvmet_tcp_proto { + void (*no_linger)(struct sock *sk); + void (*set_priority)(struct sock *sk, u32 priority); + void (*set_tos)(struct sock *sk); + const struct nvmet_fabrics_ops *ops; +}; + struct nvmet_tcp_queue { struct socket *sock; struct nvmet_tcp_port *port; @@ -196,6 +203,7 @@ struct nvmet_tcp_queue { void (*data_ready)(struct sock *); void (*state_change)(struct sock *); void (*write_space)(struct sock *); + const struct nvmet_tcp_proto *proto; }; =20 struct nvmet_tcp_port { @@ -1081,7 +1089,8 @@ static int nvmet_tcp_done_recv_pdu(struct nvmet_tcp_q= ueue *queue) req =3D &queue->cmd->req; memcpy(req->cmd, nvme_cmd, sizeof(*nvme_cmd)); =20 - if (unlikely(!nvmet_req_init(req, &queue->nvme_sq, &nvmet_tcp_ops))) { + if (unlikely(!nvmet_req_init(req, &queue->nvme_sq, + queue->proto->ops))) { pr_err("failed cmd %p id %d opcode %d, data_len: %d, status: %04x\n", req->cmd, req->cmd->common.command_id, req->cmd->common.opcode, @@ -1698,7 +1707,6 @@ static void nvmet_tcp_state_change(struct sock *sk) static int nvmet_tcp_set_queue_sock(struct nvmet_tcp_queue *queue) { struct socket *sock =3D queue->sock; - struct inet_sock *inet =3D inet_sk(sock->sk); int ret; =20 ret =3D kernel_getsockname(sock, @@ -1716,14 +1724,13 @@ static int nvmet_tcp_set_queue_sock(struct nvmet_tc= p_queue *queue) * close. This is done to prevent stale data from being sent should * the network connection be restored before TCP times out. */ - sock_no_linger(sock->sk); + queue->proto->no_linger(sock->sk); =20 if (so_priority > 0) - sock_set_priority(sock->sk, so_priority); + queue->proto->set_priority(sock->sk, so_priority); =20 /* Set socket type of service */ - if (inet->rcv_tos > 0) - ip_sock_set_tos(sock->sk, inet->rcv_tos); + queue->proto->set_tos(sock->sk); =20 ret =3D 0; write_lock_bh(&sock->sk->sk_callback_lock); @@ -1906,6 +1913,21 @@ static int nvmet_tcp_tls_handshake(struct nvmet_tcp_= queue *queue) static void nvmet_tcp_tls_handshake_timeout(struct work_struct *w) {} #endif =20 +static void tcp_sock_set_tos(struct sock *sk) +{ + struct inet_sock *inet =3D inet_sk(sk); + + if (inet->rcv_tos > 0) + ip_sock_set_tos(sk, inet->rcv_tos); +} + +static const struct nvmet_tcp_proto nvmet_tcp_proto =3D { + .no_linger =3D sock_no_linger, + .set_priority =3D sock_set_priority, + .set_tos =3D tcp_sock_set_tos, + .ops =3D &nvmet_tcp_ops, +}; + static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, struct socket *newsock) { @@ -1923,6 +1945,12 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_p= ort *port, INIT_WORK(&queue->io_work, nvmet_tcp_io_work); kref_init(&queue->kref); queue->sock =3D newsock; + if (newsock->sk->sk_protocol =3D=3D IPPROTO_TCP) { + queue->proto =3D &nvmet_tcp_proto; + } else { + ret =3D -EINVAL; + goto out_free_queue; + } queue->port =3D port; queue->nr_cmds =3D 0; spin_lock_init(&queue->state_lock); --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 3667418C933; Thu, 28 May 2026 03:11:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937901; cv=none; b=DDMg2ZhCtLjIdOKw/N4HPDcBCn3kL6h5unSEbWZWlZZkrP2FURujAR8DxH91/9vl4qmPBwAmmaPCIxFNbPqCS2yozTKsEXLUl40MpLvHq1pWVf26XzRnYWrrM4yvUivoLFcAivqrjmCr/jdJJtenMhm7cwQpSIe6Hrf8jyGGIb0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937901; c=relaxed/simple; bh=8NVMjdRxZpTyLQxHaCs8pbMS+s5bcuOhtXOHfSz4tcw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SUP2Zm04s+eopWSFLTfgMIajd+yfF3W+Awuyb6q3wbTrTpz8NPVDPv5HgIfoPP0NqJy8WEpN+2RylnJ7NtcDtV9LQu2UzSWteHEHz1SN1gEswZCfcVRv/CJMQWa1xyvIkn2kuuh/Dpv4NZ4EJYonrWNK9SB1K1UHqUrhGCqyKts= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FIWn/mYD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FIWn/mYD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1C4E1F00A3C; Thu, 28 May 2026 03:11:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937899; bh=6+8IEzoRehjjp8IjXCg+Lnt1AIJejqKg0hiZ67zNe3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FIWn/mYDkjaJRU7bNOFKOv2WcJ6KtrWz08uijEIWCU/NMaxtn3tSMRmcOmQ18kAlX kj16jDwA9JMfjlulFOCPPytGbM3uzx3sBlRao1z8vQmnUOzSndXpOMHAMdxfT5A+5L 0s+5qOt2DztUI0Vu2VV42fpc38Yy32uFnFXJHougFhLaRe673S/83mq+oLt/ryhas3 S9aCIvyhU5lg67UPy4fREjn9DI7wYsXP5lVKLZehZMP1XbUzCKFbWBs9tChi5Lx991 vzwkdOghWMX1XzhIBrA9iTYmFPvf5tbl5IT7eOWJtnb46Are25ZChchdMZmh+9LOal zEeUkh/1kC75A== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 02/11] nvmet-tcp: implement accept mptcp proto Date: Thu, 28 May 2026 11:10:36 +0800 Message-ID: X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang An MPTCP-specific version of struct nvmet_tcp_proto is implemented for accept sockets. It is assigned to queue->proto when the accepted socket protocol is IPPROTO_MPTCP. Dedicated MPTCP helpers are introduced for setting accept socket options. These helpers (no_linger, set_priority, set_tos) set the values on all existing subflows using mptcp_for_each_subflow(). The values are then synchronized to other newly created subflows in sync_socket_options(). Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/target/tcp.c | 16 ++++++++ include/net/mptcp.h | 12 ++++++ net/mptcp/sockopt.c | 79 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 01c23fb15b79..16f153a9772b 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -220,6 +220,9 @@ static DEFINE_MUTEX(nvmet_tcp_queue_mutex); =20 static struct workqueue_struct *nvmet_tcp_wq; static const struct nvmet_fabrics_ops nvmet_tcp_ops; +#ifdef CONFIG_MPTCP +static const struct nvmet_fabrics_ops nvmet_mptcp_ops; +#endif static void nvmet_tcp_free_cmd(struct nvmet_tcp_cmd *c); static void nvmet_tcp_free_cmd_buffers(struct nvmet_tcp_cmd *cmd); =20 @@ -1928,6 +1931,15 @@ static const struct nvmet_tcp_proto nvmet_tcp_proto = =3D { .ops =3D &nvmet_tcp_ops, }; =20 +#ifdef CONFIG_MPTCP +static const struct nvmet_tcp_proto nvmet_mptcp_proto =3D { + .no_linger =3D mptcp_sock_no_linger, + .set_priority =3D mptcp_sock_set_priority, + .set_tos =3D mptcp_sock_set_tos, + .ops =3D &nvmet_mptcp_ops, +}; +#endif + static void nvmet_tcp_alloc_queue(struct nvmet_tcp_port *port, struct socket *newsock) { @@ -1947,6 +1959,10 @@ static void nvmet_tcp_alloc_queue(struct nvmet_tcp_p= ort *port, queue->sock =3D newsock; if (newsock->sk->sk_protocol =3D=3D IPPROTO_TCP) { queue->proto =3D &nvmet_tcp_proto; +#ifdef CONFIG_MPTCP + } else if (newsock->sk->sk_protocol =3D=3D IPPROTO_MPTCP) { + queue->proto =3D &nvmet_mptcp_proto; +#endif } else { ret =3D -EINVAL; goto out_free_queue; diff --git a/include/net/mptcp.h b/include/net/mptcp.h index aef2dbeb847b..bf74dedc578d 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -233,6 +233,12 @@ static inline __be32 mptcp_reset_option(const struct s= k_buff *skb) } =20 void mptcp_active_detect_blackhole(struct sock *sk, bool expired); + +void mptcp_sock_no_linger(struct sock *sk); + +void mptcp_sock_set_priority(struct sock *sk, u32 priority); + +void mptcp_sock_set_tos(struct sock *sk); #else =20 static inline void mptcp_init(void) @@ -319,6 +325,12 @@ static inline struct request_sock *mptcp_subflow_reqsk= _alloc(const struct reques static inline __be32 mptcp_reset_option(const struct sk_buff *skb) { retu= rn htonl(0u); } =20 static inline void mptcp_active_detect_blackhole(struct sock *sk, bool exp= ired) { } + +static inline void mptcp_sock_no_linger(struct sock *sk) { } + +static inline void mptcp_sock_set_priority(struct sock *sk, u32 priority) = { } + +static inline void mptcp_sock_set_tos(struct sock *sk) { } #endif /* CONFIG_MPTCP */ =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 87b5796d0135..359b1eb2d0a9 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1662,3 +1662,82 @@ int mptcp_set_rcvlowat(struct sock *sk, int val) } return 0; } + +void mptcp_sock_no_linger(struct sock *sk) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + struct sock *ssk; + + lock_sock(sk); + sockopt_seq_inc(msk); + WRITE_ONCE(sk->sk_lingertime, 0); + sock_set_flag(sk, SOCK_LINGER); + mptcp_for_each_subflow(msk, subflow) { + ssk =3D mptcp_subflow_tcp_sock(subflow); + if (ssk) { + lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + WRITE_ONCE(ssk->sk_lingertime, 0); + sock_set_flag(ssk, SOCK_LINGER); + release_sock(ssk); + } + } + release_sock(sk); +} +EXPORT_SYMBOL(mptcp_sock_no_linger); + +void mptcp_sock_set_priority(struct sock *sk, u32 priority) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + struct sock *ssk; + + lock_sock(sk); + sockopt_seq_inc(msk); + sock_set_priority(sk, priority); + mptcp_for_each_subflow(msk, subflow) { + ssk =3D mptcp_subflow_tcp_sock(subflow); + if (ssk) { + lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + sock_set_priority(ssk, priority); + release_sock(ssk); + } + } + release_sock(sk); +} +EXPORT_SYMBOL(mptcp_sock_set_priority); + +static void __mptcp_sock_set_tos(struct sock *sk, int val) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + struct sock *ssk; + + lock_sock(sk); + sockopt_seq_inc(msk); + __ip_sock_set_tos(sk, val); + mptcp_for_each_subflow(msk, subflow) { + ssk =3D mptcp_subflow_tcp_sock(subflow); + if (ssk) { + lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + __ip_sock_set_tos(ssk, val); + release_sock(ssk); + } + } + release_sock(sk); +} + +void mptcp_sock_set_tos(struct sock *sk) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + int val =3D 0; + + lock_sock(sk); + if (msk->first) + val =3D inet_sk(msk->first)->rcv_tos; + release_sock(sk); + + if (val > 0) + __mptcp_sock_set_tos(sk, val); +} +EXPORT_SYMBOL(mptcp_sock_set_tos); --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B1C542C3259; Thu, 28 May 2026 03:11:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937908; cv=none; b=sDz7Fb+GLdsB7mTDljZJ8JPVSA4Nf19du0AS++YnOvszwJ24W+CZNf9SKxLhsT/ix0EXuVyVMfd/WL7TSpzyZsLPyUOSomQXA6szyZgk/lhtECNoapyv7H0jL7uEw7B6Dmv6242WulxX8z0gE0ze3+T8kM+cEbds79Sveel4eKY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937908; c=relaxed/simple; bh=R++BFsDYqoN45G4VPN/MEPg83HDSC1/RgrcnZkwmN+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X9Rd8pdfJh1EmVPMPq+RI34jxOLr4lGFMECL22WUZtXPEY2wSnqeDzEDlXR43WtzrW3ixDlfmomBYgKTRZFr6tBU3bR4zbC5W+bN+kWVmFMUc+UrizCBBJdBSoY/MGwCRYTTi0a9nOtCNOHR3sdKS5kjdYiMYD+TOyXhstRwffk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kwj/AfZB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kwj/AfZB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CF831F000E9; Thu, 28 May 2026 03:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937907; bh=syMmlg+JD2nqzhG8uZF0dK37U+gNHucnr241k0jXdP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kwj/AfZBJ757bJtFH6WyL4zOdpKKFBchHHXONEy8CtC+MbLScB3LDRtLf1ijVmHwy KaBFgvupu6KuM3iVxoPL7zS+grgolZzqdcTI9UVfzj/hJ2kQuuHSUFY4PswXMtPQyp QZzBdoJh39+ujdwwY+7UEgEJSIeEf8gHZR3GHVUsh09qHg2mltkZo+4TlhE3UMfqQf tNBB9jQ3fhkLLLcQ6hbmzQohW0Yck5m6TSsKDv1nruh7gIwnZTgCfrqGYdhR49uDRj TWJJq6k4XXyQQrlQoa82MKOPNR+b+9ihj/JUquikAwI6k3aUf3owBSM3WP5jWdTuQN K7sMUQclMCzzg== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 03/11] nvmet-tcp: define listen socket ops Date: Thu, 28 May 2026 11:10:37 +0800 Message-ID: X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang To support MPTCP on the target side, the listen socket needs to pass IPPROTO_MPTCP to sock_create() for MPTCP ports, and use MPTCP-specific setsockopt functions. This patch adds struct nvmet_tcp_proto_ops to hold listen socket protocol operations (protocol, set_reuseaddr, set_nodelay, set_priority). A TCP version is defined and used for TCP ports. v2: - use trtype instead of tsas (Hannes). v3: - check mptcp protocol from disc_addr.trtype instead of passing a parameter (Hannes). v4: - check CONFIG_MPTCP. v5: - define nvmet_tcp_proto struct. - add a pointer to this structure in nvmet_tcp_port. v6: - split nvmet_tcp_proto struct into two structs, nvmet_tcp_proto and nvmet_tcp_proto_ops, one for the accept socket, the other for the liston socket. - add a pointer to nvmet_tcp_proto struct in nvmet_tcp_queue. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/target/tcp.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 16f153a9772b..83fe001fc619 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -2087,8 +2087,23 @@ static void nvmet_tcp_listen_data_ready(struct sock = *sk) read_unlock_bh(&sk->sk_callback_lock); } =20 +struct nvmet_tcp_proto_ops { + int protocol; + void (*set_reuseaddr)(struct sock *sk); + void (*set_nodelay)(struct sock *sk); + void (*set_priority)(struct sock *sk, u32 priority); +}; + +static const struct nvmet_tcp_proto_ops nvmet_tcp_proto_ops =3D { + .protocol =3D IPPROTO_TCP, + .set_reuseaddr =3D sock_set_reuseaddr, + .set_nodelay =3D tcp_sock_set_nodelay, + .set_priority =3D sock_set_priority, +}; + static int nvmet_tcp_add_port(struct nvmet_port *nport) { + const struct nvmet_tcp_proto_ops *ops; struct nvmet_tcp_port *port; __kernel_sa_family_t af; int ret; @@ -2111,6 +2126,13 @@ static int nvmet_tcp_add_port(struct nvmet_port *npo= rt) goto err_port; } =20 + if (nport->disc_addr.trtype =3D=3D NVMF_TRTYPE_TCP) { + ops =3D &nvmet_tcp_proto_ops; + } else { + ret =3D -EINVAL; + goto err_port; + } + ret =3D inet_pton_with_scope(&init_net, af, nport->disc_addr.traddr, nport->disc_addr.trsvcid, &port->addr); if (ret) { @@ -2125,7 +2147,7 @@ static int nvmet_tcp_add_port(struct nvmet_port *npor= t) port->nport->inline_data_size =3D NVMET_TCP_DEF_INLINE_DATA_SIZE; =20 ret =3D sock_create(port->addr.ss_family, SOCK_STREAM, - IPPROTO_TCP, &port->sock); + ops->protocol, &port->sock); if (ret) { pr_err("failed to create a socket\n"); goto err_port; @@ -2134,10 +2156,10 @@ static int nvmet_tcp_add_port(struct nvmet_port *np= ort) port->sock->sk->sk_user_data =3D port; port->data_ready =3D port->sock->sk->sk_data_ready; port->sock->sk->sk_data_ready =3D nvmet_tcp_listen_data_ready; - sock_set_reuseaddr(port->sock->sk); - tcp_sock_set_nodelay(port->sock->sk); + ops->set_reuseaddr(port->sock->sk); + ops->set_nodelay(port->sock->sk); if (so_priority > 0) - sock_set_priority(port->sock->sk, so_priority); + ops->set_priority(port->sock->sk, so_priority); =20 ret =3D kernel_bind(port->sock, (struct sockaddr_unsized *)&port->addr, sizeof(port->addr)); --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 A19822EE262; Thu, 28 May 2026 03:11:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937916; cv=none; b=Dv4vlm3ee7qZf28YA1MrKlL8LTg9WF9paXnt/TZ2d5uxlyHw0G02Z+B2YcAwzewYIX8Ji5z6LbntED5veW5YwOpRxIBTVkINHn1N+wY+iCjWiX9JNAF1HJVXSu6FTuSf4loDeXSKPmNC4kGURhO6E5qVN3PPNeDP3obFSVzIitc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937916; c=relaxed/simple; bh=arqqSf385H1LtuKqMqaGUKAzC7Y6zn5AWOZbW8EIfgo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QqaOkRnzSZMyHsZuWEKwZP0DItlmDzcLbgyB4imh6edZsm9ocgArMjFYBW322quQd0IXoUPr6XJ73iXgoP4fgPueUNFwxGW/PsfcaJOCsEencHJm0z7dOUNYXuMyDJ9XeHeIgqn3PSRaMj2XJP+ZwrvfOzQRjF0m+R+/2gcYhxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=K1b32Q2K; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="K1b32Q2K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E1B511F00A3A; Thu, 28 May 2026 03:11:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937915; bh=Q1AQ8w8xZnKth/C1FC0s94Oku0WUQ21SRaKh+tq6vys=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=K1b32Q2Kf91771Loe2KCem565qodyrmBwRqV2nX2enZxad5K6WJeVWA0mDKcCtAOS M9uKpK+h4w8twx60nxAlJxiPWxO4EYDOeZV8EOeR6++8mBTVmXK7yIL6FaeUswopbu 0RTFqvBpLJhnVVKAJWtkypWqFgkQlCClh94jlxRN0MdIIyxfiYACzroHRyTG3C4qgI v6sRoVxGqp5KWY8iEL+xPCXyfgbvTPQHR5YbKJ9Kxwd2K/ZWJu4CgTUWc1OoTOlGB0 DYs6XbSRpqLIqUZhOdHsRSBTC3fq3zBjD8mp98BNc3J4QMQXSgyWmKOo7JJ3q7Ucty W3yHOVnoJL9Tw== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 04/11] nvmet-tcp: register target mptcp transport Date: Thu, 28 May 2026 11:10:38 +0800 Message-ID: <683214b4c1a396d305056e3f4db77fdd0ef4fc0f.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch adds a new nvme target transport type NVMF_TRTYPE_MPTCP for MPTCP. And defines a new nvmet_fabrics_ops named nvmet_mptcp_ops, which is almost the same as nvmet_tcp_ops except .type. It is registered in nvmet_tcp_init() and unregistered in nvmet_tcp_exit(). A MODULE_ALIAS for "nvmet-transport-4" is also added. Note: NVMF_TRTYPE_MPTCP is temporarily assigned 4, a value currently reserved in the NVMe over Fabrics specification. During "NVMe over MPTCP" discussion at the LSF/MM/BPF 2026 conference, it was concluded that MPTCP should be treated as a new transport type, rather than a TCP variant. A request will be submitted to the NVMe working group to officially allocate this value for MPTCP. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/target/configfs.c | 1 + drivers/nvme/target/tcp.c | 29 +++++++++++++++++++++++++++++ include/linux/nvme.h | 1 + 3 files changed, 31 insertions(+) diff --git a/drivers/nvme/target/configfs.c b/drivers/nvme/target/configfs.c index b88f897f06e2..51fc0f4d0c32 100644 --- a/drivers/nvme/target/configfs.c +++ b/drivers/nvme/target/configfs.c @@ -37,6 +37,7 @@ static struct nvmet_type_name_map nvmet_transport[] =3D { { NVMF_TRTYPE_RDMA, "rdma" }, { NVMF_TRTYPE_FC, "fc" }, { NVMF_TRTYPE_TCP, "tcp" }, + { NVMF_TRTYPE_MPTCP, "mptcp" }, { NVMF_TRTYPE_PCI, "pci" }, { NVMF_TRTYPE_LOOP, "loop" }, }; diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index 83fe001fc619..e2f3de364c2b 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -2299,6 +2299,23 @@ static const struct nvmet_fabrics_ops nvmet_tcp_ops = =3D { .host_traddr =3D nvmet_tcp_host_port_addr, }; =20 +#ifdef CONFIG_MPTCP +static bool nvmet_mptcp_registered; + +static const struct nvmet_fabrics_ops nvmet_mptcp_ops =3D { + .owner =3D THIS_MODULE, + .type =3D NVMF_TRTYPE_MPTCP, + .msdbd =3D 1, + .add_port =3D nvmet_tcp_add_port, + .remove_port =3D nvmet_tcp_remove_port, + .queue_response =3D nvmet_tcp_queue_response, + .delete_ctrl =3D nvmet_tcp_delete_ctrl, + .install_queue =3D nvmet_tcp_install_queue, + .disc_traddr =3D nvmet_tcp_disc_port_addr, + .host_traddr =3D nvmet_tcp_host_port_addr, +}; +#endif + static int __init nvmet_tcp_init(void) { int ret; @@ -2312,6 +2329,11 @@ static int __init nvmet_tcp_init(void) if (ret) goto err; =20 +#ifdef CONFIG_MPTCP + if (!nvmet_register_transport(&nvmet_mptcp_ops)) + nvmet_mptcp_registered =3D true; +#endif + return 0; err: destroy_workqueue(nvmet_tcp_wq); @@ -2322,6 +2344,10 @@ static void __exit nvmet_tcp_exit(void) { struct nvmet_tcp_queue *queue; =20 +#ifdef CONFIG_MPTCP + if (nvmet_mptcp_registered) + nvmet_unregister_transport(&nvmet_mptcp_ops); +#endif nvmet_unregister_transport(&nvmet_tcp_ops); =20 flush_workqueue(nvmet_wq); @@ -2341,3 +2367,6 @@ module_exit(nvmet_tcp_exit); MODULE_DESCRIPTION("NVMe target TCP transport driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("nvmet-transport-3"); /* 3 =3D=3D NVMF_TRTYPE_TCP */ +#ifdef CONFIG_MPTCP +MODULE_ALIAS("nvmet-transport-4"); /* 4 =3D=3D NVMF_TRTYPE_MPTCP */ +#endif diff --git a/include/linux/nvme.h b/include/linux/nvme.h index 041f30931a90..0eada1e0c652 100644 --- a/include/linux/nvme.h +++ b/include/linux/nvme.h @@ -68,6 +68,7 @@ enum { NVMF_TRTYPE_RDMA =3D 1, /* RDMA */ NVMF_TRTYPE_FC =3D 2, /* Fibre Channel */ NVMF_TRTYPE_TCP =3D 3, /* TCP/IP */ + NVMF_TRTYPE_MPTCP =3D 4, /* Multipath TCP */ NVMF_TRTYPE_LOOP =3D 254, /* Reserved for host usage */ NVMF_TRTYPE_MAX, }; --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 03E3E2EE262; Thu, 28 May 2026 03:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937923; cv=none; b=Zs/d7lbmU6BDBCxTrSBODnHK2aZs621OKX49RLlAjkWh7nQjJqBHbTMSMuf1qwspq/ezFsawPgAwO9RcoF5VdSEEIj8nVFhRuY0lVmW9/puK0k/9IrbcTLOwsa26x+v9LcXEHZm57P6zTErkWBKaPrnJ6VZ+O9DXewvG/4td2kg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937923; c=relaxed/simple; bh=9sHaBalzKBamUnYFmIzzwwt8Xktx1D4KSvzdB1bXi9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XFxAwlKMnzSFI4Ljurua45VeuXRBV6beM3ywxlXPw13amxwLpsnGaljfdoRlNK9TdE52y6cteGmGeH86o8IrQYVj3HMPS2H1gX3dqJFhNKc51qtponDMKKgtq6GIwjKqnWQh3GnyVD1v/GdlSZa4rXL8DKuo8LC7jQmas3N9tDI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RyXvSfqj; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RyXvSfqj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7C321F000E9; Thu, 28 May 2026 03:11:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937921; bh=1F+n6ooRADX4UcHNc88FEQmlqLp1hzczA9EGmgpkhas=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RyXvSfqjQR3yaBYapgKPN2MlrEdRFvbzjZz0Gs+qCb155kgDneU/17hSVst4mdyzU INjV7ejl9VLE7WNENyB/l3j8DkcWm0t5sEabaPH+caic2Jdg3h5GMay5/+7jlwm5oA PpfBcynj/NNQp/qRH46JNCKJtUgA0ZQVUIbvBAtW+lNb+Onx3ddTrHFH6svpNewvsR Ot+reu2pdSqPo6udjEeclcj3BBPBhOGwKsOAT44RcLvnS33qLpQhR76/1mAjOMn8ks lgKmBj3WHdLQeYXX34o1PofWdbJEnxZnnAGEE+k3+r3CMD9x1KSZeKvRx0KLWdSR96 duEIpCVg4ftlQ== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 05/11] nvmet-tcp: implement mptcp listen socket ops Date: Thu, 28 May 2026 11:10:39 +0800 Message-ID: <94d8286242b894e8bc9a9a3391c4d3db778f96c0.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang An MPTCP-specific version of struct nvmet_tcp_proto_ops is implemented for listen sockets. It is assigned to port->proto_ops when the transport type is MPTCP. Dedicated MPTCP helpers are introduced for setting listen socket options. The set_nodelay and set_priority helpers set the values on all existing subflows using mptcp_for_each_subflow(). The set_reuseaddr helper only applies to the first subflow. The values are then synchronized to other newly created subflows in sync_socket_options(). Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/target/tcp.c | 13 ++++++++++++ include/net/mptcp.h | 8 ++++++++ net/mptcp/sockopt.c | 42 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/drivers/nvme/target/tcp.c b/drivers/nvme/target/tcp.c index e2f3de364c2b..8c2dc4bcbcd3 100644 --- a/drivers/nvme/target/tcp.c +++ b/drivers/nvme/target/tcp.c @@ -2101,6 +2101,15 @@ static const struct nvmet_tcp_proto_ops nvmet_tcp_pr= oto_ops =3D { .set_priority =3D sock_set_priority, }; =20 +#ifdef CONFIG_MPTCP +static const struct nvmet_tcp_proto_ops nvmet_mptcp_proto_ops =3D { + .protocol =3D IPPROTO_MPTCP, + .set_reuseaddr =3D mptcp_sock_set_reuseaddr, + .set_nodelay =3D mptcp_sock_set_nodelay, + .set_priority =3D mptcp_sock_set_priority, +}; +#endif + static int nvmet_tcp_add_port(struct nvmet_port *nport) { const struct nvmet_tcp_proto_ops *ops; @@ -2128,6 +2137,10 @@ static int nvmet_tcp_add_port(struct nvmet_port *npo= rt) =20 if (nport->disc_addr.trtype =3D=3D NVMF_TRTYPE_TCP) { ops =3D &nvmet_tcp_proto_ops; +#ifdef CONFIG_MPTCP + } else if (nport->disc_addr.trtype =3D=3D NVMF_TRTYPE_MPTCP) { + ops =3D &nvmet_mptcp_proto_ops; +#endif } else { ret =3D -EINVAL; goto err_port; diff --git a/include/net/mptcp.h b/include/net/mptcp.h index bf74dedc578d..b8ab214a7890 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -239,6 +239,10 @@ void mptcp_sock_no_linger(struct sock *sk); void mptcp_sock_set_priority(struct sock *sk, u32 priority); =20 void mptcp_sock_set_tos(struct sock *sk); + +void mptcp_sock_set_reuseaddr(struct sock *sk); + +void mptcp_sock_set_nodelay(struct sock *sk); #else =20 static inline void mptcp_init(void) @@ -331,6 +335,10 @@ static inline void mptcp_sock_no_linger(struct sock *s= k) { } static inline void mptcp_sock_set_priority(struct sock *sk, u32 priority) = { } =20 static inline void mptcp_sock_set_tos(struct sock *sk) { } + +static inline void mptcp_sock_set_reuseaddr(struct sock *sk) { } + +static inline void mptcp_sock_set_nodelay(struct sock *sk) { } #endif /* CONFIG_MPTCP */ =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 359b1eb2d0a9..0adbbe568f6e 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1596,6 +1596,8 @@ static void sync_socket_options(struct mptcp_sock *ms= k, struct sock *ssk) inet_assign_bit(FREEBIND, ssk, inet_test_bit(FREEBIND, sk)); inet_assign_bit(BIND_ADDRESS_NO_PORT, ssk, inet_test_bit(BIND_ADDRESS_NO_= PORT, sk)); WRITE_ONCE(inet_sk(ssk)->local_port_range, READ_ONCE(inet_sk(sk)->local_p= ort_range)); + + ssk->sk_reuse =3D sk->sk_reuse; } =20 void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk) @@ -1741,3 +1743,43 @@ void mptcp_sock_set_tos(struct sock *sk) __mptcp_sock_set_tos(sk, val); } EXPORT_SYMBOL(mptcp_sock_set_tos); + +void mptcp_sock_set_reuseaddr(struct sock *sk) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct sock *ssk; + + lock_sock(sk); + sockopt_seq_inc(msk); + sk->sk_reuse =3D SK_CAN_REUSE; + ssk =3D __mptcp_nmpc_sk(msk); + if (IS_ERR(ssk)) + goto unlock; + lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + ssk->sk_reuse =3D SK_CAN_REUSE; + release_sock(ssk); +unlock: + release_sock(sk); +} +EXPORT_SYMBOL(mptcp_sock_set_reuseaddr); + +void mptcp_sock_set_nodelay(struct sock *sk) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + struct sock *ssk; + + lock_sock(sk); + sockopt_seq_inc(msk); + msk->nodelay =3D true; + mptcp_for_each_subflow(msk, subflow) { + ssk =3D mptcp_subflow_tcp_sock(subflow); + if (ssk) { + lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + __tcp_sock_set_nodelay(ssk, true); + release_sock(ssk); + } + } + release_sock(sk); +} +EXPORT_SYMBOL(mptcp_sock_set_nodelay); --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B909425F7B9; Thu, 28 May 2026 03:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937930; cv=none; b=tqkO0FVhm8V8CXLbVqf4cOb9B+aGaJ9pdlYMyf/CqTwZdyWGvSVDjL2/JZODnvCwajxB/3ji4b+KHVRuRQgvC+5xU+Caaea4re6q0zx6MGUx17sj2TiPujSWGARL8xJYQpzD6uFR9bcRcy7y2YjHsxGdYzw665uFXG451Bkx34g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937930; c=relaxed/simple; bh=x5lvd2WieVYFnrOyxhQZQmbBnp68/R28p7d+i8k0jBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QYEyRHYA2d9LUY9K5RC+UVtV8drc4MrReeMDQVLUoIFdpAvtTzBWPEkQQiwkDCOHvs9Qcr6gO2Za8Rian2b1K+kDQrFSv+wot2ziN7WQ3VoCO8c/looyxdGfaGBQ6OvOapMWA4Re+EkV0I+dfKEWA2tjuFnh+iNu0hhHjkBx//I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l5Z84dXJ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l5Z84dXJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F3841F00A3A; Thu, 28 May 2026 03:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937929; bh=1BY3fIUX8gmKju1y5veWjmaxgiak/EkCD3JD09YnoAM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l5Z84dXJwZHwM8LCJ5dq+U73AaYLFztuK9cmtaW1jlZREj3nwjCvjF4sShtwV6O6c Tgg/MlMajgZi2b7Cz3+wrk7OYrR2evwR0/SOlpJADHsMpjdwHsqukan7bDUai5ugQn tfEVkaoSmzKeEcts1aAQ1qtgXax1E/XYsfuobOUVSFYy+KLG6C3WzbtPIWPWCXPRSs +1bmlYKcq+Igioln952z7zpRSMDUXV9HylVnUoOpHKcn9a8cbY/1mGWxRTelKQCZX6 foAOTqjNORZ9N6/x7IIsoMGE05f4cvb0PfOLCs9/NT7Ht3CvL3fxP3CEYYtoCQL6tj TdqI0kPFMQ5xA== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 06/11] nvme-fabrics: compare transport in ip_options_match Date: Thu, 28 May 2026 11:10:40 +0800 Message-ID: <148800f6002bae1448d8dfc279f2e22f0851ee03.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang When checking for an existing controller, nvmf_ip_options_match() does not compare the transport type. This can cause a TCP connection request to incorrectly match an existing MPTCP controller, or an MPTCP connection request to match an existing TCP controller, resulting in a false -EALREADY error. Fix this by adding strcmp(opts->transport, ctrl->opts->transport) to the matching condition. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/host/fabrics.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index ac3d4f400601..e086e61e8f94 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -1220,6 +1220,7 @@ bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, struct nvmf_ctrl_options *opts) { if (!nvmf_ctlr_matches_baseopts(ctrl, opts) || + strcmp(opts->transport, ctrl->opts->transport) || strcmp(opts->traddr, ctrl->opts->traddr) || strcmp(opts->trsvcid, ctrl->opts->trsvcid)) return false; --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 63CDD309F1D; Thu, 28 May 2026 03:12:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937938; cv=none; b=Aeqs/VF/bX6ZEb8QMrAIs6COCpgfZ8fKwf9fJMQrefAukrimg7glyKV40lmJNqlRc4cVWiJIjhNlKYq5HTI47Q8o9ekFKYLXWZqAXzrtKeCkd/7gGgl0MYKx8IyoUJLrz+blq6PexMJNuCyFaTHUxbN5I/Fuw6v4DoHhfZB1k74= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937938; c=relaxed/simple; bh=qyibQf84OrZGmbumBxVLlkVn7uazkIjjEmP1RKnUKas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P3Ocn9x2w3b5nmytkoZcM/zXI1MigpMvZZI0x749CmtHxyvhcZF4velfL/pjN3A8425/TbQbLV42tOVQF3dQIsh9qMMMidTjLGZbioypOdUfwIyuez+3Egh100W0IUfLgE1W9qrObLl9PCFik7EV8TLiPZo6EHO6h86Sm00s+U0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l7hF2xYR; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l7hF2xYR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC3681F000E9; Thu, 28 May 2026 03:12:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937937; bh=qVPK9yHLQUnhtDVAiuj4V6+2A9N4RXjT24Omrnv2M3c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l7hF2xYRR26i7y2YDqrkGuST/P19ccwDFHoldpOnZiR87Qt+VM5vekpa6TJqwDkt0 /oO0EWt/Zl4C0gWbZgPFX0pxlLGxxca805QmtqmN2qCP7sSeZF9EF0ewIDpjNZE+Oh qgXebpohTbdCbPUfl6bHHwluJZhpbOve8UeNb8sd/FnU+fCguLVSyXW90+tuuWIbzM QrvSI49FRtxNR0X3u7A9Q9yLF9f9qRC3e05Ors+3CkmCPeNXGi3+qBRUdKfT370ctA Zhk0JaKAEoWhhTtI9QWHnAyv8NBX0yEnKRX+4DfX8t4d4vzuc4dGWk/xe5QTXzcEWA bVVw79pkAkyFQ== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 07/11] nvme-tcp: define host tcp_proto struct Date: Thu, 28 May 2026 11:10:41 +0800 Message-ID: <7b784259d81e8457668ceb395c55e09141ce6db5.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang To add MPTCP support in "NVMe over TCP", the host side needs to pass IPPROTO_MPTCP to sock_create_kern() instead of IPPROTO_TCP to create an MPTCP socket. Similar to the target-side nvmet_tcp_proto, this patch defines the host-side nvme_tcp_proto structure, which contains the protocol of the socket and a set of function pointers for socket operations. The only difference is that it defines .set_syncnt instead of .set_reuseaddr. A TCP-specific version of this structure is defined, and a proto field is added to nvme_tcp_ctrl. When the transport string is "tcp", it is assigned to ctrl->proto. All locations that previously called TCP setsockopt functions are updated to call the corresponding function pointers in the nvme_tcp_proto structure. The controller's proto pointer is set during initialization and remains valid throughout the controller's lifetime. v2: - use 'trtype' instead of '--mptcp' (Hannes) v3: - check mptcp protocol from opts->transport instead of passing a parameter (Hannes). v4: - check CONFIG_MPTCP. v5: - define nvme_tcp_proto struct. - add a pointer to this structure in nvme_tcp_ctrl. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/host/tcp.c | 44 ++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 15d36d6a728e..13a5240623ef 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -182,6 +182,16 @@ struct nvme_tcp_queue { void (*write_space)(struct sock *); }; =20 +struct nvme_tcp_proto { + int protocol; + int (*set_syncnt)(struct sock *sk, int val); + void (*set_nodelay)(struct sock *sk); + void (*no_linger)(struct sock *sk); + void (*set_priority)(struct sock *sk, u32 priority); + void (*set_tos)(struct sock *sk, int val); + const struct nvme_ctrl_ops *ops; +}; + struct nvme_tcp_ctrl { /* read only in the hot path */ struct nvme_tcp_queue *queues; @@ -198,6 +208,8 @@ struct nvme_tcp_ctrl { struct delayed_work connect_work; struct nvme_tcp_request async_req; u32 io_queues[HCTX_MAX_TYPES]; + + const struct nvme_tcp_proto *proto; }; =20 static LIST_HEAD(nvme_tcp_ctrl_list); @@ -1799,7 +1811,7 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *nct= rl, int qid, =20 ret =3D sock_create_kern(current->nsproxy->net_ns, ctrl->addr.ss_family, SOCK_STREAM, - IPPROTO_TCP, &queue->sock); + ctrl->proto->protocol, &queue->sock); if (ret) { dev_err(nctrl->device, "failed to create socket: %d\n", ret); @@ -1816,24 +1828,24 @@ static int nvme_tcp_alloc_queue(struct nvme_ctrl *n= ctrl, int qid, nvme_tcp_reclassify_socket(queue->sock); =20 /* Single syn retry */ - tcp_sock_set_syncnt(queue->sock->sk, 1); + ctrl->proto->set_syncnt(queue->sock->sk, 1); =20 /* Set TCP no delay */ - tcp_sock_set_nodelay(queue->sock->sk); + ctrl->proto->set_nodelay(queue->sock->sk); =20 /* * Cleanup whatever is sitting in the TCP transmit queue on socket * close. This is done to prevent stale data from being sent should * the network connection be restored before TCP times out. */ - sock_no_linger(queue->sock->sk); + ctrl->proto->no_linger(queue->sock->sk); =20 if (so_priority > 0) - sock_set_priority(queue->sock->sk, so_priority); + ctrl->proto->set_priority(queue->sock->sk, so_priority); =20 /* Set socket type of service */ if (nctrl->opts->tos >=3D 0) - ip_sock_set_tos(queue->sock->sk, nctrl->opts->tos); + ctrl->proto->set_tos(queue->sock->sk, nctrl->opts->tos); =20 /* Set 10 seconds timeout for icresp recvmsg */ queue->sock->sk->sk_rcvtimeo =3D 10 * HZ; @@ -2900,6 +2912,17 @@ nvme_tcp_existing_controller(struct nvmf_ctrl_option= s *opts) return found; } =20 +static const struct nvme_tcp_proto nvme_tcp_proto =3D { + .protocol =3D IPPROTO_TCP, + .set_syncnt =3D tcp_sock_set_syncnt, + .set_nodelay =3D tcp_sock_set_nodelay, + .no_linger =3D sock_no_linger, + .set_priority =3D sock_set_priority, + .set_tos =3D ip_sock_set_tos, + .ops =3D &nvme_tcp_ctrl_ops, + +}; + static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev, struct nvmf_ctrl_options *opts) { @@ -2964,13 +2987,20 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(st= ruct device *dev, goto out_free_ctrl; } =20 + if (!strcmp(ctrl->ctrl.opts->transport, "tcp")) { + ctrl->proto =3D &nvme_tcp_proto; + } else { + ret =3D -EINVAL; + goto out_free_ctrl; + } + ctrl->queues =3D kzalloc_objs(*ctrl->queues, ctrl->ctrl.queue_count); if (!ctrl->queues) { ret =3D -ENOMEM; goto out_free_ctrl; } =20 - ret =3D nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); + ret =3D nvme_init_ctrl(&ctrl->ctrl, dev, ctrl->proto->ops, 0); if (ret) goto out_kfree_queues; =20 --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 0B6142EA172; Thu, 28 May 2026 03:12:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937947; cv=none; b=JO1Q8u67Z4sz5cLC2ZZsG5fZTAEEsX66WT4/FWUkZ+bHIokADPsugo/6zcCxokI2NN7w7GU0crrjhRvJOLO5lT7jLxgo967C1lc8nu1CAMMY/jScS1k089RcMzr8mhFV64oruUGQgWIStGOF73RVe0OT5oYTqqWPQkUUbvWrKFY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937947; c=relaxed/simple; bh=wX7xyPGvpOD/uMykvG0/GDFv0L2kO/Luf3JNBfF+Y+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BMVpPB2c0Z9Lzs2Gopao82XJR58NJj3GAQfGI3oSimkxGyxzVzADI7xoICkiZdd/QBSUOyWdLAhJaFbGHNaEEGXaAjBYj0ofge0vEhOT1jBdEuUaFG80XS32rcbnFBHe7irBrcx24gwYifKp82KaAbU+cQ8cpOe3w9RQImIr39U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Eu0Lbas1; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Eu0Lbas1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8D64B1F00A3A; Thu, 28 May 2026 03:12:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937944; bh=PmfzOJLp2eLDzqXolgrbZckSWO9kvihV17kP2U2aJr4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Eu0Lbas1S8v4PAQ/6Y1/uvtZPPsWSKxA44gWRW14blfey4mplrAl+AUU2Ea6QS+Gb i74/+x2dZFfUMar+moqr551BpdqSXRY7yMJwbTwwdoDl9sW+iQ4nmFmxLn87iqTxX3 8utJiCIZGgQYY2z3LI3+GLr+/TRJ+glDHDLWtmofiZRak8NIE4/EsXtfanpBKPWmvD aVC4Nruwv8G4oUHHHpr6ZNGG2J27iEtjnuITaqoASmn233NrhDHRm4kHUI97ytUCfI dmlfntJj6De/P4yhcevsCFTKcw/ZqKf48Zr72yP2QnHkv5s8MMEyHKk/j0TJfcgYZz M2PyCXJYKUD+Q== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 08/11] nvme-tcp: register host mptcp transport Date: Thu, 28 May 2026 11:10:42 +0800 Message-ID: <2b0445782439b3fb4801de6a7aa2e06d19c43246.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang This patch defines a new nvmf_transport_ops named nvme_mptcp_transport, which is almost the same as nvme_tcp_transport except .name and .allowed_opts. MPTCP currently does not support TLS. The four TLS-related options (NVMF_OPT_TLS, NVMF_OPT_KEYRING, NVMF_OPT_TLS_KEY, and NVMF_OPT_CONCAT) have been removed from allowed_opts. They will be added back once MPTCP TLS is supported. It is registered in nvme_tcp_init_module() and unregistered in nvme_tcp_cleanup_module(). A MODULE_ALIAS("nvme-mptcp") declaration is added at the end of the file. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/host/tcp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 13a5240623ef..305624d59c50 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -3067,6 +3067,20 @@ static struct nvmf_transport_ops nvme_tcp_transport = =3D { .create_ctrl =3D nvme_tcp_create_ctrl, }; =20 +#ifdef CONFIG_MPTCP +static struct nvmf_transport_ops nvme_mptcp_transport =3D { + .name =3D "mptcp", + .module =3D THIS_MODULE, + .required_opts =3D NVMF_OPT_TRADDR, + .allowed_opts =3D NVMF_OPT_TRSVCID | NVMF_OPT_RECONNECT_DELAY | + NVMF_OPT_HOST_TRADDR | NVMF_OPT_CTRL_LOSS_TMO | + NVMF_OPT_HDR_DIGEST | NVMF_OPT_DATA_DIGEST | + NVMF_OPT_NR_WRITE_QUEUES | NVMF_OPT_NR_POLL_QUEUES | + NVMF_OPT_TOS | NVMF_OPT_HOST_IFACE, + .create_ctrl =3D nvme_tcp_create_ctrl, +}; +#endif + static int __init nvme_tcp_init_module(void) { unsigned int wq_flags =3D WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_SYSFS; @@ -3092,6 +3106,9 @@ static int __init nvme_tcp_init_module(void) atomic_set(&nvme_tcp_cpu_queues[cpu], 0); =20 nvmf_register_transport(&nvme_tcp_transport); +#ifdef CONFIG_MPTCP + nvmf_register_transport(&nvme_mptcp_transport); +#endif return 0; } =20 @@ -3099,6 +3116,9 @@ static void __exit nvme_tcp_cleanup_module(void) { struct nvme_tcp_ctrl *ctrl; =20 +#ifdef CONFIG_MPTCP + nvmf_unregister_transport(&nvme_mptcp_transport); +#endif nvmf_unregister_transport(&nvme_tcp_transport); =20 mutex_lock(&nvme_tcp_ctrl_mutex); @@ -3116,3 +3136,6 @@ module_exit(nvme_tcp_cleanup_module); MODULE_DESCRIPTION("NVMe host TCP transport driver"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("nvme-tcp"); +#ifdef CONFIG_MPTCP +MODULE_ALIAS("nvme-mptcp"); +#endif --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 4782430AD15; Thu, 28 May 2026 03:12:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937952; cv=none; b=BDNBEY+tgV2tlqyyx/ePZ05P96q6Nby+EQ/qDEwVV/oWoA3LDgfUFUvSBDNIuKpQevTrnkXUngqoMssPuk7A09HlSZWX7sLjLkoNEZmJCZnWbbEuiilIbr93HDTtwV6tNAjNvq8fcDUs4MhvBdecAtQxbK6Lm7FmkaA7jtfXdEU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937952; c=relaxed/simple; bh=InhEhwWLDbfGGNuVvp/VPuDmqqpBp19W+QbyizVPGo8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TetvrC4lIrB7Ye58Nk357G5a6S4MUuYqJJitYKvp8N1akkwnwQ2BD2ALms8rvPJnbYsVcXWdsLedtY3wuxPd9rv7zCO5QNNdv0wph3ghR987ZWQBHWPpI36i8KDu4zI4d1Pozj4U/hizNrvjx0Rdvf+aJsB13i2nLK8bm+8KXDk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QP8YeAS4; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QP8YeAS4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11D901F000E9; Thu, 28 May 2026 03:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937951; bh=RbKJjq4aWwXODLoBQ2EcVIURob7IqQdQHIVigwRe+nk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QP8YeAS4fIwzo80dRBc7g3PJYRxnS5eKJbwINn6CQSXFAZl/5RqdfdPOTYwXctYwj va1dX+U58+6w3T7n0Cl3gTZ2y4xGTkW7bBymsckqqVEI/6L/0T6t5h7YfgJM93eoXq KsPAl4wEQqfG7DbsMz+OBAxap59fSJ1mV6XrL4RPWCV9b7kO/lA4geMqCyUsQIQGiF xSwqBo4cxIG5jox+AXaj9QD5js0iphUQ6KQYoO3D15Go+Tyl/ZefWsWmEx7uFCl0XG j5kq/Cex8AuIGfL810sEkZ6SbAfAIvdLB1Vy1nrCKNI5Co/aSl4RZ2Z7DbQq2uGAqG GOV1KW8gGB/Fg== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 09/11] nvme-tcp: implement host mptcp proto Date: Thu, 28 May 2026 11:10:43 +0800 Message-ID: X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang An MPTCP-specific version of struct nvme_tcp_proto is implemented, and it is assigned to ctrl->proto when the transport string is "mptcp". The socket option setting logic is similar to the target side, except that mptcp_sock_set_syncnt is newly defined for the host side. These helpers set the values on all existing subflows of an MPTCP connection, except for set_reuseaddr which only applies to the first subflow. The values are then synchronized to other newly created subflows in sync_socket_options(). A separate nvme_mptcp_ctrl_ops structure with .name =3D "mptcp" is defined and used for MPTCP controllers. "mptcp" is planned to be introduced as a new NVMe transport type into the NVMe Base Specification in the future. Currently, the Discovery Log does not yet recognize trtype=3D4 (MPTCP), and will show "trtype: unrecognized" for such entries: =3D=3D=3D=3D=3DDiscovery Log Entry 0=3D=3D=3D=3D=3D=3D trtype: unrecognized adrfam: ipv4 subtype: current discovery subsystem treq: not specified, sq flow control disable supported portid: 23106 trsvcid: 23601 subnqn: nqn.2014-08.org.nvmexpress.discovery traddr: 10.1.1.1 eflags: none Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- drivers/nvme/host/tcp.c | 34 ++++++++++++++++++++++++++++++++++ include/net/mptcp.h | 11 +++++++++++ net/mptcp/sockopt.c | 30 +++++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 305624d59c50..2388a8c443cc 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -2895,6 +2895,24 @@ static const struct nvme_ctrl_ops nvme_tcp_ctrl_ops = =3D { .get_virt_boundary =3D nvmf_get_virt_boundary, }; =20 +#ifdef CONFIG_MPTCP +static const struct nvme_ctrl_ops nvme_mptcp_ctrl_ops =3D { + .name =3D "mptcp", + .module =3D THIS_MODULE, + .flags =3D NVME_F_FABRICS | NVME_F_BLOCKING, + .reg_read32 =3D nvmf_reg_read32, + .reg_read64 =3D nvmf_reg_read64, + .reg_write32 =3D nvmf_reg_write32, + .subsystem_reset =3D nvmf_subsystem_reset, + .free_ctrl =3D nvme_tcp_free_ctrl, + .submit_async_event =3D nvme_tcp_submit_async_event, + .delete_ctrl =3D nvme_tcp_delete_ctrl, + .get_address =3D nvme_tcp_get_address, + .stop_ctrl =3D nvme_tcp_stop_ctrl, + .get_virt_boundary =3D nvmf_get_virt_boundary, +}; +#endif + static bool nvme_tcp_existing_controller(struct nvmf_ctrl_options *opts) { @@ -2923,6 +2941,18 @@ static const struct nvme_tcp_proto nvme_tcp_proto = =3D { =20 }; =20 +#ifdef CONFIG_MPTCP +static const struct nvme_tcp_proto nvme_mptcp_proto =3D { + .protocol =3D IPPROTO_MPTCP, + .set_syncnt =3D mptcp_sock_set_syncnt, + .set_nodelay =3D mptcp_sock_set_nodelay, + .no_linger =3D mptcp_sock_no_linger, + .set_priority =3D mptcp_sock_set_priority, + .set_tos =3D __mptcp_sock_set_tos, + .ops =3D &nvme_mptcp_ctrl_ops, +}; +#endif + static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(struct device *dev, struct nvmf_ctrl_options *opts) { @@ -2989,6 +3019,10 @@ static struct nvme_tcp_ctrl *nvme_tcp_alloc_ctrl(str= uct device *dev, =20 if (!strcmp(ctrl->ctrl.opts->transport, "tcp")) { ctrl->proto =3D &nvme_tcp_proto; +#ifdef CONFIG_MPTCP + } else if (!strcmp(ctrl->ctrl.opts->transport, "mptcp")) { + ctrl->proto =3D &nvme_mptcp_proto; +#endif } else { ret =3D -EINVAL; goto out_free_ctrl; diff --git a/include/net/mptcp.h b/include/net/mptcp.h index b8ab214a7890..160267e35b13 100644 --- a/include/net/mptcp.h +++ b/include/net/mptcp.h @@ -238,11 +238,15 @@ void mptcp_sock_no_linger(struct sock *sk); =20 void mptcp_sock_set_priority(struct sock *sk, u32 priority); =20 +void __mptcp_sock_set_tos(struct sock *sk, int val); + void mptcp_sock_set_tos(struct sock *sk); =20 void mptcp_sock_set_reuseaddr(struct sock *sk); =20 void mptcp_sock_set_nodelay(struct sock *sk); + +int mptcp_sock_set_syncnt(struct sock *sk, int val); #else =20 static inline void mptcp_init(void) @@ -334,11 +338,18 @@ static inline void mptcp_sock_no_linger(struct sock *= sk) { } =20 static inline void mptcp_sock_set_priority(struct sock *sk, u32 priority) = { } =20 +static inline void __mptcp_sock_set_tos(struct sock *sk, int val) { } + static inline void mptcp_sock_set_tos(struct sock *sk) { } =20 static inline void mptcp_sock_set_reuseaddr(struct sock *sk) { } =20 static inline void mptcp_sock_set_nodelay(struct sock *sk) { } + +static inline int mptcp_sock_set_syncnt(struct sock *sk, int val) +{ + return 0; +} #endif /* CONFIG_MPTCP */ =20 #if IS_ENABLED(CONFIG_MPTCP_IPV6) diff --git a/net/mptcp/sockopt.c b/net/mptcp/sockopt.c index 0adbbe568f6e..7857dac62afc 100644 --- a/net/mptcp/sockopt.c +++ b/net/mptcp/sockopt.c @@ -1598,6 +1598,8 @@ static void sync_socket_options(struct mptcp_sock *ms= k, struct sock *ssk) WRITE_ONCE(inet_sk(ssk)->local_port_range, READ_ONCE(inet_sk(sk)->local_p= ort_range)); =20 ssk->sk_reuse =3D sk->sk_reuse; + if (inet_csk(sk)->icsk_syn_retries > 0) + tcp_sock_set_syncnt(ssk, inet_csk(sk)->icsk_syn_retries); } =20 void mptcp_sockopt_sync_locked(struct mptcp_sock *msk, struct sock *ssk) @@ -1709,7 +1711,7 @@ void mptcp_sock_set_priority(struct sock *sk, u32 pri= ority) } EXPORT_SYMBOL(mptcp_sock_set_priority); =20 -static void __mptcp_sock_set_tos(struct sock *sk, int val) +void __mptcp_sock_set_tos(struct sock *sk, int val) { struct mptcp_sock *msk =3D mptcp_sk(sk); struct mptcp_subflow_context *subflow; @@ -1728,6 +1730,7 @@ static void __mptcp_sock_set_tos(struct sock *sk, int= val) } release_sock(sk); } +EXPORT_SYMBOL(__mptcp_sock_set_tos); =20 void mptcp_sock_set_tos(struct sock *sk) { @@ -1783,3 +1786,28 @@ void mptcp_sock_set_nodelay(struct sock *sk) release_sock(sk); } EXPORT_SYMBOL(mptcp_sock_set_nodelay); + +int mptcp_sock_set_syncnt(struct sock *sk, int val) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + struct sock *ssk; + + if (val < 1 || val > MAX_TCP_SYNCNT) + return -EINVAL; + + lock_sock(sk); + sockopt_seq_inc(msk); + inet_csk(sk)->icsk_syn_retries =3D val; + mptcp_for_each_subflow(msk, subflow) { + ssk =3D mptcp_subflow_tcp_sock(subflow); + if (ssk) { + lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); + tcp_sock_set_syncnt(ssk, val); + release_sock(ssk); + } + } + release_sock(sk); + return 0; +} +EXPORT_SYMBOL(mptcp_sock_set_syncnt); --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 AD3B92EA172; Thu, 28 May 2026 03:12:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937961; cv=none; b=KcVoZJJAllLap4cH2pxyrqV9GElonW6xe7g0rnWwmacC+XEox7PFkjqhKS8V0hh513waXxM7FrusGML4y6ysZB48zadgteF9v/+VP8UM8nvyFI7HUNYMMEoTagpla+YVLJnPDB/NdVWk4KgIiOGszxMOD7MK1eE5fOYsJBJCiO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937961; c=relaxed/simple; bh=sf61uxk63D01Q3MAkUWNDamhBPyWgx2sOEyadYaJBRA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cd/HDfz11W19CeuUr3Uoejrmf7Daey2jM+xRE+V4c8514HsDM1YWZtP/hDJ3vxjf8yTxEqXVUKriO1WibyltXHi2nU+bFy0xLZHDCKfDrCJub4ApHmb6g/B+eW30chtW2OztAgaBXFDJ8Ak2i9Bk0suRTuHb3qhH0BQSJjMFGI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=jfZcZaK3; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jfZcZaK3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A24761F00A3A; Thu, 28 May 2026 03:12:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937959; bh=X8P7GTkuXAPaVRxKv5xYTCC9g55wmFj/P0mjoLQc7GI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jfZcZaK320BXXBcEP9/C0gIQk2/GjUKvxQFJCanDywu0D8urfH6ymh6j0klmGa7BB UTKQveCaBrlZNH9ead2ZzryN+b2LAtrb3gLmkGcpGXj7zPgM2YcrpwOEcAC5VZFtpy uQAht0lGTY5UbCvRr3M8oxB57iFyBnGmhRUcByuhpPWk/DkIQIXObAGViUk75ZZaaG u11Urb8cMPkHjO3pkRBGcQNfu4s+/lzcYdu5XSWKzeQzbUXC+Ms3cYbcVdNIKKLA/V a3TqWqHJhctIx4VebsqSQNeW0mmzf9Kxgd3/phn+KM32X0g0b1exifeJjgUak1o0EH Ixg/vWq8HJQGQ== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 10/11] selftests: mptcp: add nvme over mptcp test Date: Thu, 28 May 2026 11:10:44 +0800 Message-ID: <6cd098ba688fb8b761f00b7e03fd0459b4fe8ac1.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang A test case for NVMe over MPTCP has been implemented. It verifies the proper functionality of nvme discover and connect commands to establish NVMe over MPTCP connections. The test then evaluates read/write performance using fio, and ensures proper cleanup with nvme disconnect. This script accepts two positional parameters: trtype - Transport type (mptcp|tcp). Default: mptcp path - Number of multipath (1-4). Default: 1 This test simulates four NICs on both target and host sides, each limited to 125MB/s. It shows that 'NVMe over MPTCP' delivered bandwidth up to four times that of standard TCP with a single NVMe multipath configuration: # ./mptcp_nvme.sh tcp READ: bw=3D112MiB/s (118MB/s), 112MiB/s-112MiB/s (118MB/s-118MB/s), io=3D1123MiB (1177MB), run=3D10018-10018msec WRITE: bw=3D112MiB/s (117MB/s), 112MiB/s-112MiB/s (117MB/s-117MB/s), io=3D1118MiB (1173MB), run=3D10018-10018msec # ./mptcp_nvme.sh mptcp READ: bw=3D427MiB/s (448MB/s), 427MiB/s-427MiB/s (448MB/s-448MB/s), io=3D4286MiB (4494MB), run=3D10039-10039msec WRITE: bw=3D387MiB/s (406MB/s), 387MiB/s-387MiB/s (406MB/s-406MB/s), io=3D3885MiB (4073MB), run=3D10043-10043msec It reflects that MPTCP has the same multi-interface bandwidth aggregation capability as NVMe multipath. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- tools/testing/selftests/net/mptcp/Makefile | 1 + tools/testing/selftests/net/mptcp/config | 8 + .../testing/selftests/net/mptcp/mptcp_lib.sh | 12 + .../testing/selftests/net/mptcp/mptcp_nvme.sh | 329 ++++++++++++++++++ 4 files changed, 350 insertions(+) create mode 100755 tools/testing/selftests/net/mptcp/mptcp_nvme.sh diff --git a/tools/testing/selftests/net/mptcp/Makefile b/tools/testing/sel= ftests/net/mptcp/Makefile index 22ba0da2adb8..7b308447a58b 100644 --- a/tools/testing/selftests/net/mptcp/Makefile +++ b/tools/testing/selftests/net/mptcp/Makefile @@ -13,6 +13,7 @@ TEST_PROGS :=3D \ mptcp_connect_sendfile.sh \ mptcp_connect_splice.sh \ mptcp_join.sh \ + mptcp_nvme.sh \ mptcp_sockopt.sh \ pm_netlink.sh \ simult_flows.sh \ diff --git a/tools/testing/selftests/net/mptcp/config b/tools/testing/selft= ests/net/mptcp/config index 59051ee2a986..e59cf7398f19 100644 --- a/tools/testing/selftests/net/mptcp/config +++ b/tools/testing/selftests/net/mptcp/config @@ -34,3 +34,11 @@ CONFIG_NFT_SOCKET=3Dm CONFIG_NFT_TPROXY=3Dm CONFIG_SYN_COOKIES=3Dy CONFIG_VETH=3Dy +CONFIG_BLK_DEV_LOOP=3Dy +CONFIG_CONFIGFS_FS=3Dy +CONFIG_NVME_CORE=3Dy +CONFIG_NVME_FABRICS=3Dy +CONFIG_NVME_TCP=3Dy +CONFIG_NVME_TARGET=3Dy +CONFIG_NVME_TARGET_TCP=3Dy +CONFIG_NVME_MULTIPATH=3Dy diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing= /selftests/net/mptcp/mptcp_lib.sh index 5ef6033775c8..e08854ba42bd 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh @@ -530,6 +530,18 @@ mptcp_lib_check_tools() { exit ${KSFT_SKIP} fi ;; + "nvme") + if ! nvme --version &> /dev/null; then + mptcp_lib_pr_skip "nvme tool not found" + exit ${KSFT_SKIP} + fi + ;; + "fio") + if ! fio -h &> /dev/null; then + mptcp_lib_pr_skip "fio tool not found" + exit ${KSFT_SKIP} + fi + ;; *) mptcp_lib_pr_fail "Internal error: unsupported tool: ${tool}" exit ${KSFT_FAIL} diff --git a/tools/testing/selftests/net/mptcp/mptcp_nvme.sh b/tools/testin= g/selftests/net/mptcp/mptcp_nvme.sh new file mode 100755 index 000000000000..5b1133dbc2d5 --- /dev/null +++ b/tools/testing/selftests/net/mptcp/mptcp_nvme.sh @@ -0,0 +1,329 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +. "$(dirname "$0")/mptcp_lib.sh" + +ret=3D0 +trtype=3D"${1:-mptcp}" +path=3D"${2:-1}" +nqn=3D"nqn.2014-08.org.nvmexpress.${trtype}dev.$$.${RANDOM}" +ns=3D1 +port=3D$((RANDOM % 10000 + 20000)) +trsvcid=3D$((RANDOM % 64512 + 1024)) +ns1=3D"" +ns2=3D"" +temp_file=3D"" +loop_dev=3D"" + +export trtype path nqn ns port trsvcid +export loop_dev temp_file + +usage() +{ + cat << EOF + +Usage: + + $(basename "$0") [trtype] [path] + + trtype Transport type (tcp|mptcp) - default: mptcp + path Number of multipath (1-4) - default: 1 + +EOF +exit ${KSFT_FAIL} +} + +validate_params() +{ + if [[ ! "${trtype}" =3D~ ^(tcp|mptcp)$ ]]; then + echo "Invalid trtype ${trtype}. Must be tcp or mptcp" + usage + fi + + if [[ ! "${path}" =3D~ ^[1-4]$ ]]; then + echo "Invalid path count ${path}. Must be between 1 and 4" + usage + fi +} + +# This function is invoked indirectly +#shellcheck disable=3DSC2317,SC2329 +ns1_cleanup() +{ + pushd /sys/kernel/config/nvmet || exit 1 + + for i in $(seq 1 "${path}"); do + local portdir=3D$((port + i)) + + rm -rf "ports/${portdir}/subsystems/${nqn}" + rmdir "ports/${portdir}" + done + + echo 0 > "subsystems/${nqn}/namespaces/${ns}/enable" + rmdir "subsystems/${nqn}/namespaces/${ns}" + rmdir "subsystems/${nqn}" + + popd || exit 1 +} + +# This function is invoked indirectly +#shellcheck disable=3DSC2317,SC2329 +ns2_cleanup() +{ + nvme disconnect -n "${nqn}" || true +} + +# This function is used in the cleanup trap +#shellcheck disable=3DSC2317,SC2329 +cleanup() +{ + if ! ip netns exec "$ns2" bash <<- EOF + $(declare -f ns2_cleanup) + ns2_cleanup + EOF + then + echo "ns2_cleanup failed" >&2 + fi + + sleep 1 + + if ! ip netns exec "$ns1" unshare -m bash <<- EOF + mount -t configfs none /sys/kernel/config + $(declare -f ns1_cleanup) + ns1_cleanup + EOF + then + echo "ns1_cleanup failed" >&2 + fi + + if [ -n "${loop_dev}" ] && [ -b "${loop_dev}" ]; then + losetup -d "${loop_dev}" 2>/dev/null || true + fi + rm -rf "${temp_file}" + + mptcp_lib_ns_exit "$ns1" "$ns2" + + unset -v trtype path nqn ns port trsvcid + unset -v loop_dev temp_file +} + +# $tc_args needs word splitting to pass multiple arguments to netem +# shellcheck disable=3DSC2086 +init() +{ + local tc_args=3D"rate 1000mbit" + + mptcp_lib_ns_init ns1 ns2 + + # ns1 ns2 + # 10.1.1.1 10.1.1.2 + # 10.1.2.1 10.1.2.2 + # 10.1.3.1 10.1.3.2 + # 10.1.4.1 10.1.4.2 + for i in {1..4}; do + ip link add ns1eth"$i" netns "$ns1" type veth peer \ + name ns2eth"$i" netns "$ns2" + ip -net "$ns1" addr add 10.1."$i".1/24 dev ns1eth"$i" + ip -net "$ns1" addr add dead:beef:"$i"::1/64 \ + dev ns1eth"$i" nodad + ip -net "$ns1" link set ns1eth"$i" up + ip -net "$ns2" addr add 10.1."$i".2/24 dev ns2eth"$i" + ip -net "$ns2" addr add dead:beef:"$i"::2/64 \ + dev ns2eth"$i" nodad + ip -net "$ns2" link set ns2eth"$i" up + ip -net "$ns2" route add default via 10.1."$i".1 \ + dev ns2eth"$i" metric 10"$i" + ip -net "$ns2" route add default via dead:beef:"$i"::1 \ + dev ns2eth"$i" metric 10"$i" + + # Add tc qdisc to both namespaces for bandwidth limiting + tc -n "$ns1" qdisc add dev ns1eth"$i" root netem $tc_args + tc -n "$ns2" qdisc add dev ns2eth"$i" root netem $tc_args + + tc -n "$ns1" qdisc show dev ns1eth"$i" + tc -n "$ns2" qdisc show dev ns2eth"$i" + done + + mptcp_lib_pm_nl_set_limits "${ns1}" 8 8 + + mptcp_lib_pm_nl_add_endpoint "$ns1" 10.1.1.1 flags signal + mptcp_lib_pm_nl_add_endpoint "$ns1" 10.1.2.1 flags signal + mptcp_lib_pm_nl_add_endpoint "$ns1" 10.1.3.1 flags signal + mptcp_lib_pm_nl_add_endpoint "$ns1" 10.1.4.1 flags signal + + mptcp_lib_pm_nl_set_limits "${ns2}" 8 8 + + mptcp_lib_pm_nl_add_endpoint "$ns2" 10.1.1.2 flags subflow + mptcp_lib_pm_nl_add_endpoint "$ns2" 10.1.2.2 flags subflow + mptcp_lib_pm_nl_add_endpoint "$ns2" 10.1.3.2 flags subflow + mptcp_lib_pm_nl_add_endpoint "$ns2" 10.1.4.2 flags subflow +} + +# This function is invoked indirectly +#shellcheck disable=3DSC2317,SC2329 +run_target() +{ + cd /sys/kernel/config/nvmet/subsystems || exit + mkdir -p "${nqn}" + cd "${nqn}" || exit + echo 1 > attr_allow_any_host + mkdir -p namespaces/"${ns}" + echo "${loop_dev}" > namespaces/"${ns}"/device_path + echo 1 > namespaces/"${ns}"/enable + + # Create ${path} ports, each on a different IP address + for i in $(seq 1 "${path}"); do + local portdir=3D$((port + i)) + + cd /sys/kernel/config/nvmet/ports || exit + mkdir -p "${portdir}" + cd "${portdir}" || exit 1 + echo "${trtype}" > addr_trtype + echo ipv4 > addr_adrfam + if [ "${path}" -eq 1 ]; then + echo "0.0.0.0" > addr_traddr + else + echo "10.1.${i}.1" > addr_traddr + fi + echo "${trsvcid}" > addr_trsvcid + + mkdir -p subsystems + ln -sf "../../subsystems/${nqn}" "subsystems/${nqn}" + cd - >/dev/null || exit + done +} + +# This function is invoked indirectly +#shellcheck disable=3DSC2317,SC2329 +run_host() +{ + local traddr=3D10.1.1.1 + local devname + + echo "nvme discover -a ${traddr}" + if ! nvme discover -t "${trtype}" -a "${traddr}" \ + -s "${trsvcid}"; then + echo "Failed to discover ${traddr}" + return 1 + fi + + for i in $(seq 1 "${path}"); do + traddr=3D10.1.${i}.1 + echo "Connecting to ${traddr}:${trsvcid}" + if ! nvme connect -t "${trtype}" -a "${traddr}" \ + -s "${trsvcid}" -n "${nqn}"; then + echo "Failed to connect to ${traddr}" + return 1 + fi + done + + for i in $(seq 1 10); do + for dev in /dev/nvme*n1; do + if [ -b "$dev" ] 2>/dev/null; then + if nvme id-ctrl "$dev" 2>/dev/null | + grep -q "${nqn}"; then + devname=3D$(basename "$dev") + break 2 + fi + fi + done 2>/dev/null + [ -n "$devname" ] && break + sleep 1 + done + + if [ -z "$devname" ]; then + echo "No block device found for NQN ${nqn}" >&2 + return 1 + fi + + echo "nvme list" + if ! nvme list; then + echo "nvme list failed" >&2 + return 1 + fi + + sleep 1 + + echo "fio randread /dev/${devname}" + if ! fio --name=3Dglobal --direct=3D1 --norandommap --randrepeat=3D0 \ + --ioengine=3Dlibaio --thread=3D1 --blocksize=3D128k --runtime=3D10 \ + --time_based --rw=3Drandread --numjobs=3D4 --iodepth=3D256 \ + --group_reporting --size=3D100% \ + --name=3Dlibaio_4_256_128k_randread \ + --filename=3D"/dev/${devname}"; then + echo "fio randread failed" + return 1 + fi + + sleep 1 + + echo "fio randwrite /dev/${devname}" + if ! fio --name=3Dglobal --direct=3D1 --norandommap --randrepeat=3D0 \ + --ioengine=3Dlibaio --thread=3D1 --blocksize=3D128k --runtime=3D10 \ + --time_based --rw=3Drandwrite --numjobs=3D4 --iodepth=3D256 \ + --group_reporting --size=3D100% \ + --name=3Dlibaio_4_256_128k_randwrite \ + --filename=3D"/dev/${devname}"; then + echo "fio randwrite failed" + return 1 + fi + + nvme flush "/dev/${devname}" +} + +mptcp_lib_check_tools nvme fio +validate_params + +if ! temp_file=3D$(mktemp --suffix=3D.raw /tmp/nvme_test.XXXXXX); then + echo "Failed to create temp file" + exit 1 +fi + +trap cleanup EXIT + +if ! dd if=3D/dev/zero of=3D"${temp_file}" bs=3D1M count=3D0 seek=3D512; t= hen + echo "Failed to create backing file" >&2 + exit 1 +fi + +if ! loop_dev=3D$(losetup -f --show "${temp_file}"); then + echo "Failed to create loop device" >&2 + exit 1 +fi + +init + +run_test() +{ + if ! ip netns exec "$ns1" unshare -m bash <<- EOF + mount -t configfs none /sys/kernel/config + $(declare -f run_target) + run_target + exit \$? + EOF + then + ret=3D"${KSFT_FAIL}" + fi + + if ! ip netns exec "$ns2" bash <<- EOF + $(declare -f run_host) + run_host + exit \$? + EOF + then + ret=3D"${KSFT_FAIL}" + fi + + sleep 1 +} + +run_test "$@" + +if [ "${ret}" -eq 0 ]; then + mptcp_lib_result_pass "nvme over ${trtype} test" +else + mptcp_lib_result_fail "nvme over ${trtype} test" +fi + +mptcp_lib_result_print_all_tap +exit "$ret" --=20 2.53.0 From nobody Mon Jun 8 16:29:06 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 E96C02EA172; Thu, 28 May 2026 03:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937969; cv=none; b=Hzbp0B9+0h0GD0BBCVNbNWk1sZAfIbF8RyvRvISiEQqsEsDjx0u0uaL8pTctd41r2I61KECVPgsVUlP3kR7Q9fzJtIiey45i+/TwSHqzmzT48AWw2B87+xcROwjnb1NUZ/HG2JpuMHwNyy7tldEYt4u37ETU2Gzmb9XesyWMZdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779937969; c=relaxed/simple; bh=BtpyOFLdptcWMoYqt0VLzwL3iZwobfw6mj2yYqyJ+Pc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n9sqbk1Y0APWV03uEZ9CliwG3RdlWHCM14PTkGdhtmVxa5h2naDWOy4Gbs+yn9ynETmF6TcEXIYs4xMMlc9qJhFexx/Dx7e9RPshhHRZFOs9TXyD6R4GWifKQZpKozO6SRVxvYgZzByL0rcJvWQg6hj3rwbOqFdLCj3PJyvFJA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ndAmRDUn; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ndAmRDUn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 110021F000E9; Thu, 28 May 2026 03:12:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779937967; bh=uHcHw+Zgx2c/yCnrl2bglqEmsfzND1F6CvMpIf7CaV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ndAmRDUn9eSi6DtQhDo0hSiI/fw4XFynY8pWiq5FJ6DwxfN923xu9o9pQP6UDliYP QY9DmaX7fc4dwEzhvTu/0d+NhUU4emN2kZ6gLD4vRqS5xMreQ+7EvD0EMBfIK9qqqr pNOXBjItdQOTgVcD9pqe2aJWFdb3zlpH9ZjiU+UAwD4Rt8ZkGXepdCDHtD1jWug3kp 56QEkMOo7z4y5hUT8X+hIx/qDGnWeY4FNIvUV54Z9RYdt+sPPf6U/G4m/W64mKRGo3 8XiUtg1mFzLm6faSuqNTXpeZmWDzlUfu8377iKmqe62oBThAi77k1MWyrJPZEr7WpY 2+W3dX5xBbwDA== From: Geliang Tang To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , Matthieu Baerts , Mat Martineau , Geliang Tang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan Cc: Geliang Tang , linux-nvme@lists.infradead.org, netdev@vger.kernel.org, mptcp@lists.linux.dev, linux-kselftest@vger.kernel.org, Hannes Reinecke , John Meneghini , Randy Jennings , Nilay Shroff , zhenwei pi , Hui Zhu , Gang Yan Subject: [PATCH 11/11] selftests: mptcp: nvme: add iopolicy tests Date: Thu, 28 May 2026 11:10:45 +0800 Message-ID: <51f054a6a573b9a771ed927eef34fa5ca083d009.1779934709.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.53.0 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 Content-Type: text/plain; charset="utf-8" From: Geliang Tang Add NVMe iopolicy testing to mptcp_nvme.sh, with the default set to "numa". It can be set to "round-robin" or "queue-depth". Test results with 4 NVMe multipath paths and round-robin iopolicy show that TCP and MPTCP achieve similar bandwidth: # ./mptcp_nvme.sh tcp 4 round-robin READ: bw=3D455MiB/s (478MB/s), 455MiB/s-455MiB/s (478MB/s-478MB/s), io=3D4665MiB (4891MB), run=3D10242-10242msec WRITE: bw=3D455MiB/s (477MB/s), 455MiB/s-455MiB/s (477MB/s-477MB/s), io=3D4633MiB (4858MB), run=3D10184-10184msec # ./mptcp_nvme.sh mptcp 4 round-robin READ: bw=3D445MiB/s (466MB/s), 445MiB/s-445MiB/s (466MB/s-466MB/s), io=3D4575MiB (4797MB), run=3D10287-10287msec WRITE: bw=3D445MiB/s (467MB/s), 445MiB/s-445MiB/s (467MB/s-467MB/s), io=3D4572MiB (4794MB), run=3D10267-10267msec A "loss" argument is added to simulate network packet loss. When loss=3D1, each veth interface is configured with "delay 5ms loss 0.5%" using tc qdisc. Under this scenario, TCP performance is reduced by multiples compared to MPTCP: # ./mptcp_nvme.sh tcp 4 round-robin 1 READ: bw=3D144MiB/s (151MB/s), 144MiB/s-144MiB/s (151MB/s-151MB/s), io=3D1909MiB (2001MB), run=3D13231-13231msec WRITE: bw=3D100.0MiB/s (105MB/s), 100.0MiB/s-100.0MiB/s (105MB/s-105MB/s), io=3D1397MiB (1465MB), run=3D13980-13980msec # ./mptcp_nvme.sh mptcp 4 round-robin 1 READ: bw=3D428MiB/s (449MB/s), 428MiB/s-428MiB/s (449MB/s-449MB/s), io=3D4524MiB (4743MB), run=3D10564-10564msec WRITE: bw=3D431MiB/s (452MB/s), 431MiB/s-431MiB/s (452MB/s-452MB/s), io=3D4513MiB (4732MB), run=3D10481-10481msec These results demonstrate that MPTCP has better resilience against packet loss compared to TCP, as it can leverage multiple subflows to mitigate network degradation. Cc: Hannes Reinecke Cc: John Meneghini Cc: Randy Jennings Cc: Nilay Shroff Co-developed-by: zhenwei pi Signed-off-by: zhenwei pi Co-developed-by: Hui Zhu Signed-off-by: Hui Zhu Co-developed-by: Gang Yan Signed-off-by: Gang Yan Signed-off-by: Geliang Tang --- .../testing/selftests/net/mptcp/mptcp_nvme.sh | 70 ++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_nvme.sh b/tools/testin= g/selftests/net/mptcp/mptcp_nvme.sh index 5b1133dbc2d5..3ab04be05dff 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_nvme.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_nvme.sh @@ -6,6 +6,8 @@ ret=3D0 trtype=3D"${1:-mptcp}" path=3D"${2:-1}" +iopolicy=3D${3:-"numa"} # round-robin, queue-depth +loss=3D${4:-0} nqn=3D"nqn.2014-08.org.nvmexpress.${trtype}dev.$$.${RANDOM}" ns=3D1 port=3D$((RANDOM % 10000 + 20000)) @@ -17,6 +19,7 @@ loop_dev=3D"" =20 export trtype path nqn ns port trsvcid export loop_dev temp_file +export iopolicy loss =20 usage() { @@ -24,10 +27,12 @@ usage() =20 Usage: =20 - $(basename "$0") [trtype] [path] + $(basename "$0") [trtype] [path] [iopolicy] [loss] =20 trtype Transport type (tcp|mptcp) - default: mptcp path Number of multipath (1-4) - default: 1 + iopolicy I/O policy (numa|round-robin|queue-depth) - default: numa + loss Enable packet loss (0|1) - default: 0 =20 EOF exit ${KSFT_FAIL} @@ -44,6 +49,16 @@ validate_params() echo "Invalid path count ${path}. Must be between 1 and 4" usage fi + + if [[ ! "${iopolicy}" =3D~ ^(numa|round-robin|queue-depth)$ ]]; then + echo "Invalid iopolicy ${iopolicy}." + usage + fi + + if [[ ! "${loss}" =3D~ ^[01]$ ]]; then + echo "Invalid loss value ${loss}. Must be 0 or 1" + usage + fi } =20 # This function is invoked indirectly @@ -105,6 +120,7 @@ cleanup() =20 unset -v trtype path nqn ns port trsvcid unset -v loop_dev temp_file + unset -v iopolicy loss } =20 # $tc_args needs word splitting to pass multiple arguments to netem @@ -113,6 +129,10 @@ init() { local tc_args=3D"rate 1000mbit" =20 + if [ "${loss}" -eq 1 ]; then + tc_args+=3D" delay 5ms loss 0.5%" + fi + mptcp_lib_ns_init ns1 ns2 =20 # ns1 ns2 @@ -193,6 +213,48 @@ run_target() done } =20 +# This function is invoked indirectly +#shellcheck disable=3DSC2317,SC2329 +set_io_policy() +{ + local nqn=3D"$1" + local iopolicy=3D"$2" + local subname + local policy + local current + + subname=3D$(nvme list-subsys 2>/dev/null | grep "${nqn}" | + grep -o 'nvme-subsys[0-9]*' | head -1) + if [ -z "$subname" ]; then + return 1 + fi + + policy=3D"/sys/class/nvme-subsystem/${subname}/iopolicy" + if [ ! -e "$policy" ]; then + # NVMe multipath not supported, skip iopolicy setting + return 0 + fi + + if [ ! -w "$policy" ]; then + return 1 + fi + + if ! echo "${iopolicy}" > "$policy" 2>/dev/null; then + return 1 + fi + + current=3D$(cat "$policy" 2>/dev/null) + if [ -z "$current" ]; then + return 1 + fi + + if [[ "$current" !=3D *"${iopolicy}"* ]]; then + return 1 + fi + + return 0 +} + # This function is invoked indirectly #shellcheck disable=3DSC2317,SC2329 run_host() @@ -242,6 +304,11 @@ run_host() return 1 fi =20 + if ! set_io_policy "${nqn}" "${iopolicy}"; then + echo "Failed to set I/O policy to ${iopolicy}" + return 1 + fi + sleep 1 =20 echo "fio randread /dev/${devname}" @@ -306,6 +373,7 @@ run_test() fi =20 if ! ip netns exec "$ns2" bash <<- EOF + $(declare -f set_io_policy) $(declare -f run_host) run_host exit \$? --=20 2.53.0