[PATCH 09/10] nvme/042: test bi-directional authentication

Hannes Reinecke hare at suse.de
Fri Dec 10 04:06:34 PST 2021


On 12/8/21 2:09 PM, Sagi Grimberg wrote:
> 
> 
> On 11/28/21 7:34 PM, Hannes Reinecke wrote:
>> On 11/28/21 2:36 PM, Sagi Grimberg wrote:
>>>
>>>
>>> On 11/23/21 9:49 AM, Hannes Reinecke wrote:
>>>> Signed-off-by: Hannes Reinecke <hare at suse.de>
>>>> ---
>>>>   tests/nvme/042     | 107
>>>> +++++++++++++++++++++++++++++++++++++++++++++
>>>>   tests/nvme/042.out |   8 ++++
>>>>   2 files changed, 115 insertions(+)
>>>>   create mode 100644 tests/nvme/042
>>>>   create mode 100644 tests/nvme/042.out
>>>>
>>>> diff --git a/tests/nvme/042 b/tests/nvme/042
>>>> new file mode 100644
>>>> index 0000000..f3954b4
>>>> --- /dev/null
>>>> +++ b/tests/nvme/042
>>>> @@ -0,0 +1,107 @@
>>>> +#!/bin/bash
>>>> +# SPDX-License-Identifier: GPL-3.0+
>>>> +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs
>>>> +#
>>>> +# Test bi-directional authentication
>>>> +
>>>> +. tests/nvme/rc
>>>> +
>>>> +DESCRIPTION="Test bi-directional authentication"
>>>> +QUICK=1
>>>> +
>>>> +requires() {
>>>> +    _nvme_requires
>>>> +    _have_modules loop
>>>> +    _require_nvme_trtype_is_fabrics
>>>> +}
>>>> +
>>>> +
>>>> +test() {
>>>> +    local port
>>>> +    local subsys="blktests-subsystem-1"
>>>> +    local hostid="$(uuidgen)"
>>>> +    local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
>>>> +    local scratch="/tmp/blktest-ns1.img"
>>>> +    local hostkey
>>>> +    local ctrlkey
>>>> +    local ctrldev
>>>> +
>>>> +    echo "Running ${TEST_NAME}"
>>>> +
>>>> +    hostkey="$(nvme gen-dhchap-key -n ${subsys} 2> /dev/null)"
>>>> +    if [ $? -ne 0 ] ; then
>>>> +        echo "nvme gen-dhchap-key command missing"
>>>> +        return 1
>>>> +    fi
>>>> +
>>>> +    ctrlkey="$(nvme gen-dhchap-key -n ${subsys} 2> /dev/null)"
>>>> +    if [ $? -ne 0 ] ; then
>>>> +        echo "nvme gen-dhchap-key command missing"
>>>> +        return 1
>>>> +    fi
>>>> +
>>>> +    _setup_nvmet
>>>> +
>>>> +    truncate -s 512M "${scratch}"
>>>> +
>>>> +    port="$(_create_nvmet_port "${nvme_trtype}")"
>>>> +
>>>> +    _create_nvmet_subsystem "${subsys}" "${scratch}"
>>>> +    _add_nvmet_subsys_to_port "${port}" "${subsys}"
>>>> +    _create_nvmet_host "${subsys}" "${hostnqn}" "${hostkey}"
>>>> "${ctrlkey}"
>>>> +
>>>> +    _set_nvmet_dhgroup "${hostnqn}" "ffdhe2048"
>>>> +
>>>> +    # Step 1: Connect with host authentication only
>>>> +    echo "Test host authentication"
>>>> +    _nvme_connect_subsys "${nvme_trtype}" "${subsys}" \
>>>> +                 "${def_traddr}" "${def_trsvcid}" \
>>>> +                 "${hostnqn}" "${hostid}" \
>>>> +                 "${hostkey}"
>>>> +
>>>> +    ctrldev=$(_find_nvme_dev "${subsys}")
>>>> +    if [ -z "$ctrldev" ] ; then
>>>> +        echo "nvme controller not found"
>>>> +    fi
>>>> +
>>>> +    _nvme_disconnect_subsys "${subsys}"
>>>> +
>>>> +    # Step 2: Connect with host authentication
>>>> +    # and invalid ctrl authentication
>>>> +    echo "Test host authentication and invalid ctrl authentication"
>>>> +    _nvme_connect_subsys "${nvme_trtype}" "${subsys}" \
>>>> +                 "${def_traddr}" "${def_trsvcid}" \
>>>> +                 "${hostnqn}" "${hostid}" \
>>>> +                 "${hostkey}" "${hostkey}"
>>>> +    ctrldev=$(_find_nvme_dev "${subsys}1")
>>>> +    if [ -n "${ctrldev}" ] ; then
>>>> +        echo "nvme controller found!"
>>>> +        _nvme_disconnect_subsys "${ctrldev}"
>>>> +    fi
>>>
>>> This test case has a weird behavior. Why isn't _nvme_connect_subsys
>>> failing?
>>
>> Oh, but it is.
>> The line 'nvme controller found' is not part of the .out file, hence
>> the test will fail.
>>
>> Call it an obscure feature of blktests :-)
>>
>> But yeah, I can make it more obvious that this is the failure case.
> 
> Hannes, my question is why isn't nvme connect not failing (i.e.
> returning a non-zero status code)?
> 
I guess it does, but we're never actually checking the return value.
Let me check.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare at suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer



More information about the Linux-nvme mailing list