From: Hannes Reinecke Date: Wed, 21 Feb 2024 14:15:27 +0000 (+0100) Subject: tree: read TLS key in nvme_configure_ctrl() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1c44e9a10e9d900ce4e3a047e8c2facf6dc1c6fa;p=users%2Fsagi%2Flibnvme.git tree: read TLS key in nvme_configure_ctrl() nvme_configure_ctrl() is reading the values from sysfs, so we should be reading the TLS key, too, if present. Signed-off-by: Hannes Reinecke --- diff --git a/src/nvme/fabrics.h b/src/nvme/fabrics.h index a2504def..04b86511 100644 --- a/src/nvme/fabrics.h +++ b/src/nvme/fabrics.h @@ -57,7 +57,7 @@ struct nvme_fabrics_config { int nr_poll_queues; int tos; int keyring; - int tls_key; + long tls_key; bool duplicate_connect; bool disable_sqflow; diff --git a/src/nvme/tree.c b/src/nvme/tree.c index 344f8bc7..50e40917 100644 --- a/src/nvme/tree.c +++ b/src/nvme/tree.c @@ -1772,7 +1772,7 @@ static int nvme_configure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path, const char *name) { DIR *d; - char *host_key; + char *host_key, *tls_psk; d = opendir(path); if (!d) { @@ -1807,6 +1807,16 @@ static int nvme_configure_ctrl(nvme_root_t r, nvme_ctrl_t c, const char *path, free(c->dhchap_ctrl_key); c->dhchap_ctrl_key = NULL; } + tls_psk = nvme_get_ctrl_attr(c, "tls_key"); + if (tls_psk) { + char *endptr; + long key_id = strtol(tls_psk, &endptr, 16); + + if (endptr != tls_psk) { + c->cfg.tls_key = key_id; + c->cfg.tls = true; + } + } c->cntrltype = nvme_get_ctrl_attr(c, "cntrltype"); c->dctype = nvme_get_ctrl_attr(c, "dctype"); c->phy_slot = nvme_ctrl_lookup_phy_slot(r, c->address);