From: Caleb Sander Date: Wed, 30 Aug 2023 15:53:19 +0000 (-0600) Subject: fabrics: unconditionally strip discovery entry strings X-Git-Tag: v1.6~29 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=bc6e07ad3dfcc201dd508f19b134896992713298;p=users%2Fsagi%2Flibnvme.git fabrics: unconditionally strip discovery entry strings The NVMe base specification defines fields TRSVCID and TRADDR as "ASCII strings", meaning they are space-padded. Therefore, whether spaces need to be stripped from them doesn't depend on the transport or address family. Some combinations already appear to be missing, such as RDMA using IB addresses. And if new transports are added in the future, sanitize_discovery_log_entry() would need to be updated. So strip spaces from these fields regardless of the entry's transport type or address family. Signed-off-by: Caleb Sander --- diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c index acbcda35..224a5c89 100644 --- a/src/nvme/fabrics.c +++ b/src/nvme/fabrics.c @@ -1166,30 +1166,10 @@ out_free_log: return NULL; } -static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e) +static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e) { - switch (e->trtype) { - case NVMF_TRTYPE_RDMA: - case NVMF_TRTYPE_TCP: - switch (e->adrfam) { - case NVMF_ADDR_FAMILY_IP4: - case NVMF_ADDR_FAMILY_IP6: - strchomp(e->traddr, NVMF_TRADDR_SIZE); - strchomp(e->trsvcid, NVMF_TRSVCID_SIZE); - break; - } - break; - case NVMF_TRTYPE_FC: - switch (e->adrfam) { - case NVMF_ADDR_FAMILY_FC: - strchomp(e->traddr, NVMF_TRADDR_SIZE); - break; - } - break; - case NVMF_TRTYPE_LOOP: - strchomp(e->traddr, NVMF_TRADDR_SIZE); - break; - } + strchomp(e->trsvcid, sizeof(e->trsvcid)); + strchomp(e->traddr, sizeof(e->traddr)); } int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,