* [PATCH] nvme: add re-authentication running concurrently with reset
@ 2022-11-14 12:52 Sagi Grimberg
2022-11-14 19:03 ` Chaitanya Kulkarni
2022-11-15 9:39 ` Shinichiro Kawasaki
0 siblings, 2 replies; 3+ messages in thread
From: Sagi Grimberg @ 2022-11-14 12:52 UTC (permalink / raw)
To: Shinichiro Kawasaki; +Cc: linux-nvme, Hannes Reinecke
when re-authentication with new host-key and/or ctrl-key there is an
async work that is scheduled async. A controller reset should be mutual
exclusive with the re-authentication work. Add a test that triggers
re-authentication and immediately resets the controller.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
---
tests/nvme/046 | 112 +++++++++++++++++++++++++++++++++++++++++++++
tests/nvme/046.out | 23 ++++++++++
2 files changed, 135 insertions(+)
create mode 100755 tests/nvme/046
create mode 100644 tests/nvme/046.out
diff --git a/tests/nvme/046 b/tests/nvme/046
new file mode 100755
index 000000000000..d5c8d53ada7e
--- /dev/null
+++ b/tests/nvme/046
@@ -0,0 +1,112 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Sagi Grimberg <sagi@grimberg.me>
+#
+# Test re-authentication and reset running in parallel
+
+. tests/nvme/rc
+
+DESCRIPTION="Test re-authentication concurrently with reset"
+QUICK=1
+
+requires() {
+ _nvme_requires
+ _have_loop
+ _have_kernel_option NVME_AUTH
+ _have_kernel_option NVME_TARGET_AUTH
+ _require_nvme_trtype_is_fabrics
+ _require_nvme_cli_auth
+ _have_driver dh_generic
+}
+
+
+test() {
+ local port
+ local subsys_name="blktests-subsystem-1"
+ local hostid
+ local hostnqn
+ local file_path="${TMPDIR}/img"
+ local hostkey
+ local new_hostkey
+ local ctrlkey
+ local new_ctrlkey
+ local ctrldev
+
+ echo "Running ${TEST_NAME}"
+
+ hostid="$(uuidgen)"
+ if [ -z "$hostid" ] ; then
+ echo "uuidgen failed"
+ return 1
+ fi
+ hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
+
+ hostkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+ if [ -z "$hostkey" ] ; then
+ echo "failed to generate host key"
+ return 1
+ fi
+
+ ctrlkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+ if [ -z "$ctrlkey" ] ; then
+ echo "failed to generate ctrl key"
+ 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"
+
+ _nvme_connect_subsys "${nvme_trtype}" "${subsys_name}" \
+ "${def_traddr}" "${def_trsvcid}" \
+ "${hostnqn}" "${hostid}" \
+ "${hostkey}" "${ctrlkey}"
+
+ udevadm settle
+
+ ctrldev=$(_find_nvme_dev "${subsys_name}")
+ if [ -z "$ctrldev" ] ; then
+ echo "nvme controller not found"
+ fi
+
+ hostkey_file="/sys/class/nvme/${ctrldev}/dhchap_secret"
+ ctrlkey_file="/sys/class/nvme/${ctrldev}/dhchap_ctrl_secret"
+
+ for ((i = 0; i < 10; i++)); do
+ echo "Re-authenticate with new host key (iteration $i)"
+ new_hostkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+ _set_nvmet_hostkey "${hostnqn}" "${new_hostkey}"
+ echo "${new_hostkey}" > "${hostkey_file}"
+ _nvme_reset_ctrl $ctrldev
+
+ echo "Re-authenticate with new ctrl key (iteration $i)"
+ new_ctrlkey="$(nvme gen-dhchap-key -n ${subsys_name} 2> /dev/null)"
+ _set_nvmet_ctrlkey "${hostnqn}" "${new_ctrlkey}"
+ echo "${new_ctrlkey}" > "${ctrlkey_file}"
+ _nvme_reset_ctrl $ctrldev
+ done
+
+ nvmedev=$(_find_nvme_dev "${subsys_name}")
+
+ _run_fio_rand_io --size=8m --filename="/dev/${nvmedev}n1"
+
+ _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/046.out b/tests/nvme/046.out
new file mode 100644
index 000000000000..2d63f4e3112b
--- /dev/null
+++ b/tests/nvme/046.out
@@ -0,0 +1,23 @@
+Running nvme/046
+Re-authenticate with new host key (iteration 0)
+Re-authenticate with new ctrl key (iteration 0)
+Re-authenticate with new host key (iteration 1)
+Re-authenticate with new ctrl key (iteration 1)
+Re-authenticate with new host key (iteration 2)
+Re-authenticate with new ctrl key (iteration 2)
+Re-authenticate with new host key (iteration 3)
+Re-authenticate with new ctrl key (iteration 3)
+Re-authenticate with new host key (iteration 4)
+Re-authenticate with new ctrl key (iteration 4)
+Re-authenticate with new host key (iteration 5)
+Re-authenticate with new ctrl key (iteration 5)
+Re-authenticate with new host key (iteration 6)
+Re-authenticate with new ctrl key (iteration 6)
+Re-authenticate with new host key (iteration 7)
+Re-authenticate with new ctrl key (iteration 7)
+Re-authenticate with new host key (iteration 8)
+Re-authenticate with new ctrl key (iteration 8)
+Re-authenticate with new host key (iteration 9)
+Re-authenticate with new ctrl key (iteration 9)
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: add re-authentication running concurrently with reset
2022-11-14 12:52 [PATCH] nvme: add re-authentication running concurrently with reset Sagi Grimberg
@ 2022-11-14 19:03 ` Chaitanya Kulkarni
2022-11-15 9:39 ` Shinichiro Kawasaki
1 sibling, 0 replies; 3+ messages in thread
From: Chaitanya Kulkarni @ 2022-11-14 19:03 UTC (permalink / raw)
To: Sagi Grimberg, Shinichiro Kawasaki; +Cc: linux-nvme, Hannes Reinecke
On 11/14/22 04:52, Sagi Grimberg wrote:
> when re-authentication with new host-key and/or ctrl-key there is an
> async work that is scheduled async. A controller reset should be mutual
> exclusive with the re-authentication work. Add a test that triggers
> re-authentication and immediately resets the controller.
>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
> ---
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: add re-authentication running concurrently with reset
2022-11-14 12:52 [PATCH] nvme: add re-authentication running concurrently with reset Sagi Grimberg
2022-11-14 19:03 ` Chaitanya Kulkarni
@ 2022-11-15 9:39 ` Shinichiro Kawasaki
1 sibling, 0 replies; 3+ messages in thread
From: Shinichiro Kawasaki @ 2022-11-15 9:39 UTC (permalink / raw)
To: Sagi Grimberg; +Cc: linux-nvme, Hannes Reinecke
On Nov 14, 2022 / 14:52, Sagi Grimberg wrote:
> when re-authentication with new host-key and/or ctrl-key there is an
> async work that is scheduled async. A controller reset should be mutual
> exclusive with the re-authentication work. Add a test that triggers
> re-authentication and immediately resets the controller.
>
> Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Thanks. I believe that this test case checks fix of a problem found during your
work on "nvme: fixes, cleanups and enhancements to the dhchap-auth host code".
I have some nit comments. Other than these, the patch looks good for me.
- Shellcheck have a couple of complaints:
$ make check
shellcheck -x -e SC2119 -f gcc check new common/* \
tests/*/rc tests/*/[0-9]*[0-9]
tests/nvme/046:87:20: note: Double quote to prevent globbing and word splitting. [SC2086]
tests/nvme/046:93:20: note: Double quote to prevent globbing and word splitting. [SC2086]
make: *** [Makefile:21: check] Error 1
- The test() function lists all local variables except "hostkey_file",
"ctrlkey_file" and "nvvmedev". A bit better to declare those three also.
- It would be a bit better for linux-nvme readers to have subject prefix
"[PATCH blktests]" to clarify it is not the patch for linux, but for blktests.
--
Shin'ichiro Kawasaki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-15 9:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-14 12:52 [PATCH] nvme: add re-authentication running concurrently with reset Sagi Grimberg
2022-11-14 19:03 ` Chaitanya Kulkarni
2022-11-15 9:39 ` Shinichiro Kawasaki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.