From 100c53718dceffb743b92932b69e042dcb902b45 Mon Sep 17 00:00:00 2001 From: MengjinWu Date: Thu, 22 Sep 2022 09:27:58 +0000 Subject: [PATCH] nvmf/tcp: add in_capsule_data_size check before init in_capsule_data_size should not be larger than max_io_size. Signed-off-by: MengjinWu Change-Id: I636724c888b9e5abc4cffac96bff24021e172498 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14618 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/nvmf/tcp.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index 8bbb459b3..aa634a892 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -649,9 +649,18 @@ nvmf_tcp_create(struct spdk_nvmf_transport_opts *opts) /* I/O unit size cannot be larger than max I/O size */ if (opts->io_unit_size > opts->max_io_size) { + SPDK_WARNLOG("TCP param io_unit_size %u can't be larger than max_io_size %u. Using max_io_size as io_unit_size\n", + opts->io_unit_size, opts->max_io_size); opts->io_unit_size = opts->max_io_size; } + /* In capsule data size cannot be larger than max I/O size */ + if (opts->in_capsule_data_size > opts->max_io_size) { + SPDK_WARNLOG("TCP param ICD size %u can't be larger than max_io_size %u. Using max_io_size as ICD size\n", + opts->io_unit_size, opts->max_io_size); + opts->in_capsule_data_size = opts->max_io_size; + } + sge_count = opts->max_io_size / opts->io_unit_size; if (sge_count > SPDK_NVMF_MAX_SGL_ENTRIES) { SPDK_ERRLOG("Unsupported IO Unit size specified, %d bytes\n", opts->io_unit_size);