nvmet: Add 'sq' argument to alloc_ctrl_args
authorHannes Reinecke <hare@kernel.org>
Mon, 24 Feb 2025 12:38:16 +0000 (13:38 +0100)
committerKeith Busch <kbusch@kernel.org>
Thu, 20 Mar 2025 23:53:54 +0000 (16:53 -0700)
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 <dlemoal@kernel.org>
Signed-off-by: Hannes Reinecke <hare@kernel.org>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
drivers/nvme/target/auth.c
drivers/nvme/target/core.c
drivers/nvme/target/fabrics-cmd-auth.c
drivers/nvme/target/fabrics-cmd.c
drivers/nvme/target/nvmet.h

index b47d675232d2d8171e429f3a913b1cdf015df480..d0392ccda2a1d8b3d7da7aa1aab6990f0c6b0853 100644 (file)
@@ -139,7 +139,7 @@ int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id)
        return ret;
 }
 
-u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl)
+u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq)
 {
        int ret = 0;
        struct nvmet_host_link *p;
index cdc4a09a6e8a48d39210f459049cc831918b847c..112df8970954b5ded5056ca8980e37d634532fc3 100644 (file)
@@ -1649,7 +1649,7 @@ struct nvmet_ctrl *nvmet_alloc_ctrl(struct nvmet_alloc_ctrl_args *args)
        if (args->hostid)
                uuid_copy(&ctrl->hostid, args->hostid);
 
-       dhchap_status = nvmet_setup_auth(ctrl);
+       dhchap_status = nvmet_setup_auth(ctrl, args->sq);
        if (dhchap_status) {
                pr_err("Failed to setup authentication, dhchap status %u\n",
                       dhchap_status);
index 2022757f08dc76be3b332e738352095e3a5ebf8d..43b684af816cbec7932f6e562429e0f66f672078 100644 (file)
@@ -246,7 +246,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
                        pr_debug("%s: ctrl %d qid %d reset negotiation\n",
                                 __func__, ctrl->cntlid, req->sq->qid);
                        if (!req->sq->qid) {
-                               dhchap_status = nvmet_setup_auth(ctrl);
+                               dhchap_status = nvmet_setup_auth(ctrl, req->sq);
                                if (dhchap_status) {
                                        pr_err("ctrl %d qid 0 failed to setup re-authentication\n",
                                               ctrl->cntlid);
index eb406c90c16793b8890f79d16ae5505102ec0261..5e8a3e1ca79cb32b2064be7eb1df4e853469a76f 100644 (file)
@@ -234,10 +234,12 @@ err:
        return ret;
 }
 
-static u32 nvmet_connect_result(struct nvmet_ctrl *ctrl)
+static u32 nvmet_connect_result(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq)
 {
+       bool needs_auth = nvmet_has_auth(ctrl);
+
        return (u32)ctrl->cntlid |
-               (nvmet_has_auth(ctrl) ? NVME_CONNECT_AUTHREQ_ATR : 0);
+               (needs_auth ? NVME_CONNECT_AUTHREQ_ATR : 0);
 }
 
 static void nvmet_execute_admin_connect(struct nvmet_req *req)
@@ -247,6 +249,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
        struct nvmet_ctrl *ctrl = NULL;
        struct nvmet_alloc_ctrl_args args = {
                .port = req->port,
+               .sq = req->sq,
                .ops = req->ops,
                .p2p_client = req->p2p_client,
                .kato = le32_to_cpu(c->kato),
@@ -299,7 +302,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
                goto out;
        }
 
-       args.result = cpu_to_le32(nvmet_connect_result(ctrl));
+       args.result = cpu_to_le32(nvmet_connect_result(ctrl, req->sq));
 out:
        kfree(d);
 complete:
@@ -357,7 +360,7 @@ static void nvmet_execute_io_connect(struct nvmet_req *req)
                goto out_ctrl_put;
 
        pr_debug("adding queue %d to ctrl %d.\n", qid, ctrl->cntlid);
-       req->cqe->result.u32 = cpu_to_le32(nvmet_connect_result(ctrl));
+       req->cqe->result.u32 = cpu_to_le32(nvmet_connect_result(ctrl, req->sq));
 out:
        kfree(d);
 complete:
index 4be8d22d2d8d417b0eb285a35b7d51cf5be23bdd..e0cfdae8af6de01cf71828c28d5e66449f040edf 100644 (file)
@@ -583,6 +583,7 @@ void nvmet_update_cc(struct nvmet_ctrl *ctrl, u32 new);
 
 struct nvmet_alloc_ctrl_args {
        struct nvmet_port       *port;
+       struct nvmet_sq         *sq;
        char                    *subsysnqn;
        char                    *hostnqn;
        uuid_t                  *hostid;
@@ -860,7 +861,7 @@ void nvmet_execute_auth_receive(struct nvmet_req *req);
 int nvmet_auth_set_key(struct nvmet_host *host, const char *secret,
                       bool set_ctrl);
 int nvmet_auth_set_host_hash(struct nvmet_host *host, const char *hash);
-u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl);
+u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq);
 void nvmet_auth_sq_init(struct nvmet_sq *sq);
 void nvmet_destroy_auth(struct nvmet_ctrl *ctrl);
 void nvmet_auth_sq_free(struct nvmet_sq *sq);
@@ -879,7 +880,8 @@ int nvmet_auth_ctrl_exponential(struct nvmet_req *req,
 int nvmet_auth_ctrl_sesskey(struct nvmet_req *req,
                            u8 *buf, int buf_size);
 #else
-static inline u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl)
+static inline u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl,
+                                 struct nvmet_sq *sq)
 {
        return 0;
 }