test/nvme_tcp: Correct the psh_len in nvme_tcp unittest

psh len is not the same with header len.

Add an assert in nvme_tcp.c to prevent this happen again.

Signed-off-by: MengjinWu <mengjin.wu@intel.com>
Change-Id: Ibc250752bedf3da8994f79c51fb01577a222d364
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14521
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
MengjinWu 2022-09-16 04:22:10 +00:00 committed by Jim Harris
parent 0b7f5a57ac
commit e4569bd421
2 changed files with 4 additions and 2 deletions

View File

@ -1636,6 +1636,7 @@ nvme_tcp_read_pdu(struct nvme_tcp_qpair *tqpair, uint32_t *reaped)
break; break;
/* Wait for the pdu specific header */ /* Wait for the pdu specific header */
case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH: case NVME_TCP_PDU_RECV_STATE_AWAIT_PDU_PSH:
assert(pdu->psh_valid_bytes < pdu->psh_len);
rc = nvme_tcp_read_data(tqpair->sock, rc = nvme_tcp_read_data(tqpair->sock,
pdu->psh_len - pdu->psh_valid_bytes, pdu->psh_len - pdu->psh_valid_bytes,
(uint8_t *)&pdu->hdr.raw + sizeof(struct spdk_nvme_tcp_common_pdu_hdr) + pdu->psh_valid_bytes); (uint8_t *)&pdu->hdr.raw + sizeof(struct spdk_nvme_tcp_common_pdu_hdr) + pdu->psh_valid_bytes);

View File

@ -1381,8 +1381,9 @@ test_nvme_tcp_ctrlr_connect_qpair(void)
tqpair->recv_pdu->hdr.common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_IC_RESP; tqpair->recv_pdu->hdr.common.pdu_type = SPDK_NVME_TCP_PDU_TYPE_IC_RESP;
tqpair->recv_pdu->hdr.common.plen = sizeof(struct spdk_nvme_tcp_ic_resp); tqpair->recv_pdu->hdr.common.plen = sizeof(struct spdk_nvme_tcp_ic_resp);
tqpair->recv_pdu->hdr.common.hlen = sizeof(struct spdk_nvme_tcp_ic_resp); tqpair->recv_pdu->hdr.common.hlen = sizeof(struct spdk_nvme_tcp_ic_resp);
tqpair->recv_pdu->ch_valid_bytes = 7; tqpair->recv_pdu->ch_valid_bytes = sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - 1;
tqpair->recv_pdu->psh_valid_bytes = tqpair->recv_pdu->hdr.common.hlen; tqpair->recv_pdu->psh_valid_bytes = tqpair->recv_pdu->hdr.common.hlen -
sizeof(struct spdk_nvme_tcp_common_pdu_hdr) - 1;
tqpair->recv_pdu->hdr.ic_resp.maxh2cdata = 4096; tqpair->recv_pdu->hdr.ic_resp.maxh2cdata = 4096;
tqpair->recv_pdu->hdr.ic_resp.cpda = 1; tqpair->recv_pdu->hdr.ic_resp.cpda = 1;
tqpair->flags.icreq_send_ack = 1; tqpair->flags.icreq_send_ack = 1;