Commit 100c5371 authored by MengjinWu's avatar MengjinWu Committed by Jim Harris
Browse files

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: default avatarMengjinWu <mengjin.wu@intel.com>
Change-Id: I636724c888b9e5abc4cffac96bff24021e172498
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14618


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent dfc98943
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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);