nvme/rdma: remove newlines from discovery strings

The Linux kernel NVMe-oF target can easily be misconfigured to report
newline-terminated strings from the discovery service, since its
parameters are set by echoing into sysfs files, and echo adds a newline
by default.

Newline characters are not allowed as part of the TRADDR and TRSVCID
fields, since they are defined as ASCII strings in the NVMe specification
sense, which limits the acceptable characters to the 0x20-0x7E range.

However, we can add a workaround for misconfigured targets with trailing
newlines that shouldn't impact any valid configurations.

Change-Id: I5db183d5637128fa8d50c245f4bfa965cc3ce8e2
Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/370593
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Daniel Verkamp 2017-07-20 09:54:15 -07:00 committed by Ben Walker
parent 16c362a8de
commit 48b2e94f66

View File

@ -1122,10 +1122,16 @@ nvme_rdma_discovery_probe(struct spdk_nvmf_discovery_log_page_entry *entry,
/* Convert traddr to a null terminated string. */ /* Convert traddr to a null terminated string. */
len = spdk_strlen_pad(entry->traddr, sizeof(entry->traddr), ' '); len = spdk_strlen_pad(entry->traddr, sizeof(entry->traddr), ' ');
memcpy(trid.traddr, entry->traddr, len); memcpy(trid.traddr, entry->traddr, len);
if (spdk_str_chomp(trid.traddr) != 0) {
SPDK_TRACELOG(SPDK_TRACE_NVME, "Trailing newlines removed from discovery TRADDR\n");
}
/* Convert trsvcid to a null terminated string. */ /* Convert trsvcid to a null terminated string. */
len = spdk_strlen_pad(entry->trsvcid, sizeof(entry->trsvcid), ' '); len = spdk_strlen_pad(entry->trsvcid, sizeof(entry->trsvcid), ' ');
memcpy(trid.trsvcid, entry->trsvcid, len); memcpy(trid.trsvcid, entry->trsvcid, len);
if (spdk_str_chomp(trid.trsvcid) != 0) {
SPDK_TRACELOG(SPDK_TRACE_NVME, "Trailing newlines removed from discovery TRSVCID\n");
}
SPDK_TRACELOG(SPDK_TRACE_DEBUG, "subnqn=%s, trtype=%u, traddr=%s, trsvcid=%s\n", SPDK_TRACELOG(SPDK_TRACE_DEBUG, "subnqn=%s, trtype=%u, traddr=%s, trsvcid=%s\n",
trid.subnqn, trid.trtype, trid.subnqn, trid.trtype,