Skip to content

Commit 51eac08

Browse files
committed
json: fixup dhchap_ctrl_key definitions
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 <[email protected]>
1 parent c6d3415 commit 51eac08

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

doc/config-schema.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"description": "NVMe host ID",
2626
"type": "string"
2727
},
28+
"dhchap_key": {
29+
"description": "Host DH-HMAC-CHAP key",
30+
"type": "string"
31+
},
2832
"hostsymname": {
2933
"description": "NVMe host symbolic name",
3034
"type": "string"
@@ -78,10 +82,6 @@
7882
"description": "Transport service identifier",
7983
"type": "string"
8084
},
81-
"dhchap_key": {
82-
"description": "Host DH-HMAC-CHAP key",
83-
"type": "string"
84-
},
8585
"dhchap_ctrl_key": {
8686
"description": "Controller DH-HMAC-CHAP key",
8787
"type": "string"

src/nvme/json.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void json_parse_port(nvme_subsystem_t s, struct json_object *port_obj)
9595
if (!c)
9696
return;
9797
json_update_attributes(c, port_obj);
98-
attr_obj = json_object_object_get(port_obj, "dhchap_key");
98+
attr_obj = json_object_object_get(port_obj, "dhchap_ctrl_key");
9999
if (attr_obj)
100100
nvme_ctrl_set_dhchap_key(c, json_object_get_string(attr_obj));
101101
}
@@ -224,7 +224,7 @@ static void json_update_port(struct json_object *ctrl_array, nvme_ctrl_t c)
224224
json_object_new_string(value));
225225
value = nvme_ctrl_get_dhchap_key(c);
226226
if (value)
227-
json_object_object_add(port_obj, "dhchap_key",
227+
json_object_object_add(port_obj, "dhchap_ctrl_key",
228228
json_object_new_string(value));
229229
JSON_INT_OPTION(cfg, port_obj, nr_io_queues, 0);
230230
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)
367367
json_object_new_string(value));
368368
value = nvme_ctrl_get_dhchap_key(c);
369369
if (value)
370-
json_object_object_add(ctrl_obj, "dhchap_key",
370+
json_object_object_add(ctrl_obj, "dhchap_ctrl_key",
371371
json_object_new_string(value));
372372
JSON_INT_OPTION(cfg, ctrl_obj, nr_io_queues, 0);
373373
JSON_INT_OPTION(cfg, ctrl_obj, nr_write_queues, 0);

src/nvme/tree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ void nvme_deconfigure_ctrl(nvme_ctrl_t c)
897897
FREE_CTRL_ATTR(c->queue_count);
898898
FREE_CTRL_ATTR(c->serial);
899899
FREE_CTRL_ATTR(c->sqsize);
900+
FREE_CTRL_ATTR(c->dhchap_key);
900901
FREE_CTRL_ATTR(c->address);
901902
FREE_CTRL_ATTR(c->dctype);
902903
FREE_CTRL_ATTR(c->cntrltype);

0 commit comments

Comments
 (0)