Skip to contentSkip to conversation

NVMe over Fabrics: NQN UUID byte order

PATCH New Verkamp, Daniel 4 participants 8 messages Jun 24, 2016 – Aug 19, 2016 NVMe

lore
Share & tools
lore
#0 lore raw

The NVMe 1.2.1 specification, section 7.9 (NVMe Qualified Names), says that the UUID format of NQN is based on RFC 4122, which explicitly requires all fields to be in big-endian/network byte order (section 4.1.2, Layout and Byte Order).

However, the current NVMe over Fabrics host code generates and formats the Host Identifier UUID in little-endian byte order:

Quoted 2 lines

static struct nvmf_host *nvmf_host_default(void)
{

[...]

Quoted 4 lines
	uuid_le_gen(&host->id);
	snprintf(host->nqn, NVMF_NQN_SIZE,
		"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host-

id);

Is this intentional or an oversight?

This could probably use some clarification on the NVMe specification side either way.

Thanks,
-- Daniel Verkamp

#1 lore raw
Quoted 10 lines · Daniel

The NVMe 1.2.1 specification, section 7.9 (NVMe Qualified Names), says that the UUID format of NQN is based on RFC 4122, which explicitly requires all fields to be in big-endian/network byte order (section 4.1.2, Layout and Byte Order).

However, the current NVMe over Fabrics host code generates and formats the Host Identifier UUID in little-endian byte order:

Quoted 2 lines

static struct nvmf_host *nvmf_host_default(void)
{

Quoted 7 lines

[...]

Quoted 4 lines
	uuid_le_gen(&host->id);
	snprintf(host->nqn, NVMF_NQN_SIZE,
		"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host-

id);

Is this intentional or an oversight?

This isn't intentional. Can you send a patch to use uuid_be and uuid_be_gen instead?

#2 lore raw

PATCH 1/1 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 <daniel.verkamp at intel.com>
---
 drivers/nvme/host/fabrics.c | 10 +++++-----
 drivers/nvme/host/fabrics.h |  2 +-
 include/linux/nvme.h        |  2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)
drivers/nvme/host/fabrics.c +5 -5
index b86b637..918310c 100644
@@ -56,7 +56,7 @@ static struct nvmf_host *nvmf_host_add(const char *hostnqn)
 
 	kref_init(&host->ref);
 	memcpy(host->nqn, hostnqn, NVMF_NQN_SIZE);
-	uuid_le_gen(&host->id);
+	uuid_be_gen(&host->id);
 
 	list_add_tail(&host->list, &nvmf_hosts);
 out_unlock:
@@ -73,9 +73,9 @@ static struct nvmf_host *nvmf_host_default(void)
 		return NULL;
 
 	kref_init(&host->ref);
-	uuid_le_gen(&host->id);
+	uuid_be_gen(&host->id);
 	snprintf(host->nqn, NVMF_NQN_SIZE,
-		"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUl", &host->id);
+		"nqn.2014-08.org.nvmexpress:NVMf:uuid:%pUb", &host->id);
 
 	mutex_lock(&nvmf_hosts_mutex);
 	list_add_tail(&host->list, &nvmf_hosts);
@@ -371,7 +371,7 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl)
 	if (!data)
 		return -ENOMEM;
 
-	memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le));
+	memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
 	data->cntlid = cpu_to_le16(0xffff);
 	strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
 	strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
@@ -430,7 +430,7 @@ int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid)
 	if (!data)
 		return -ENOMEM;
 
-	memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_le));
+	memcpy(&data->hostid, &ctrl->opts->host->id, sizeof(uuid_be));
 	data->cntlid = cpu_to_le16(ctrl->cntlid);
 	strncpy(data->subsysnqn, ctrl->opts->subsysnqn, NVMF_NQN_SIZE);
 	strncpy(data->hostnqn, ctrl->opts->host->nqn, NVMF_NQN_SIZE);
drivers/nvme/host/fabrics.h +1 -1
index b540674..9d31466 100644
@@ -34,7 +34,7 @@ struct nvmf_host {
 	struct kref		ref;
 	struct list_head	list;
 	char			nqn[NVMF_NQN_SIZE];
-	uuid_le			id;
+	uuid_be			id;
 };
 
 /**
include/linux/nvme.h +1 -1
index d8b37ba..7676557 100644
@@ -794,7 +794,7 @@ struct nvmf_connect_command {
 };
 
 struct nvmf_connect_data {
-	uuid_le		hostid;
+	uuid_be		hostid;
 	__le16		cntlid;
 	char		resv4[238];
 	char		subsysnqn[NVMF_NQN_FIELD_LEN];
Signature · 1 line
2.7.4
#3 lore raw

PATCH 1/1 nvme-fabrics: change NQN UUID to big-endian format

Quoted 8 lines · Daniel Verkamp

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.

Good catch.

Reviewed-by Jay Freyensee <james_p_freyensee at linux.intel.com>
Quoted 2 lines
Signed-off-by Daniel Verkamp <daniel.verkamp at intel.com>
#4 lore raw

PATCH 1/1 nvme-fabrics: change NQN UUID to big-endian format

In reply to Daniel Verkamp
Quoted 9 lines · Daniel Verkamp

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 <daniel.verkamp at intel.com>

Thanks a lot Daniel, I'll send this on to Jens.

#5 lore raw

PATCH 1/1 nvme-fabrics: change NQN UUID to big-endian format

Quoted 9 lines · Christoph Hellwig
Quoted 8 lines · Daniel Verkamp

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.

Quoted 7 lines
Quoted 5 lines

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 <daniel.verkamp at intel.com>

Thanks a lot Daniel, I'll send this on to Jens.

Hi,

Just wanted to check on this and make sure it didn't get dropped. It doesn't appear to be in Linus's tree or in any branches of nvme- fabrics.git yet.

Thanks,
-- Daniel

maintainer Applied
#6 lore raw

PATCH 1/1 nvme-fabrics: change NQN UUID to big-endian format

Quoted 6 lines

Hi,

Just wanted to check on this and make sure it didn't get dropped. It doesn't appear to be in Linus's tree or in any branches of nvme- fabrics.git yet.

Thanks for the reminder,

Queued to nvmf-4.8-rc.