nvmf: don't allow 0xFFFFFFFF as a NSID

FFFFFFFFh is reserved for the broadcast NSID and can't be used as a
NSID for a specific namespace.

Change-Id: I64a3cc80993d7b34324823462f4d992d1415773f
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/378849
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Daniel Verkamp 2017-09-15 16:17:47 -07:00
parent 9290e0bcf7
commit 8011d8c0e6
2 changed files with 10 additions and 0 deletions

View File

@ -328,6 +328,11 @@ spdk_nvmf_subsystem_add_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_bd
uint32_t i;
int rc;
if (nsid == SPDK_NVME_GLOBAL_NS_TAG) {
SPDK_ERRLOG("Invalid NSID %" PRIu32 "\n", nsid);
return 0;
}
if (nsid > subsystem->max_nsid ||
(nsid == 0 && subsystem->num_allocated_nsid == subsystem->max_nsid)) {
struct spdk_nvmf_ns *new_ns_array;

View File

@ -189,6 +189,11 @@ test_spdk_nvmf_subsystem_add_ns(void)
CU_ASSERT(nsid == 0);
CU_ASSERT(subsystem.max_nsid == 5);
/* Request 0xFFFFFFFF (invalid NSID, reserved for broadcast) */
nsid = spdk_nvmf_subsystem_add_ns(&subsystem, &bdev2, 0xFFFFFFFF);
CU_ASSERT(nsid == 0);
CU_ASSERT(subsystem.max_nsid == 5);
free(subsystem.ns);
}