Skip to content

Commit 5032167

Browse files
Hannes Reineckekeithbusch
authored andcommitted
nvmet: Add 'sq' argument to alloc_ctrl_args
For secure concatenation the result of the TLS handshake will be stored in the 'sq' struct, so add it to the alloc_ctrl_args struct. Cc: Damien Le Moal <[email protected]> Signed-off-by: Hannes Reinecke <[email protected]> Reviewed-by: Sagi Grimberg <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 104d0e2 commit 5032167

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

drivers/nvme/target/auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id)
139139
return ret;
140140
}
141141

142-
u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl)
142+
u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq)
143143
{
144144
int ret = 0;
145145
struct nvmet_host_link *p;

drivers/nvme/target/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1649,7 +1649,7 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args)
16491649
if (args->hostid)
16501650
uuid_copy(&ctrl->hostid, args->hostid);
16511651

1652-
dhchap_status = nvmet_setup_auth(ctrl);
1652+
dhchap_status = nvmet_setup_auth(ctrl, args->sq);
16531653
if (dhchap_status) {
16541654
pr_err("Failed to setup authentication, dhchap status %u\n",
16551655
dhchap_status);

drivers/nvme/target/fabrics-cmd-auth.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
246246
pr_debug("%s: ctrl %d qid %d reset negotiation\n",
247247
__func__, ctrl->cntlid, req->sq->qid);
248248
if (!req->sq->qid) {
249-
dhchap_status = nvmet_setup_auth(ctrl);
249+
dhchap_status = nvmet_setup_auth(ctrl, req->sq);
250250
if (dhchap_status) {
251251
pr_err("ctrl %d qid 0 failed to setup re-authentication\n",
252252
ctrl->cntlid);

drivers/nvme/target/fabrics-cmd.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
234234
return ret;
235235
}
236236

237-
static u32 nvmet_connect_result(struct nvmet_ctrl *ctrl)
237+
static u32 nvmet_connect_result(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq)
238238
{
239+
bool needs_auth = nvmet_has_auth(ctrl);
240+
239241
return (u32)ctrl->cntlid |
240-
(nvmet_has_auth(ctrl) ? NVME_CONNECT_AUTHREQ_ATR : 0);
242+
(needs_auth ? NVME_CONNECT_AUTHREQ_ATR : 0);
241243
}
242244

243245
static void nvmet_execute_admin_connect(struct nvmet_req *req)
@@ -247,6 +249,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
247249
struct nvmet_ctrl *ctrl = NULL;
248250
struct nvmet_alloc_ctrl_args args = {
249251
.port = req->port,
252+
.sq = req->sq,
250253
.ops = req->ops,
251254
.p2p_client = req->p2p_client,
252255
.kato = le32_to_cpu(c->kato),
@@ -299,7 +302,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
299302
goto out;
300303
}
301304

302-
args.result = cpu_to_le32(nvmet_connect_result(ctrl));
305+
args.result = cpu_to_le32(nvmet_connect_result(ctrl, req->sq));
303306
out:
304307
kfree(d);
305308
complete:
@@ -357,7 +360,7 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
357360
goto out_ctrl_put;
358361

359362
pr_debug("adding queue %d to ctrl %d.\n", qid, ctrl->cntlid);
360-
req->cqe->result.u32 = cpu_to_le32(nvmet_connect_result(ctrl));
363+
req->cqe->result.u32 = cpu_to_le32(nvmet_connect_result(ctrl, req->sq));
361364
out:
362365
kfree(d);
363366
complete:

drivers/nvme/target/nvmet.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,7 @@ void nvmet_update_cc(struct nvmet_ctrl *ctrl, u32 new);
583583

584584
struct nvmet_alloc_ctrl_args {
585585
struct nvmet_port *port;
586+
struct nvmet_sq *sq;
586587
char *subsysnqn;
587588
char *hostnqn;
588589
uuid_t *hostid;
@@ -860,7 +861,7 @@ void nvmet_execute_auth_receive(struct nvmet_req *req);
860861
int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
861862
bool set_ctrl);
862863
int nvmet_auth_set_host_hash(struct nvmet_host *host, const char *hash);
863-
u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl);
864+
u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq);
864865
void nvmet_auth_sq_init(struct nvmet_sq *sq);
865866
void nvmet_destroy_auth(struct nvmet_ctrl *ctrl);
866867
void nvmet_auth_sq_free(struct nvmet_sq *sq);
@@ -879,7 +880,8 @@ int nvmet_auth_ctrl_exponential(struct nvmet_req *req,
879880
int nvmet_auth_ctrl_sesskey(struct nvmet_req *req,
880881
u8 *buf, int buf_size);
881882
#else
882-
static inline u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl)
883+
static inline u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl,
884+
struct nvmet_sq *sq)
883885
{
884886
return 0;
885887
}

0 commit comments

Comments
 (0)