Skip to content

Commit 6847368

Browse files
committed
tree: always set the host key
The current logic will not set the host secret to the controller when the sysfs value and the value from the host object are identically. Thus, if the controller has a host key us this one and add it to controller, if missing try to use the one from the host object. Signed-off-by: Daniel Wagner <[email protected]>
1 parent 66f4dc8 commit 6847368

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/nvme/tree.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,11 +1984,12 @@ static void nvme_read_sysfs_dhchap(nvme_root_t r, nvme_ctrl_t c)
19841984
char *host_key, *ctrl_key;
19851985

19861986
host_key = nvme_get_ctrl_attr(c, "dhchap_secret");
1987-
if (host_key && c->s && c->s->h && c->s->h->dhchap_key &&
1988-
(!strcmp(c->s->h->dhchap_key, host_key) ||
1989-
!strcmp("none", host_key))) {
1987+
if (host_key && !strcmp(host_key, "none")) {
19901988
free(host_key);
1991-
host_key = NULL;
1989+
if (c->s && c->s->h)
1990+
host_key = strdup(c->s->h->dhchap_key);
1991+
else
1992+
host_key = NULL;
19921993
}
19931994
if (host_key) {
19941995
nvme_ctrl_set_dhchap_host_key(c, NULL);

0 commit comments

Comments
 (0)