From nobody Thu Sep 05 21:15:06 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4X0Bvt5MZkz5Tyb3; Thu, 05 Sep 2024 21:15:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4X0Bvt4Xjmz41bB; Thu, 5 Sep 2024 21:15:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725570906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JhUfbwJqU46HzAAGsarMpzE+gkIdstL5nPEJJwz33/g=; b=iKRxhx2PvL1ljq6cOfSy3ih+66/TkHAZNV+6yueMWEU9yIFG0/zM7wq6SfSLrw4LAtaJlA 0h6Bf7HVxVY00754K3UZh7wmY+AnsLEkPsFSMBWvZ07Py+h7d31DXabCTJuaG3ny/JVsGk vvhVy6p9p15TFEUySosP7/mgViA2L8ZF8aE3iAfCpGjpq/NkUw8lJO19qJ5CRr25dJ9IZV e4vjFD1Yn9Nikl2FAo/K4a56GnmyEXuALbyNHhOkvJfl1mUYmsHiq6ApuasIpoibP6I0ZC HluqvupW/8IHBjBcJa4CaA/rmUAJO8M8FElRTzTg9XlmgxqYq+4VgazEVwX46w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725570906; a=rsa-sha256; cv=none; b=xBYj/CMlf8Xmt3uKIPaR2XCSlG0jlPgZd84dmftHGR/NoCjS/4AYatA2O4TfWXzuWLFx8T DCxaHOd02l07TNayDGXNsljT7Qp9xpz2kuWNuofSXqgJX+3huRhQipJcPWF6c438u+8+Jq Vhxq7jd1p+zEJW9mojuJBpCYQKACesYP2mUpEJLcYbPcLp5i9NYX2Wgb5nHKeS5KWJ9pIV mcr+RuHsdvrHCW3jefd33eWUTXcvPK43qqQQLSeQ//xhNamGoFqiZsBYaqUMWe7hT3bP6p a2VV58HYyQfTgfA0A5D5b7HM2jv4FeISjuvoLYCnAxIpTuCcJGD7zKGgNuxQzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725570906; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JhUfbwJqU46HzAAGsarMpzE+gkIdstL5nPEJJwz33/g=; b=GTmlxKn/z7uRATehE2PEJMMrp128fjhZ/KQBL2G+OMF4aXytLEhM7AytK+y6YwvVL4LVSJ Bb7QHNyBOskFl6bduveav7gZjXQKQUIGS1LGCvhtSaMjh47mNXRAOP1J/Af2fl1C3kSfTt 0404rG7A/Ig18oKODeLTv/rYWbR4jz+KRsriJm8I1lfUCwTKeohMVJ3Q6n83Cca2C3QhZd axqz2NMc/MgE88jk7w7js8ZTC/wmJ3RAPTfqjDvVXyWJPtBK45f6NDjRflNa2SU/a5VjmF DwdMFSIJSWFVCNrYtMNZvwtWSEn3/l7tYLx5oBkwJF5M/mJJVK9PK01h2YNSjg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4X0Bvt48tjzPTX; Thu, 5 Sep 2024 21:15:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 485LF6cs032535; Thu, 5 Sep 2024 21:15:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 485LF6cE032532; Thu, 5 Sep 2024 21:15:06 GMT (envelope-from git) Date: Thu, 5 Sep 2024 21:15:06 GMT Message-Id: <202409052115.485LF6cE032532@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: bedfac1f026f - main - nvmf_tcp: Fully honor kern.nvmf.tcp.max_transmit_data for C2H_DATA PDUs List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: bedfac1f026fa8e2e6572ca380d89d74a01d5def Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=bedfac1f026fa8e2e6572ca380d89d74a01d5def commit bedfac1f026fa8e2e6572ca380d89d74a01d5def Author: John Baldwin AuthorDate: 2024-09-05 21:14:36 +0000 Commit: John Baldwin CommitDate: 2024-09-05 21:14:36 +0000 nvmf_tcp: Fully honor kern.nvmf.tcp.max_transmit_data for C2H_DATA PDUs The previous version of tcp_send_controller_data avoided sending a chain of multiple mbufs that exceeded the limit, but if an individual mbuf was larger than the limit it was sent as a single, over-sized PDU. Fix by using m_split() to split individual mbufs larger than the limit. Note that this is not a protocol error, per se, as there is no limit on C2H_DATA PDU lengths (unlike the MAXH2CDATA parameter). This fix just honors the administrative limit more faithfully. This case is also very unlikely with the default limit of 256k. Sponsored by: Chelsio Communications --- sys/dev/nvmf/nvmf_tcp.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/sys/dev/nvmf/nvmf_tcp.c b/sys/dev/nvmf/nvmf_tcp.c index 67d239b63faf..22275aaa835b 100644 --- a/sys/dev/nvmf/nvmf_tcp.c +++ b/sys/dev/nvmf/nvmf_tcp.c @@ -1784,7 +1784,6 @@ tcp_send_controller_data(struct nvmf_capsule *nc, uint32_t data_offset, { struct nvmf_tcp_qpair *qp = TQP(nc->nc_qpair); struct nvme_sgl_descriptor *sgl; - struct mbuf *n, *p; uint32_t data_len; bool last_pdu, last_xfer; @@ -1813,21 +1812,29 @@ tcp_send_controller_data(struct nvmf_capsule *nc, uint32_t data_offset, /* Queue one more C2H_DATA PDUs containing the data from 'm'. */ while (m != NULL) { + struct mbuf *n; uint32_t todo; - todo = m->m_len; - p = m; - n = p->m_next; - while (n != NULL) { - if (todo + n->m_len > qp->max_tx_data) { - p->m_next = NULL; - break; - } - todo += n->m_len; - p = n; + if (m->m_len > qp->max_tx_data) { + n = m_split(m, qp->max_tx_data, M_WAITOK); + todo = m->m_len; + } else { + struct mbuf *p; + + todo = m->m_len; + p = m; n = p->m_next; + while (n != NULL) { + if (todo + n->m_len > qp->max_tx_data) { + p->m_next = NULL; + break; + } + todo += n->m_len; + p = n; + n = p->m_next; + } + MPASS(m_length(m, NULL) == todo); } - MPASS(m_length(m, NULL) == todo); last_pdu = (n == NULL && last_xfer); tcp_send_c2h_pdu(qp, nc->nc_sqe.cid, data_offset, m, todo,