[PATCH 5/6] nvmeof-tcp/005: test bi-directional authentication
Hannes Reinecke
hare at suse.de
Fri Nov 12 06:45:09 PST 2021
Signed-off-by: Hannes Reinecke <hare at suse.de>
---
tests/nvmeof-tcp/005 | 74 ++++++++++++++++++++++++++++++++++++++++
tests/nvmeof-tcp/005.out | 6 ++++
2 files changed, 80 insertions(+)
create mode 100644 tests/nvmeof-tcp/005
create mode 100644 tests/nvmeof-tcp/005.out
diff --git a/tests/nvmeof-tcp/005 b/tests/nvmeof-tcp/005
new file mode 100644
index 0000000..f33030a
--- /dev/null
+++ b/tests/nvmeof-tcp/005
@@ -0,0 +1,74 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2021 Hannes Reinecke, SUSE Labs
+#
+# Test nvme over tcp bi-directional authentication
+
+. tests/nvmeof-tcp/rc
+
+DESCRIPTION="Test bi-directional authentication for TCP connection via localhost"
+QUICK=1
+
+requires() {
+ _nvme_requires
+ _have_modules loop
+ _require_nvme_trtype_is_fabrics
+}
+
+
+test() {
+ local port
+ local genctr
+ local subsys="blktests-subsystem-"
+ local hostid="$(uuidgen)"
+ local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
+ local scratch="/tmp/blktest-ns1.img"
+ local hostkey
+
+ echo "Running ${TEST_NAME}"
+
+ hostkey="$(nvme gen-dhchap-key -n ${subsys}1 2> /dev/null)"
+ if [ $? -ne 0 ] ; then
+ echo "nvme gen-dhchap-key command missing"
+ return 1
+ fi
+
+ ctrlkey="$(nvme gen-dhchap-key -n ${subsys}1 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}1" "${scratch}"
+ _add_nvmet_subsys_to_port "${port}" "${subsys}1"
+ _create_nvmet_host "${subsys}1" "${hostnqn}" "${hostkey}"
+
+ _set_nvmet_dhgroup "${hostnqn}" "ffdhe2048"
+ _set_nvmet_ctrlkey "${hostnqn}" "${ctrlkey}"
+
+ nvme connect -t "${nvme_trtype}" -n "${subsys}1" \
+ -a "${def_traddr}" -s "${def_trsvcid}" \
+ -S "${hostkey}" -C "${ctrlkey}" \
+ --hostnqn="${hostnqn}" --hostid="${hostid}"
+
+ nvme list-subsys
+
+ nvme disconnect -n "${subsys}1"
+
+ _remove_nvmet_subsystem_from_port "${port}" "${subsys}1"
+ _remove_nvmet_subsystem "${subsys}1"
+
+ _remove_nvmet_port "${port}"
+
+ _remove_nvmet_host "${hostnqn}"
+
+ rm ${scratch}
+
+ echo "Test complete"
+}
diff --git a/tests/nvmeof-tcp/005.out b/tests/nvmeof-tcp/005.out
new file mode 100644
index 0000000..2cd467a
--- /dev/null
+++ b/tests/nvmeof-tcp/005.out
@@ -0,0 +1,6 @@
+Running nvmeof-tcp/005
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete
--
2.26.2
More information about the Linux-nvme
mailing list