From nobody Mon Jul 22 21:06:46 2024 X-Original-To: dev-commits-src-all@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 4WSXs32Hzdz5QBc6; Mon, 22 Jul 2024 21:06:47 +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 4WSXs30V9Yz4drl; Mon, 22 Jul 2024 21:06:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721682407; 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=2tRDl9SbJXxE/Mi0iSLRfDnUCNZDcy2t9ESqom6YmtU=; b=kzVCgRgBwQWIlRdo5HAPb6HkwUwL+FsVKrbjG43b87+v+f0B4J170b4H8yaCFn1VE3WxiM A94cuAPBWMbbJCNazkwu87YqG+MGXcIdBa6CeLO8Os5oF40nYXIqPQiEk0c8Z8+YAQonm1 pD0JBi0swCxrl6iL1ITDOr6fW1EO5jiLQSJMqxgPLGh+Jg4OF8ZNf91VztclwjlSjNH7BI 8OTzW6ZHAi1X9fvBjxJJstv/UkarHgSIkYa3/Fm4vEG93q43UIjOlLINtn7FPVcsFCwI6w HtHQ7P2ZCZNU9MJU9Yx3hYvnyXg2LddzxzmCS1N7IPhhkbOzS+LCwxjlNhVJkw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721682407; a=rsa-sha256; cv=none; b=OMVaFkCimlZcA99CYGmhcqAg17vSPEnznWRHZqi0e2WEoKHz2kSZ+ttLWtGa4t7Nerqkog ODAL79XRJ486iisyz1myV0j+hOXt3WT/RcoWpg+BCCyX+S4APO0tFagw+3zwAYoa5fvaQG W4jbIprE/wI9LgGhdNerIaq7KM7TO4H6ZxkpDkb3pvTvw+5x4E1WHp/vA9zIxYwd3pB2Sm URi3WlInhOGKkUZWcsSG0RL2NzY1Bu/I7/QOcznRA704NyD7japjRkz0N14wG3xQX4uSk5 qJ6hSk4VqXlvBAINAnF4Bpx2mOpco+p4/3qxdtnPbToeBomVDXxnHkM3LvBIoQ== 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=1721682407; 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=2tRDl9SbJXxE/Mi0iSLRfDnUCNZDcy2t9ESqom6YmtU=; b=vtDGGL8iIu/Yx+WywTbstQF39kNMMG13ZhfjyaEzoDogb6VuEezC1HFwNsM0ndITKn68ss 5+mbiSeHxi5WgJIvTSXODYkMsjhDOk6x5YfKMhp0oLJcFNouAOiDQNBtDUFKuwY37nH1k9 11y0B4P+JqbhHgDTmLosnaT7g4pH1c0SN2plTNkeMHyQ+cIQF8835XpZxcANfz66cloYQz PLT061n88CJWABJ8xPhHu5td/BfaSeneoNJdTrqrf8GMyrpCipzh/knqkLnOcBCqw/YEc/ o5Cw2n4TVCS5B9GjVfMie81wxXd3qQBrA4oo5HfceP6ux0AOGCf25/Uav7YmNQ== 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 4WSXs305jGz10qt; Mon, 22 Jul 2024 21:06:47 +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 46ML6kZd063109; Mon, 22 Jul 2024 21:06:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46ML6kJl063106; Mon, 22 Jul 2024 21:06:46 GMT (envelope-from git) Date: Mon, 22 Jul 2024 21:06:46 GMT Message-Id: <202407222106.46ML6kJl063106@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: 43d45f26413a - main - nvmf_tcp: Don't require a data digest for PDUs without data List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 43d45f26413aa98e41994d0d0f06c49c7eca430e Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=43d45f26413aa98e41994d0d0f06c49c7eca430e commit 43d45f26413aa98e41994d0d0f06c49c7eca430e Author: John Baldwin AuthorDate: 2024-07-22 19:38:12 +0000 Commit: John Baldwin CommitDate: 2024-07-22 21:05:55 +0000 nvmf_tcp: Don't require a data digest for PDUs without data If a PDU (such as a Command Capsule PDU) on a connection that has enabled data digests does not have a data section, it will not have the the PDU data digest flag set. The previous check was requiring this flag to be present on all PDU types that support data sections even if no data was included in the PDU. Sponsored by: Chelsio Communications --- sys/dev/nvmf/nvmf_tcp.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/sys/dev/nvmf/nvmf_tcp.h b/sys/dev/nvmf/nvmf_tcp.h index 78d6cf17a977..c60be0bc1024 100644 --- a/sys/dev/nvmf/nvmf_tcp.h +++ b/sys/dev/nvmf/nvmf_tcp.h @@ -41,6 +41,13 @@ nvmf_tcp_validate_pdu_header(const struct nvme_tcp_common_pdu_hdr *ch, uint8_t digest_flags, valid_flags; plen = le32toh(ch->plen); + full_hlen = ch->hlen; + if ((ch->flags & NVME_TCP_CH_FLAGS_HDGSTF) != 0) + full_hlen += sizeof(uint32_t); + if (plen == full_hlen) + data_len = 0; + else + data_len = plen - ch->pdo; /* * Errors must be reported for the lowest incorrect field @@ -125,11 +132,15 @@ nvmf_tcp_validate_pdu_header(const struct nvme_tcp_common_pdu_hdr *ch, return (EBADMSG); } - /* Verify that digests are present iff enabled. */ + /* + * Verify that digests are present iff enabled. Note that the + * data digest will not be present if there is no data + * payload. + */ digest_flags = 0; if (header_digests) digest_flags |= NVME_TCP_CH_FLAGS_HDGSTF; - if (data_digests) + if (data_digests && data_len != 0) digest_flags |= NVME_TCP_CH_FLAGS_DDGSTF; if ((digest_flags & valid_flags) != (ch->flags & (NVME_TCP_CH_FLAGS_HDGSTF | @@ -184,9 +195,6 @@ nvmf_tcp_validate_pdu_header(const struct nvme_tcp_common_pdu_hdr *ch, } /* Validate pdo. */ - full_hlen = ch->hlen; - if ((ch->flags & NVME_TCP_CH_FLAGS_HDGSTF) != 0) - full_hlen += sizeof(uint32_t); switch (ch->pdu_type) { default: __assert_unreachable(); @@ -207,7 +215,7 @@ nvmf_tcp_validate_pdu_header(const struct nvme_tcp_common_pdu_hdr *ch, case NVME_TCP_PDU_TYPE_H2C_DATA: case NVME_TCP_PDU_TYPE_C2H_DATA: /* Permit PDO of 0 if there is no data. */ - if (full_hlen == plen && ch->pdo == 0) + if (data_len == 0 && ch->pdo == 0) break; if (ch->pdo < full_hlen || ch->pdo > plen || @@ -229,10 +237,6 @@ nvmf_tcp_validate_pdu_header(const struct nvme_tcp_common_pdu_hdr *ch, return (EBADMSG); } - if (plen == full_hlen) - data_len = 0; - else - data_len = plen - ch->pdo; switch (ch->pdu_type) { default: __assert_unreachable();