Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1280,10 +1280,25 @@ static struct nvmf_discovery_log *nvme_discovery_log(
return NULL;
}

static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e)
static void sanitize_discovery_log_entry(nvme_root_t r,
struct nvmf_disc_log_entry *e)
{
strchomp(e->trsvcid, sizeof(e->trsvcid));
strchomp(e->traddr, sizeof(e->traddr));

/*
* Report traddr always in 'nn-0x:pn-0x' format, but some discovery logs
* provide 'nn-0x,pn-0x'.
*/
if (e->trtype == NVMF_TRTYPE_FC) {
char *comma = strchr(e->traddr, ',');

if (comma) {
nvme_msg(r, LOG_WARNING,
"invalid traddr separator ',' instead ':', fixing it");
*comma = ':';
}
}
}

int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
Expand All @@ -1303,13 +1318,17 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
struct nvmf_discovery_log *nvmf_get_discovery_wargs(struct nvme_get_discovery_args *args)
{
struct nvmf_discovery_log *log;
nvme_ctrl_t c;
nvme_root_t r;

log = nvme_discovery_log(args);
if (!log)
return NULL;

c = args->c;
r = c->s && c->s->h ? c->s->h->r : NULL;
for (int i = 0; i < le64_to_cpu(log->numrec); i++)
sanitize_discovery_log_entry(&log->entries[i]);
sanitize_discovery_log_entry(r, &log->entries[i]);

return log;
}
Expand Down
Loading