[PATCH 09/10] nvme/042: test bi-directional authentication
Sagi Grimberg
sagi at grimberg.me
Sun Nov 28 05:36:42 PST 2021
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?
More information about the Linux-nvme
mailing list