]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: read TLS key in nvme_configure_ctrl()
authorHannes Reinecke <hare@suse.de>
Wed, 21 Feb 2024 14:15:27 +0000 (15:15 +0100)
committerDaniel Wagner <wagi@monom.org>
Thu, 7 Mar 2024 13:49:46 +0000 (14:49 +0100)
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 <hare@suse.de>
src/nvme/fabrics.h
src/nvme/tree.c

index a2504defa389303a1945d24f4cf51d911508894a..04b86511e02585b811f44fb98877895d8427abcb 100644 (file)
@@ -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;
index 344f8bc7fd74209e965caf8cfab0b44b02dab8e9..50e40917c4e08cf5832219e4d6270f2163086475 100644 (file)
@@ -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);