From 48b2e94f665077afcbd3e0a3a4c2ab583caf49b0 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Thu, 20 Jul 2017 09:54:15 -0700 Subject: [PATCH] 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 Reviewed-on: https://review.gerrithub.io/370593 Reviewed-by: Ben Walker Tested-by: SPDK Automated Test System --- lib/nvme/nvme_rdma.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/nvme/nvme_rdma.c b/lib/nvme/nvme_rdma.c index 910c91cf0..ac978ee74 100644 --- a/lib/nvme/nvme_rdma.c +++ b/lib/nvme/nvme_rdma.c @@ -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,