File 0010-json-fixup-dhchap_ctrl_key-definitions.patch of Package libnvme.27116
From: Hannes Reinecke <hare@suse.de>
Date: Fri, 29 Jul 2022 08:14:14 +0200
Subject: json: fixup dhchap_ctrl_key definitions
Git-commit: 51eac082acecc3d418d081047f4aedbff2762838
References: bsc#1201501 bsc#1201700
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>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
doc/config-schema.json | 8 ++++----
src/nvme/json.c | 6 +++---
src/nvme/tree.c | 1 +
3 files changed, 8 insertions(+), 7 deletions(-)
--- a/doc/config-schema.json
+++ b/doc/config-schema.json
@@ -25,6 +25,10 @@
"description": "NVMe host ID",
"type": "string"
},
+ "dhchap_key": {
+ "description": "Host DH-HMAC-CHAP key",
+ "type": "string"
+ },
"hostsymname": {
"description": "NVMe host symbolic name",
"type": "string"
@@ -78,10 +82,6 @@
"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"
--- a/src/nvme/json.c
+++ b/src/nvme/json.c
@@ -95,7 +95,7 @@ static void json_parse_port(nvme_subsyst
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
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);
@@ -366,7 +366,7 @@ static void json_dump_ctrl(struct json_o
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);
--- a/src/nvme/tree.c
+++ b/src/nvme/tree.c
@@ -894,6 +894,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);