Skip to content

Commit 9fd6153

Browse files
committed
fabrics: issue a warning on invalid traddr format
Report that the traddr is invalid instead silently fix it only. (cherry picked from 05b3f6b0930e) Signed-off-by: Daniel Wagner <[email protected]>
1 parent a6b39ab commit 9fd6153

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

src/nvme/fabrics.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,7 +1280,8 @@ static struct nvmf_discovery_log *nvme_discovery_log(
12801280
return NULL;
12811281
}
12821282

1283-
static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e)
1283+
static void sanitize_discovery_log_entry(nvme_root_t r,
1284+
struct nvmf_disc_log_entry *e)
12841285
{
12851286
strchomp(e->trsvcid, sizeof(e->trsvcid));
12861287
strchomp(e->traddr, sizeof(e->traddr));
@@ -1292,8 +1293,11 @@ static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e)
12921293
if (e->trtype == NVMF_TRTYPE_FC) {
12931294
char *comma = strchr(e->traddr, ',');
12941295

1295-
if (comma)
1296+
if (comma) {
1297+
nvme_msg(r, LOG_WARNING,
1298+
"invalid traddr separator ',' instead ':', fixing it");
12961299
*comma = ':';
1300+
}
12971301
}
12981302
}
12991303

@@ -1314,13 +1318,17 @@ int nvmf_get_discovery_log(nvme_ctrl_t c, struct nvmf_discovery_log **logp,
13141318
struct nvmf_discovery_log *nvmf_get_discovery_wargs(struct nvme_get_discovery_args *args)
13151319
{
13161320
struct nvmf_discovery_log *log;
1321+
nvme_ctrl_t c;
1322+
nvme_root_t r;
13171323

13181324
log = nvme_discovery_log(args);
13191325
if (!log)
13201326
return NULL;
13211327

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

13251333
return log;
13261334
}

0 commit comments

Comments
 (0)