Commit 48b2e94f authored by Daniel Verkamp's avatar Daniel Verkamp Committed by Ben Walker
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/370593


Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 16c362a8
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1122,10 +1122,16 @@ nvme_rdma_discovery_probe(struct spdk_nvmf_discovery_log_page_entry *entry,
	/* Convert traddr to a null terminated string. */
	len = spdk_strlen_pad(entry->traddr, sizeof(entry->traddr), ' ');
	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. */
	len = spdk_strlen_pad(entry->trsvcid, sizeof(entry->trsvcid), ' ');
	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",
		      trid.subnqn, trid.trtype,