Skip to content

Commit 7a665d2

Browse files
danielverkampsagigrimberg
authored andcommitted
nvme-fabrics: change NQN UUID to big-endian format
NVM Express 1.2.1 section 7.9, NVMe Qualified Names, specifies that the UUID format of NQN uses a UUID based on RFC 4122. RFC 4122 specifies that the UUID is encoded in big-endian byte order. Switch the NVMe over Fabrics host ID field from little-endian UUID to big-endian UUID to match the specification. Signed-off-by: Daniel Verkamp <[email protected]> Reviewed-by: Jay Freyensee <[email protected]> Signed-off-by: Sagi Grimberg <[email protected]>
1 parent eadb7cf commit 7a665d2

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

drivers/nvme/host/fabrics.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
5656

5757
kref_init(&host->ref);
5858
memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
59-
uuid_le_gen(&host->id);
59+
uuid_be_gen(&host->id);
6060

6161
list_add_tail(&host->list, &nvmf_hosts);
6262
out_unlock:
@@ -73,9 +73,9 @@ static struct nvmf_host *nvmf_host_default(void)
7373
return NULL;
7474

7575
kref_init(&host->ref);
76-
uuid_le_gen(&host->id);
76+
uuid_be_gen(&host->id);
7777
snprintf(host->nqn, NVMF_NQN_SIZE,
78-
"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host->id);
78+
"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
7979

8080
mutex_lock(&nvmf_hosts_mutex);
8181
list_add_tail(&host->list, &nvmf_hosts);
@@ -382,7 +382,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
382382
if (!data)
383383
return -ENOMEM;
384384

385-
memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le));
385+
memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
386386
data->cntlid = cpu_to_le16(0xffff);
387387
strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
388388
strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
@@ -441,7 +441,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
441441
if (!data)
442442
return -ENOMEM;
443443

444-
memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le));
444+
memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
445445
data->cntlid = cpu_to_le16(ctrl->cntlid);
446446
strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
447447
strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);

drivers/nvme/host/fabrics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct nvmf_host {
3434
struct kref ref;
3535
struct list_head list;
3636
char nqn[NVMF_NQN_SIZE];
37-
uuid_le id;
37+
uuid_be id;
3838
};
3939

4040
/**

include/linux/nvme.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ struct nvmf_connect_command {
794794
};
795795

796796
struct nvmf_connect_data {
797-
uuid_le hostid;
797+
uuid_be hostid;
798798
__le16 cntlid;
799799
char resv4[238];
800800
char subsysnqn[NVMF_NQN_FIELD_LEN];

0 commit comments

Comments
 (0)