From: Hannes Reinecke <hare@suse.de>
To: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
Keith Busch <kbusch@kernel.org>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 09/10] nvme/043: test bi-directional authentication
Date: Fri, 10 Jun 2022 13:33:23 +0200 [thread overview]
Message-ID: <20220610113324.10294-10-hare@suse.de> (raw)
In-Reply-To: <20220610113324.10294-1-hare@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
tests/nvme/043 | 106 +++++++++++++++++++++++++++++++++++++++++++++
tests/nvme/043.out | 8 ++++
2 files changed, 114 insertions(+)
create mode 100644 tests/nvme/043
create mode 100644 tests/nvme/043.out
diff --git a/tests/nvme/043 b/tests/nvme/043
new file mode 100644
index 0000000..fdccb10
--- /dev/null
+++ b/tests/nvme/043
@@ -0,0 +1,106 @@
+#!/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_loop
+ _require_nvme_trtype_is_fabrics
+ _require_nvme_cli_auth
+}
+
+
+test() {
+ local port
+ local subsys_name="blktests-subsystem-1"
+ local hostid="$(uuidgen)"
+ local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
+ local file_path="${TMPDIR}/img"
+ local hostkey
+ local ctrlkey
+ local ctrldev
+
+ echo "Running ${TEST_NAME}"
+
+ hostkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+ if [ $? -ne 0 ] ; then
+ echo "nvme gen-dhchap-key command missing"
+ return 1
+ fi
+
+ ctrlkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+ if [ $? -ne 0 ] ; then
+ echo "nvme gen-dhchap-key command missing"
+ return 1
+ fi
+
+ _setup_nvmet
+
+ truncate -s 512M "${file_path}"
+
+ _create_nvmet_subsystem "${subsys_name}" "${file_path}"
+ port="$(_create_nvmet_port "${nvme_trtype}")"
+ _add_nvmet_subsys_to_port "${port}" "${subsys_name}"
+ _create_nvmet_host "${subsys_name}" "${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_name}" \
+ "${def_traddr}" "${def_trsvcid}" \
+ "${hostnqn}" "${hostid}" \
+ "${hostkey}"
+ if [ $? -ne 0 ] ; then
+ echo "nvme connect failed"
+ fi
+
+ udevadm settle
+
+ _nvme_disconnect_subsys "${subsys_name}"
+
+ # Step 2: Connect with host authentication
+ # and invalid ctrl authentication
+ echo "Test host authentication and invalid ctrl authentication"
+ _nvme_connect_subsys "${nvme_trtype}" "${subsys_name}" \
+ "${def_traddr}" "${def_trsvcid}" \
+ "${hostnqn}" "${hostid}" \
+ "${hostkey}" "${hostkey}"
+ if [ $? -eq 0 ] ; then
+ echo "nvme connect succeeded (should have failed)"
+ _nvme_disconnect_subsys "${subsys_name}"
+ fi
+
+ # Step 3: Connect with host authentication
+ # and valid ctrl authentication
+ echo "Test host authentication and valid ctrl authentication"
+ _nvme_connect_subsys "${nvme_trtype}" "${subsys_name}" \
+ "${def_traddr}" "${def_trsvcid}" \
+ "${hostnqn}" "${hostid}" \
+ "${hostkey}" "${ctrlkey}"
+ if [ $? -ne 0 ] ; then
+ echo "nvme connect failed"
+ fi
+
+ udevadm settle
+
+ _nvme_disconnect_subsys "${subsys_name}"
+
+ _remove_nvmet_subsystem_from_port "${port}" "${subsys_name}"
+ _remove_nvmet_subsystem "${subsys_name}"
+
+ _remove_nvmet_port "${port}"
+
+ _remove_nvmet_host "${hostnqn}"
+
+ rm ${file_path}
+
+ echo "Test complete"
+}
diff --git a/tests/nvme/043.out b/tests/nvme/043.out
new file mode 100644
index 0000000..a49408d
--- /dev/null
+++ b/tests/nvme/043.out
@@ -0,0 +1,8 @@
+Running nvme/043
+Test host authentication
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test host authentication and invalid ctrl authentication
+no controller found: failed to write to nvme-fabrics device
+Test host authentication and valid ctrl authentication
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete
--
2.26.2
next prev parent reply other threads:[~2022-06-10 11:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 11:33 [PATCHv5 blktests 00/10] Testsuite for nvme in-band authentication Hannes Reinecke
2022-06-10 11:33 ` [PATCH 01/10] nvme/rc: do not print error message when no nvme device is found Hannes Reinecke
2022-06-10 11:33 ` [PATCH 02/10] nvme/rc: clear allowed_hosts subdirectory Hannes Reinecke
2022-06-14 4:12 ` Shinichiro Kawasaki
2022-06-20 6:53 ` Hannes Reinecke
2022-06-10 11:33 ` [PATCH 03/10] nvme/rc: clear hosts directory in _cleanup_nvmet() Hannes Reinecke
2022-06-10 11:33 ` [PATCH 04/10] nvme/rc: add functions for in-band authentication Hannes Reinecke
2022-06-10 11:33 ` [PATCH 05/10] nvme/rc: add more arguments to _nvme_connect_subsys() Hannes Reinecke
2022-06-14 4:23 ` Shinichiro Kawasaki
2022-06-20 6:55 ` Hannes Reinecke
2022-06-10 11:33 ` [PATCH 06/10] nvme/040: create authenticated connections Hannes Reinecke
2022-06-14 4:36 ` Shinichiro Kawasaki
2022-06-20 6:56 ` Hannes Reinecke
2022-06-10 11:33 ` [PATCH 07/10] nvme/041: test dhchap key types for " Hannes Reinecke
2022-06-14 4:43 ` Shinichiro Kawasaki
2022-06-20 6:56 ` Hannes Reinecke
2022-06-10 11:33 ` [PATCH 08/10] nvme/042: test hash and dh group variations " Hannes Reinecke
2022-06-10 11:33 ` Hannes Reinecke [this message]
2022-06-10 11:33 ` [PATCH 10/10] nvme/044: test re-authentication Hannes Reinecke
2022-06-14 5:07 ` [PATCHv5 blktests 00/10] Testsuite for nvme in-band authentication Shinichiro Kawasaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220610113324.10294-10-hare@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox