@@ -31,7 +31,7 @@ void nvmet_auth_sq_init(struct nvmet_sq *sq)
3131 sq -> dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ;
3232}
3333
34- static u16 nvmet_auth_negotiate (struct nvmet_req * req , void * d )
34+ static u8 nvmet_auth_negotiate (struct nvmet_req * req , void * d )
3535{
3636 struct nvmet_ctrl * ctrl = req -> sq -> ctrl ;
3737 struct nvmf_auth_dhchap_negotiate_data * data = d ;
@@ -109,7 +109,7 @@ static u16 nvmet_auth_negotiate(struct nvmet_req *req, void *d)
109109 return 0 ;
110110}
111111
112- static u16 nvmet_auth_reply (struct nvmet_req * req , void * d )
112+ static u8 nvmet_auth_reply (struct nvmet_req * req , void * d )
113113{
114114 struct nvmet_ctrl * ctrl = req -> sq -> ctrl ;
115115 struct nvmf_auth_dhchap_reply_data * data = d ;
@@ -172,7 +172,7 @@ static u16 nvmet_auth_reply(struct nvmet_req *req, void *d)
172172 return 0 ;
173173}
174174
175- static u16 nvmet_auth_failure2 (void * d )
175+ static u8 nvmet_auth_failure2 (void * d )
176176{
177177 struct nvmf_auth_dhchap_failure_data * data = d ;
178178
@@ -186,6 +186,7 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
186186 void * d ;
187187 u32 tl ;
188188 u16 status = 0 ;
189+ u8 dhchap_status ;
189190
190191 if (req -> cmd -> auth_send .secp != NVME_AUTH_DHCHAP_PROTOCOL_IDENTIFIER ) {
191192 status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
@@ -237,30 +238,32 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
237238 if (data -> auth_type == NVME_AUTH_COMMON_MESSAGES ) {
238239 if (data -> auth_id == NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ) {
239240 /* Restart negotiation */
240- pr_debug ("%s: ctrl %d qid %d reset negotiation\n" , __func__ ,
241- ctrl -> cntlid , req -> sq -> qid );
241+ pr_debug ("%s: ctrl %d qid %d reset negotiation\n" ,
242+ __func__ , ctrl -> cntlid , req -> sq -> qid );
242243 if (!req -> sq -> qid ) {
243- if (nvmet_setup_auth (ctrl ) < 0 ) {
244- status = NVME_SC_INTERNAL ;
245- pr_err ("ctrl %d qid 0 failed to setup"
246- "re-authentication" ,
244+ dhchap_status = nvmet_setup_auth (ctrl );
245+ if (dhchap_status ) {
246+ pr_err ("ctrl %d qid 0 failed to setup re-authentication\n" ,
247247 ctrl -> cntlid );
248- goto done_failure1 ;
248+ req -> sq -> dhchap_status = dhchap_status ;
249+ req -> sq -> dhchap_step =
250+ NVME_AUTH_DHCHAP_MESSAGE_FAILURE1 ;
251+ goto done_kfree ;
249252 }
250253 }
251- req -> sq -> dhchap_step = NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ;
254+ req -> sq -> dhchap_step =
255+ NVME_AUTH_DHCHAP_MESSAGE_NEGOTIATE ;
252256 } else if (data -> auth_id != req -> sq -> dhchap_step )
253257 goto done_failure1 ;
254258 /* Validate negotiation parameters */
255- status = nvmet_auth_negotiate (req , d );
256- if (status == 0 )
259+ dhchap_status = nvmet_auth_negotiate (req , d );
260+ if (dhchap_status == 0 )
257261 req -> sq -> dhchap_step =
258262 NVME_AUTH_DHCHAP_MESSAGE_CHALLENGE ;
259263 else {
260264 req -> sq -> dhchap_step =
261265 NVME_AUTH_DHCHAP_MESSAGE_FAILURE1 ;
262- req -> sq -> dhchap_status = status ;
263- status = 0 ;
266+ req -> sq -> dhchap_status = dhchap_status ;
264267 }
265268 goto done_kfree ;
266269 }
@@ -284,15 +287,14 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
284287
285288 switch (data -> auth_id ) {
286289 case NVME_AUTH_DHCHAP_MESSAGE_REPLY :
287- status = nvmet_auth_reply (req , d );
288- if (status == 0 )
290+ dhchap_status = nvmet_auth_reply (req , d );
291+ if (dhchap_status == 0 )
289292 req -> sq -> dhchap_step =
290293 NVME_AUTH_DHCHAP_MESSAGE_SUCCESS1 ;
291294 else {
292295 req -> sq -> dhchap_step =
293296 NVME_AUTH_DHCHAP_MESSAGE_FAILURE1 ;
294- req -> sq -> dhchap_status = status ;
295- status = 0 ;
297+ req -> sq -> dhchap_status = dhchap_status ;
296298 }
297299 goto done_kfree ;
298300 case NVME_AUTH_DHCHAP_MESSAGE_SUCCESS2 :
@@ -301,13 +303,12 @@ void nvmet_execute_auth_send(struct nvmet_req *req)
301303 __func__ , ctrl -> cntlid , req -> sq -> qid );
302304 goto done_kfree ;
303305 case NVME_AUTH_DHCHAP_MESSAGE_FAILURE2 :
304- status = nvmet_auth_failure2 (d );
305- if (status ) {
306+ dhchap_status = nvmet_auth_failure2 (d );
307+ if (dhchap_status ) {
306308 pr_warn ("ctrl %d qid %d: authentication failed (%d)\n" ,
307- ctrl -> cntlid , req -> sq -> qid , status );
308- req -> sq -> dhchap_status = status ;
309+ ctrl -> cntlid , req -> sq -> qid , dhchap_status );
310+ req -> sq -> dhchap_status = dhchap_status ;
309311 req -> sq -> authenticated = false;
310- status = 0 ;
311312 }
312313 goto done_kfree ;
313314 default :
0 commit comments