summaryrefslogtreecommitdiffstats
path: root/src/nvme/fabrics.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvme/fabrics.c')
-rw-r--r--src/nvme/fabrics.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/src/nvme/fabrics.c b/src/nvme/fabrics.c
index 7134dba..3c32e27 100644
--- a/src/nvme/fabrics.c
+++ b/src/nvme/fabrics.c
@@ -110,8 +110,15 @@ static const char * const treqs[] = {
[NVMF_TREQ_NOT_SPECIFIED] = "not specified",
[NVMF_TREQ_REQUIRED] = "required",
[NVMF_TREQ_NOT_REQUIRED] = "not required",
- [NVMF_TREQ_DISABLE_SQFLOW] = "not specified, "
- "sq flow control disable supported",
+ [NVMF_TREQ_NOT_SPECIFIED |
+ NVMF_TREQ_DISABLE_SQFLOW] = "not specified, "
+ "sq flow control disable supported",
+ [NVMF_TREQ_REQUIRED |
+ NVMF_TREQ_DISABLE_SQFLOW] = "required, "
+ "sq flow control disable supported",
+ [NVMF_TREQ_NOT_REQUIRED |
+ NVMF_TREQ_DISABLE_SQFLOW] = "not required, "
+ "sq flow control disable supported",
};
const char *nvmf_treq_str(__u8 treq)
@@ -216,6 +223,8 @@ static struct nvme_fabrics_config *merge_config(nvme_ctrl_t c,
NVMF_DEF_CTRL_LOSS_TMO);
MERGE_CFG_OPTION(ctrl_cfg, cfg, fast_io_fail_tmo, 0);
MERGE_CFG_OPTION(ctrl_cfg, cfg, tos, -1);
+ MERGE_CFG_OPTION(ctrl_cfg, cfg, keyring, 0);
+ MERGE_CFG_OPTION(ctrl_cfg, cfg, tls_key, 0);
MERGE_CFG_OPTION(ctrl_cfg, cfg, duplicate_connect, false);
MERGE_CFG_OPTION(ctrl_cfg, cfg, disable_sqflow, false);
MERGE_CFG_OPTION(ctrl_cfg, cfg, hdr_digest, false);
@@ -243,6 +252,8 @@ void nvmf_update_config(nvme_ctrl_t c, const struct nvme_fabrics_config *cfg)
NVMF_DEF_CTRL_LOSS_TMO);
UPDATE_CFG_OPTION(ctrl_cfg, cfg, fast_io_fail_tmo, 0);
UPDATE_CFG_OPTION(ctrl_cfg, cfg, tos, -1);
+ UPDATE_CFG_OPTION(ctrl_cfg, cfg, keyring, 0);
+ UPDATE_CFG_OPTION(ctrl_cfg, cfg, tls_key, 0);
UPDATE_CFG_OPTION(ctrl_cfg, cfg, duplicate_connect, false);
UPDATE_CFG_OPTION(ctrl_cfg, cfg, disable_sqflow, false);
UPDATE_CFG_OPTION(ctrl_cfg, cfg, hdr_digest, false);
@@ -517,6 +528,9 @@ static int build_options(nvme_host_t h, nvme_ctrl_t c, char **argstr)
cfg->fast_io_fail_tmo, false)) ||
(strcmp(transport, "loop") &&
add_int_argument(argstr, "tos", cfg->tos, true)) ||
+ add_int_argument(argstr, "keyring", cfg->keyring, false) ||
+ (!strcmp(transport, "tcp") &&
+ add_int_argument(argstr, "tls_key", cfg->tls_key, false)) ||
add_bool_argument(argstr, "duplicate_connect",
cfg->duplicate_connect) ||
add_bool_argument(argstr, "disable_sqflow",
@@ -894,20 +908,20 @@ static void sanitize_discovery_log_entry(struct nvmf_disc_log_entry *e)
switch (e->adrfam) {
case NVMF_ADDR_FAMILY_IP4:
case NVMF_ADDR_FAMILY_IP6:
- strchomp(e->traddr, NVMF_TRADDR_SIZE - 1);
- strchomp(e->trsvcid, NVMF_TRSVCID_SIZE - 1);
+ 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 - 1);
+ strchomp(e->traddr, NVMF_TRADDR_SIZE);
break;
}
break;
case NVMF_TRTYPE_LOOP:
- strchomp(e->traddr, NVMF_TRADDR_SIZE - 1);
+ strchomp(e->traddr, NVMF_TRADDR_SIZE);
break;
}
}
@@ -998,6 +1012,31 @@ static int uuid_from_device_tree(char *system_uuid)
#define PATH_DMI_ENTRIES "/sys/firmware/dmi/entries"
+/*
+ * See System Management BIOS (SMBIOS) Reference Specification
+ * https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.2.0.pdf
+ */
+#define DMI_SYSTEM_INFORMATION 1
+
+static bool is_dmi_uuid_valid(const char *buf, size_t len)
+{
+ int i;
+
+ /* UUID bytes are from byte 8 to 23 */
+ if (len < 24)
+ return false;
+
+ /* Test it's a invalid UUID with all zeros */
+ for (i = 8; i < 24; i++) {
+ if (buf[i])
+ break;
+ }
+ if (i == 24)
+ return false;
+
+ return true;
+}
+
static int uuid_from_dmi_entries(char *system_uuid)
{
int f;
@@ -1025,7 +1064,7 @@ static int uuid_from_dmi_entries(char *system_uuid)
continue;
if (sscanf(buf, "%d", &type) != 1)
continue;
- if (type != 1)
+ if (type != DMI_SYSTEM_INFORMATION)
continue;
sprintf(filename, "%s/%s/raw", PATH_DMI_ENTRIES, de->d_name);
f = open(filename, O_RDONLY);
@@ -1033,8 +1072,10 @@ static int uuid_from_dmi_entries(char *system_uuid)
continue;
len = read(f, buf, 512);
close(f);
- if (len <= 0)
+
+ if (!is_dmi_uuid_valid(buf, len))
continue;
+
/* Sigh. https://en.wikipedia.org/wiki/Overengineering */
/* DMTF SMBIOS 3.0 Section 7.2.1 System UUID */
sprintf(system_uuid,