]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
json: fixup dhchap_ctrl_key definitions
authorHannes Reinecke <hare@suse.de>
Fri, 29 Jul 2022 06:14:14 +0000 (08:14 +0200)
committerHannes Reinecke <hare@suse.de>
Fri, 29 Jul 2022 06:19:13 +0000 (08:19 +0200)
The config schema declared a 'dhchap_key' and a 'dhchap_ctrl_key'
value for the port structure, but the json parser implemented a
'dhchap_key' entry for the port (holding the controller key), and
a 'dhchap_key' entry for the host (holding the host key).
Fixup the config schema to declared the correct entries and the
json parser to check for 'dhchap_ctrl_key' instead of 'dhchap_key'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
doc/config-schema.json
src/nvme/json.c
src/nvme/tree.c

index a7bbdf17c1eb7f955861a2c215de7aea3025ca9e..0d2b267516161f2d71324f84070b1a0335c2fdc5 100644 (file)
                    "description": "NVMe host ID",
                    "type": "string"
                },
+               "dhchap_key": {
+                   "description": "Host DH-HMAC-CHAP key",
+                   "type": "string"
+               },
                "hostsymname": {
                    "description": "NVMe host symbolic name",
                    "type": "string"
                    "description": "Transport service identifier",
                    "type": "string"
                },
-               "dhchap_key": {
-                   "description": "Host DH-HMAC-CHAP key",
-                   "type": "string"
-               },
                "dhchap_ctrl_key": {
                    "description": "Controller DH-HMAC-CHAP key",
                    "type": "string"
index 7053618d17009f3f99d094e42c5a2c039d14869d..b42cd516f4bde584a789e3da0ea6f49235c12fb2 100644 (file)
@@ -95,7 +95,7 @@ static void json_parse_port(nvme_subsystem_t s, struct json_object *port_obj)
        if (!c)
                return;
        json_update_attributes(c, port_obj);
-       attr_obj = json_object_object_get(port_obj, "dhchap_key");
+       attr_obj = json_object_object_get(port_obj, "dhchap_ctrl_key");
        if (attr_obj)
                nvme_ctrl_set_dhchap_key(c, json_object_get_string(attr_obj));
 }
@@ -224,7 +224,7 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c)
                                       json_object_new_string(value));
        value = nvme_ctrl_get_dhchap_key(c);
        if (value)
-               json_object_object_add(port_obj, "dhchap_key",
+               json_object_object_add(port_obj, "dhchap_ctrl_key",
                                       json_object_new_string(value));
        JSON_INT_OPTION(cfg, port_obj, nr_io_queues, 0);
        JSON_INT_OPTION(cfg, port_obj, nr_write_queues, 0);
@@ -367,7 +367,7 @@ static void json_dump_ctrl(struct json_object *ctrl_array, nvme_ctrl_t c)
                                       json_object_new_string(value));
        value = nvme_ctrl_get_dhchap_key(c);
        if (value)
-               json_object_object_add(ctrl_obj, "dhchap_key",
+               json_object_object_add(ctrl_obj, "dhchap_ctrl_key",
                                       json_object_new_string(value));
        JSON_INT_OPTION(cfg, ctrl_obj, nr_io_queues, 0);
        JSON_INT_OPTION(cfg, ctrl_obj, nr_write_queues, 0);
index 916179180294878cd8578e48de45b24fbfe8d536..e3b41e793c97b2d0a3cee499e1d450cb5f9b00a6 100644 (file)
@@ -897,6 +897,7 @@ void nvme_deconfigure_ctrl(nvme_ctrl_t c)
        FREE_CTRL_ATTR(c->queue_count);
        FREE_CTRL_ATTR(c->serial);
        FREE_CTRL_ATTR(c->sqsize);
+       FREE_CTRL_ATTR(c->dhchap_key);
        FREE_CTRL_ATTR(c->address);
        FREE_CTRL_ATTR(c->dctype);
        FREE_CTRL_ATTR(c->cntrltype);