]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
fabrics: unconditionally strip discovery entry strings
authorCaleb Sander <csander@purestorage.com>
Wed, 30 Aug 2023 15:53:19 +0000 (09:53 -0600)
committerDaniel Wagner <wagi@monom.org>
Mon, 4 Sep 2023 17:23:24 +0000 (19:23 +0200)
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 <csander@purestorage.com>
src/nvme/fabrics.c

index acbcda35c5902ba7f2d8f5283a8d308b7dafa38e..224a5c897faa2606e50bee9419b9693dcf3898a3 100644 (file)
@@ -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,