[PATCH 1/3] nvme-fabrics: factor out auth code into helper

Chaitanya Kulkarni chaitanyak at nvidia.com
Tue Apr 23 12:57:30 PDT 2024


On 4/18/24 02:30, Sagi Grimberg wrote:
>
>
> On 08/02/2024 8:24, Chaitanya Kulkarni wrote:
>> Post connect command authentication handling code is repeated into in
>> nvmf_connect_admin_queue() and nvmf_connect_io_queue().
>>
>> Add a helper to handle post connect command authentication helper. Use
>> the same helper in nvmf_connect_admin_queue(). This also removes
>> authentication specific code from a build where authentication feature
>> is not configured.
>>
>> Signed-off-by: Chaitanya Kulkarni <kch at nvidia.com>
>> ---
>>   drivers/nvme/host/auth.c    | 32 ++++++++++++++++++++++++++++++++
>>   drivers/nvme/host/fabrics.c | 25 +------------------------
>>   drivers/nvme/host/nvme.h    |  8 ++++++++
>>   3 files changed, 41 insertions(+), 24 deletions(-)
>>
>> diff --git a/drivers/nvme/host/auth.c b/drivers/nvme/host/auth.c
>> index 3dce480d932e..159071462738 100644
>> --- a/drivers/nvme/host/auth.c
>> +++ b/drivers/nvme/host/auth.c
>> @@ -988,6 +988,38 @@ void nvme_auth_stop(struct nvme_ctrl *ctrl)
>>   }
>>   EXPORT_SYMBOL_GPL(nvme_auth_stop);
>>   +u16 nvme_auth_post_connect(struct nvme_ctrl *ctrl, u16 qid, u32 
>> result)
>> +{
>> +    int ret;
>> +
>> +    if (!(result & (NVME_CONNECT_AUTHREQ_ATR | 
>> NVME_CONNECT_AUTHREQ_ASCR)))
>> +        return NVME_SC_SUCCESS;
>
> I really dislike functions that may or may not do anything. I vote 
> that we avoid
> as much as possible.
>
> How about calling the function nvme_authenticate_queue() and more the 
> above
> condition to the call-site? 


sounds good, will send v2, thanks for the comments.

-ck




More information about the Linux-nvme mailing list