Skip to contentSkip to conversation

nvme: make NVME_TARGET_CONTROL work with remote targets

PATCH In review Daniel Wagner 3 participants 16 messages Nov 18 – Dec 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover nvme: make NVME_TARGET_CONTROL work with remote targets

Hi all,

this series makes running the nvme tests against a remote target with NVME_TARGET_CONTROL actually work. The first six patches of v1 have been applied, this is the rest. It applies on top of the series that makes tests skip when a program they need is missing.

The first two patches are fixes: nvme/047 looks up the namespace again after reconnecting, and the nvmet target picks free service IDs for its ports. The third is a cleanup, nvme/042 and nvme/043 iterate over the DH-HMAC-CHAP hashes by name.

The remaining patches let tests skip instead of failing when the remote target lacks a feature they need, including the DH-HMAC-CHAP hashes and DH groups the target doesn't support, add port and host key support for remote targets, and add a NetApp ONTAP target as an example of a target that can do less than nvmet.

Tested against nvmet in a second VM, which also exported other subsystems on its own ports, and against a NetApp ONTAP array. All tests that can run against a remote target pass, except nvme/077 against nvmet, which checks attr_qid_max in the local nvmet configfs. Against the array, nvme/061 and nvme/070 fail because it refuses the reconnect after a subsystem is deleted and doesn't support Identify CNS 07h, and nvme/068 because the host runs a 6.4 kernel. The tests that need the kernel target still pass with the local target.

---
Changes in v2:
- Drop the six patches that were applied.
- Fix nvme/047 to look up the namespace again after reconnecting.
- Pick free service IDs for new nvmet ports.
- Pass the TLS option in the argument array instead of an unquoted
command substitution; quoting it would pass an empty argument without
TLS. (Shin'ichiro)
- Check the features with =~, with an SC2076 exception for the literal
match. (Shin'ichiro)
- List the DH-HMAC-CHAP algorithms a target supports, iterate over them
by name in nvme/042 and nvme/043 and skip the ones the target lacks.
- Put the fixes first, then the cleanup, then the features.
- Depend on the series that makes tests skip when a program is missing.
- Link to v1: https://patch.msgid.link/[email protected]

---
Daniel Wagner (9):
nvme/047: look up the namespace again after reconnecting contrib/nvme-target-control: pick a free service ID for new nvmet ports nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name
nvme: skip tests that need a feature the remote target lacks contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms
nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support common/nvme: support the ports of a remote target
nvme/rc: change the host keys on a remote target contrib/nvme-target-control: add a NetApp ONTAP target

 Documentation/running-tests.md                     |  49 ++-
 common/nvme                                        |  88 ++++-
 contrib/nvme-target-control/README.md              |  72 +++-
 .../nvme_target_control/target.py                  |  19 +
 .../nvme_target_control/targets/nvmet.py           |  12 +-
 .../nvme_target_control/targets/nvmet.sh           |   7 +-
 .../nvme_target_control/targets/ontap.py           | 397 +++++++++++++++++++++
 contrib/nvme-target-control/tests/test_ontap.py    | 357 ++++++++++++++++++
 .../tests/test_target_control.py                   |   4 +-
 tests/nvme/031                                     |   1 +
 tests/nvme/041                                     |   1 +
 tests/nvme/042                                     |  12 +-
 tests/nvme/042.out                                 |   8 +-
 tests/nvme/043                                     |   9 +-
 tests/nvme/043.out                                 |   6 +-
 tests/nvme/044                                     |   1 +
 tests/nvme/045                                     |   1 +
 tests/nvme/047                                     |   2 +
 tests/nvme/057                                     |   1 +
 tests/nvme/062                                     |   1 +
 tests/nvme/063                                     |   5 +-
 tests/nvme/rc                                      |  58 +++
 22 files changed, 1069 insertions(+), 42 deletions(-)

---
base-commit: 79c32fb31b7bca6a4383b749030128683cf6b6b4
change-id: 20261104-nvme-target-control-f0b239e68b29
prerequisite-change-id: 20261117-skip-missing-deps-30b4084698c4:v1
prerequisite-patch-id: 9478a4106d922c8432a4d297dcb18ed68a9c8d61
prerequisite-patch-id: 635fcb82ae72c78b84ad593a58d82315a166724d
prerequisite-patch-id: 528ad89bda84f0b0d9cbc0d38b6e1384332f86cd
prerequisite-patch-id: 2758a16b44a326eea5113ff4967e6093ad42e71c
prerequisite-patch-id: 9acbf0ff52b0b46035e4635035662cd9d9309f77

Best regards,

Signature · 1 line
Daniel Wagner <[email protected]>
#1 lore raw

PATCH v2 1/9 nvme/047: look up the namespace again after reconnecting

nvme/047 keeps using the namespace name from the first connect after reconnecting. The name can change when other controllers come and go, and fio then fails to open the device. Look it up again after the second connect.

Fixes 7497d8b45817 ("nvme/047: Test different queue types for fabrics transports")
---
 tests/nvme/047 | 2 ++
 1 file changed, 2 insertions(+)
tests/nvme/047 +2 -0
index 433090f2d6f2..2aeee2f0f1aa 100755
@@ -42,6 +42,8 @@ test() {
 
 	_nvme_connect_subsys --nr-write-queues 1 --nr-poll-queues 1
 
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
+
 	_run_fio_rand_io --filename="/dev/${ns}" --size="${rand_io_size}"
 
 	_nvme_disconnect_subsys >> "$FULL" 2>&1
Signature · 1 line
2.56.1
#2 lore raw

Re: [PATCH blktests v2 1/9] nvme/047: look up the namespace again after reconnecting

Quoted 17 lines · Daniel Wagner

nvme/047 keeps using the namespace name from the first connect after reconnecting. The name can change when other controllers come and go, and fio then fails to open the device. Look it up again after the second connect.

Fixes 7497d8b45817 ("nvme/047: Test different queue types for fabrics transports")
---
  tests/nvme/047 | 2 ++
  1 file changed, 2 insertions(+)
tests/nvme/047 +0 -0
index 433090f2d6f2..2aeee2f0f1aa 100755

tests/nvme/047 test() { · line 49

Quoted 8 lines
tests/nvme/047 +2 -0
@@ -42,6 +42,8 @@ test() {
 
  	_nvme_connect_subsys --nr-write-queues 1 --nr-poll-queues 1
 
+	ns=$(_find_nvme_ns "${def_subsys_uuid}")
+
  	_run_fio_rand_io --filename="/dev/${ns}" --size="${rand_io_size}"
 
  	_nvme_disconnect_subsys >> "$FULL" 2>&1

What's a bit awkward is this 'subsys_uuid'; one is confused why we would set the subsystem UUID as the UUID of the namespace. Eg what would happen if we were using (or wanting to specify) more than one namespace?
Can't we rename it to 'ns_uuid' to make the scope clear?

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#3 lore raw

PATCH v2 2/9 contrib/nvme-target-control: pick a free service ID for new nvmet ports

In reply to Daniel Wagner

The nvmet target derives the service ID from the port ID. On a target that already has ports this clashes with existing ports, and nvme/003 connects to a service ID nothing listens on. Use the lowest free service ID starting at trsvid instead.

Fixes 79c32fb31b7b ("contrib: make nvme-target-control a standalone project")
---
 contrib/nvme-target-control/README.md                       | 13 +++++++------
 .../nvme_target_control/targets/nvmet.sh                    |  7 ++++++-
 2 files changed, 13 insertions(+), 7 deletions(-)
contrib/nvme-target-control/README.md +7 -6
index dc421b00b788..9abd7f30932d 100644
@@ -61,12 +61,13 @@ is set, the namespace is a loop device on an image file in
 subsystem, the ports which don't export another subsystem, the hosts no
 other subsystem allows, and the loop device and image file.
 
-A new port gets the lowest free nvmet port ID N, starting at 1, and listens
-on `traddr` at service ID `trsvid` + N - 1. The first port of a target
-without other ports listens on `trsvid`. The nvmet target implements all
-port commands: `add-ports`, `add-port`, `remove-port`, `list-ports`,
-`show-port` and `set-ana`, and `set-host`, which changes the DH-CHAP keys,
-hash and DH group of the host.
+A new port gets the lowest free nvmet port ID, starting at 1, and the
+lowest service ID from `trsvid` up which no other port uses: the first
+port listens on `traddr` at `trsvid` unless another port of the target
+does. The nvmet target implements all port commands: `add-ports`,
+`add-port`, `remove-port`, `list-ports`, `show-port` and `set-ana`, and
+`set-host`, which changes the DH-CHAP keys, hash and DH group of the
+host.
 
 | Option | Meaning |
 | --- | --- |
contrib/nvme-target-control/nvme_target_control/targets/nvmet.sh +6 -1
index 33f383eb17f0..7d6e9cd40da0 100644
@@ -59,6 +59,11 @@ add_port() {
 	while [ -e "${cfs}/ports/${port}" ]; do
 		port=$((port + 1))
 	done
+	# The target may have other ports, take the first free service ID.
+	while cat "${cfs}"/ports/*/addr_trsvcid 2> /dev/null |
+			grep -qx "${trsvcid}"; do
+		trsvcid=$((trsvcid + 1))
+	done
 	case "${traddr}" in
 	*:*)	adrfam=ipv6 ;;
 	*)	adrfam=ipv4 ;;
@@ -68,7 +73,7 @@ add_port() {
 	echo "${trtype}" > "${cfs}/ports/${port}/addr_trtype"
 	echo "${adrfam}" > "${cfs}/ports/${port}/addr_adrfam"
 	echo "${traddr}" > "${cfs}/ports/${port}/addr_traddr"
-	echo $((trsvcid + port - 1)) > "${cfs}/ports/${port}/addr_trsvcid"
+	echo "${trsvcid}" > "${cfs}/ports/${port}/addr_trsvcid"
 	case "${tls}" in
 	none)
 		;;
Signature · 1 line
2.56.1
#4 lore raw

PATCH v2 3/9 nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name

In reply to Daniel Wagner

nvme/042 iterates over the numeric hash IDs nvme-cli takes, nvme/043 over the hash names of the nvmet configfs. Add a --hash option to _nvme_gen_kxchap_secret which takes the hash name, and use the plain names in both tests, and in nvme/063.

---
 common/nvme        | 18 ++++++++++++++++++
 tests/nvme/042     | 10 +++++-----
 tests/nvme/042.out |  8 ++++----
 tests/nvme/043     |  6 +++---
 tests/nvme/043.out |  6 +++---
 tests/nvme/063     |  4 ++--
 6 files changed, 35 insertions(+), 17 deletions(-)
common/nvme +18 -0
index dfe85b6e281f..6fba3890b6ce 100644
@@ -168,9 +168,27 @@ _nvme_run() {
 	nvme $(_nvme_cmd "$current") "$@"
 }
 
+# Generate a DH-HMAC-CHAP secret. --hash=HASH transforms the secret with HASH:
+# none, sha256, sha384 or sha512. The other arguments go to nvme-cli.
 _nvme_gen_kxchap_secret() {
+	local -a secret_args=()
+	local -A hmac_ids=([none]=0 [sha256]=1 [sha384]=2 [sha512]=3)
+
 	_nvme_cli_detect_version
 
+	while (($#)); do
+		case "$1" in
+		--hash=*)
+			secret_args+=("--hmac=${hmac_ids[${1#--hash=}]}")
+			;;
+		*)
+			secret_args+=("$1")
+			;;
+		esac
+		shift
+	done
+	set -- "${secret_args[@]}"
+
 	if ((!_is_nvme_cli_pre_v3)); then
 		local -a kxchap_args=()
 
tests/nvme/042 +5 -5
index bddbd1bbfc28..7c558e287805 100755
@@ -27,18 +27,18 @@ test() {
 
 	_setup_nvmet
 
-	local hmac
+	local hash
 	local key_len
 	local hostkey
 	local ctrldev
 
 	_nvmet_target_setup --blkdev file
 
-	for hmac in 0 1 2 3; do
-		echo "Testing hmac ${hmac}"
-		hostkey="$(_nvme_gen_kxchap_secret --hmac=${hmac} 2> /dev/null)"
+	for hash in none sha256 sha384 sha512; do
+		echo "Testing hash ${hash}"
+		hostkey="$(_nvme_gen_kxchap_secret --hash="${hash}" 2> /dev/null)"
 		if [ -z "$hostkey" ] ; then
-			echo "couldn't generate host key for hmac ${hmac}"
+			echo "couldn't generate host key for hash ${hash}"
 			return 1
 		fi
 		_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
tests/nvme/042.out +4 -4
index 1c3fc6130696..9a9fc697b4f5 100644
@@ -1,8 +1,8 @@
 Running nvme/042
-Testing hmac 0
-Testing hmac 1
-Testing hmac 2
-Testing hmac 3
+Testing hash none
+Testing hash sha256
+Testing hash sha384
+Testing hash sha512
 Testing key length 32
 Testing key length 48
 Testing key length 64
tests/nvme/043 +3 -3
index ac25610a402b..f85916c842fe 100755
@@ -41,18 +41,18 @@ test() {
 
 	_nvmet_target_setup --blkdev file --hostkey "${hostkey}"
 
-	for hash in "hmac(sha256)" "hmac(sha384)" "hmac(sha512)" ; do
+	for hash in sha256 sha384 sha512; do
 
 		echo "Testing hash ${hash}"
 
-		_set_nvmet_hash "${def_hostnqn}" "${hash}"
+		_set_nvmet_hash "${def_hostnqn}" "hmac(${hash})"
 
 		_nvme_connect_subsys --dhchap-secret "${hostkey}"
 
 		_nvme_disconnect_subsys
 	done
 
-	for dhgroup in "ffdhe2048" "ffdhe3072" "ffdhe4096" "ffdhe6144" "ffdhe8192" ; do
+	for dhgroup in ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192; do
 
 		echo "Testing DH group ${dhgroup}"
 
tests/nvme/043.out +3 -3
index f3f55a4449b6..c99949489070 100644
@@ -1,7 +1,7 @@
 Running nvme/043
-Testing hash hmac(sha256)
-Testing hash hmac(sha384)
-Testing hash hmac(sha512)
+Testing hash sha256
+Testing hash sha384
+Testing hash sha512
 Testing DH group ffdhe2048
 Testing DH group ffdhe3072
 Testing DH group ffdhe4096
tests/nvme/063 +2 -2
index feb07bf3a06c..ff8e0ab90026 100755
@@ -34,7 +34,7 @@ test() {
 
 	_systemctl_start tlshd
 
-	hostkey=$(_nvme_gen_kxchap_secret --hmac 1 2> /dev/null)
+	hostkey=$(_nvme_gen_kxchap_secret --hash=sha256 2> /dev/null)
 	if [ -z "$hostkey" ] ; then
 		echo "key generation failed"
 		_systemctl_stop
@@ -76,7 +76,7 @@ test() {
 
 	_nvme_disconnect_subsys
 
-	hostkey=$(_nvme_gen_kxchap_secret --hmac 2 2> /dev/null)
+	hostkey=$(_nvme_gen_kxchap_secret --hash=sha384 2> /dev/null)
 	if [ -z "$hostkey" ] ; then
 		echo "key generation failed"
 		_systemctl_stop
Signature · 1 line
2.56.1
#5 lore raw

Re: [PATCH blktests v2 3/9] nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name

Quoted 6 lines · Daniel Wagner

nvme/042 iterates over the numeric hash IDs nvme-cli takes, nvme/043 over the hash names of the nvmet configfs. Add a --hash option to _nvme_gen_kxchap_secret which takes the hash name, and use the plain names in both tests, and in nvme/063.

Quoted 8 lines
---
 common/nvme        | 18 ++++++++++++++++++
 tests/nvme/042     | 10 +++++-----
 tests/nvme/042.out |  8 ++++----
 tests/nvme/043     |  6 +++---
 tests/nvme/043.out |  6 +++---
 tests/nvme/063     |  4 ++--
 6 files changed, 35 insertions(+), 17 deletions(-)

This patch touches nvme/063 also. When I apply this patch, I will modify the commit title to include nvme/063.

#6 lore raw

PATCH v2 4/9 nvme: skip tests that need a feature the remote target lacks

In reply to Daniel Wagner

A remote target does not have to implement the optional commands, e.g. a storage array has fixed ports and manages the ANA state itself. Tests that use a missing command fail instead of being skipped.

Add a _require_nvme_target_control_feature helper that checks the output of "config --show-features", and use it in the tests that need ports, ANA, host keys or TLS. No target lists tls yet, as blktests can't pass a TLS key to the script.

---
 Documentation/running-tests.md |  5 +++++
 tests/nvme/031                 |  1 +
 tests/nvme/042                 |  1 +
 tests/nvme/043                 |  1 +
 tests/nvme/044                 |  1 +
 tests/nvme/045                 |  1 +
 tests/nvme/057                 |  1 +
 tests/nvme/062                 |  1 +
 tests/nvme/063                 |  1 +
 tests/nvme/rc                  | 19 +++++++++++++++++++
 10 files changed, 32 insertions(+)
Documentation/running-tests.md +5 -0
index 095d6aa4e18e..b66bdf9cb2e8 100644
@@ -248,6 +248,7 @@ The blktests expects that the script interface implements following
   --show-trsvid
   --show-subsys-uuid
   --show-subsysnqn
+  --show-features
 
 setup:
   --subsysnqn SUBSYSNQN
@@ -259,6 +260,10 @@ The blktests expects that the script interface implements following
 cleanup:
   --subsysnqn SUBSYSNQN
 
+config --show-features prints the optional commands the script supports,
+e.g. add-port, set-ana or set-host, and tls if the target can set up TLS.
+blktests skips the tests which need a feature the list lacks.
+
 contrib/nvme-target-control implements this interface. It configures a Linux
 nvmet target over ssh and can be extended for other targets, see
 contrib/nvme-target-control/README.md.
tests/nvme/031 +1 -0
index cd69e8ef13ac..b12e24489740 100755
@@ -21,6 +21,7 @@ requires() {
 	_nvme_requires
 	_have_loop
 	_require_nvme_trtype_is_fabrics
+	_require_nvme_target_control_feature add-port remove-port
 }
 
 set_conditions() {
tests/nvme/042 +1 -0
index 7c558e287805..e771cb6ca4aa 100755
@@ -16,6 +16,7 @@ requires() {
 	_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
+	_require_nvme_target_control_feature set-host
 }
 
 set_conditions() {
tests/nvme/043 +1 -0
index f85916c842fe..eb8f8b035f6d 100755
@@ -17,6 +17,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
+	_require_nvme_target_control_feature set-host
 }
 
 set_conditions() {
tests/nvme/044 +1 -0
index 1d9202143cf4..c1a48f1e3d86 100755
@@ -17,6 +17,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
+	_require_nvme_target_control_feature set-host
 }
 
 set_conditions() {
tests/nvme/045 +1 -0
index 78a1c607e9c6..14f4949e198e 100755
@@ -18,6 +18,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
+	_require_nvme_target_control_feature set-host
 }
 
 set_conditions() {
tests/nvme/057 +1 -0
index 0a5cfa4df1a8..6c45af8b5ed9 100755
@@ -13,6 +13,7 @@ requires() {
 	_have_loop
 	_have_fio
 	_require_nvme_trtype_is_fabrics
+	_require_nvme_target_control_feature list-ports show-port set-ana
 }
 
 set_conditions() {
tests/nvme/062 +1 -0
index eabe2d99bdcc..4402b848ecee 100755
@@ -18,6 +18,7 @@ requires() {
 	_require_nvme_cli_tls
 	_have_libnvme_ver 1 11
 	_have_systemd_tlshd_service
+	_require_nvme_target_control_feature tls
 }
 
 set_conditions() {
tests/nvme/063 +1 -0
index ff8e0ab90026..20aabd91ca80 100755
@@ -19,6 +19,7 @@ requires() {
 	_require_nvme_trtype tcp
 	_require_nvme_cli_auth
 	_have_systemd_tlshd_service
+	_require_nvme_target_control_feature set-host tls
 }
 
 set_conditions() {
tests/nvme/rc +19 -0
index 8abd14eeb112..41811c033069 100644
@@ -155,6 +155,25 @@ _require_remote_nvme_target() {
 	return 0
 }
 
+# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features,
+# the optional commands and e.g. tls, see Documentation/running-tests.md.
+_require_nvme_target_control_feature() {
+	local features feature
+
+	if [[ -z "${nvme_target_control}" ]]; then
+		return 0
+	fi
+	features=" $("${nvme_target_control}" config --show-features) "
+	for feature in "$@"; do
+		# shellcheck disable=SC2076 # match the feature literally
+		if [[ ! "${features}" =~ " ${feature} " ]]; then
+			SKIP_REASONS+=("NVME_TARGET_CONTROL target does not support ${feature}")
+			return 1
+		fi
+	done
+	return 0
+}
+
 _test_dev_nvme_ctrl() {
 	echo "/dev/char/$(cat "${TEST_DEV_SYSFS}/device/dev")"
 }
Signature · 1 line
2.56.1
#7 lore raw

PATCH v2 5/9 contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms

In reply to Daniel Wagner

Not all targets support all DH-HMAC-CHAP hashes and DH groups, e.g. ONTAP doesn't support SHA-384. List the ones a target supports as features, e.g. dhchap-sha384 or dhchap-ffdhe2048, so that the tests can check for them. The nvmet target lists all of them.

---
 contrib/nvme-target-control/README.md                  | 11 +++++++----
 .../nvme-target-control/nvme_target_control/target.py  | 18 ++++++++++++++++++
 .../nvme_target_control/targets/nvmet.py               | 12 +++++++++++-
 .../nvme-target-control/tests/test_target_control.py   |  4 +++-
 4 files changed, 39 insertions(+), 6 deletions(-)
contrib/nvme-target-control/README.md +7 -4
index 9abd7f30932d..8afbfc0be322 100644
@@ -118,10 +118,13 @@ channel is a subclass of `Channel` which returns the command running
 The port commands and `set-host` are optional. A target implements them
 by overriding `add_ports`, `add_port`, `remove_port`, `list_ports`,
 `show_port`, `set_ana` and `set_host`. `config --show-features` lists the
-ones it overrides, followed by the class attribute `extra_features`, e.g.
-`tls`. blktests skips the tests which need a feature the target doesn't
-list. Without `list-ports` and `show-port`, blktests connects to `traddr`
-and `trsvid`.
+ones it overrides, followed by the class attribute `extra_features`: the
+DH-HMAC-CHAP hashes and DH groups the target supports, e.g.
+`dhchap-sha256` or `dhchap-ffdhe2048` (`dhchap_features()` builds them),
+and `tls` if it sets up TLS. blktests skips the tests which need a
+feature the target doesn't list, and the steps of nvme/042 and nvme/043
+which use an algorithm the target doesn't list. Without `list-ports` and
+`show-port`, blktests connects to `traddr` and `trsvid`.
 
 ## Development
 
contrib/nvme-target-control/nvme_target_control/target.py +18 -0
index d648826e0386..1b3576bffbbf 100644
@@ -11,6 +11,7 @@ API, can be added as 'package.module:Class' in the [target] 'type' option.
 
 import socket
 from abc import ABC, abstractmethod
+from collections.abc import Iterable
 from dataclasses import dataclass
 from pathlib import Path
 from typing import Any, ClassVar
@@ -23,6 +24,23 @@ DEF_SUBSYSNQN = 'blktests-subsystem-1'
 DEF_SUBSYS_UUID = '91fdba0d-f87b-4c25-b80f-db7be1418b9e'
 DEF_TRSVCID = '4420'
 
+# The DH-HMAC-CHAP hashes and DH groups, named as in the nvmet configfs
+# without hmac() around the hash
+DHCHAP_HASHES = ('sha256', 'sha384', 'sha512')
+DHCHAP_DHGROUPS = (
+    'null',
+    'ffdhe2048',
+    'ffdhe3072',
+    'ffdhe4096',
+    'ffdhe6144',
+    'ffdhe8192',
+)
+
+
+def dhchap_features(algorithms: Iterable[str]) -> tuple[str, ...]:
+    """Return the features for the DH-HMAC-CHAP hashes and DH groups."""
+    return tuple(f'dhchap-{alg}' for alg in algorithms)
+
 
 @dataclass(frozen=True)
 class Subsystem:
contrib/nvme-target-control/nvme_target_control/targets/nvmet.py +11 -1
index f5f2e8cc2a62..468417f2ca7e 100644
@@ -24,7 +24,15 @@ from pathlib import Path
 from typing import Any
 
 from .. import channel
-from ..target import Port, Subsystem, Target, resolve
+from ..target import (
+    DHCHAP_DHGROUPS,
+    DHCHAP_HASHES,
+    Port,
+    Subsystem,
+    Target,
+    dhchap_features,
+    resolve,
+)
 
 SCRIPT = Path(__file__).resolve().parent / 'nvmet.sh'
 
@@ -40,6 +48,8 @@ HOST_ATTRS = {
 class NvmetTarget(Target):
     """Linux nvmet target."""
 
+    extra_features = dhchap_features(DHCHAP_HASHES + DHCHAP_DHGROUPS)
+
     def __init__(self, config: dict[str, Any]) -> None:
         super().__init__(config)
         self.channel = channel.create(config)
contrib/nvme-target-control/tests/test_target_control.py +3 -1
index 730d6c8a9b69..c6d8933b6212 100644
@@ -160,7 +160,9 @@ type = "fake_array:RecordingTarget"
         self.assertEqual(
             self.show('features'),
             'add-ports add-port remove-port list-ports show-port set-ana '
-            'set-host',
+            'set-host dhchap-sha256 dhchap-sha384 dhchap-sha512 dhchap-null '
+            'dhchap-ffdhe2048 dhchap-ffdhe3072 dhchap-ffdhe4096 '
+            'dhchap-ffdhe6144 dhchap-ffdhe8192',
         )
         self.config.write_text(PLUGIN)
         self.assertEqual(self.show('features'), '')
Signature · 1 line
2.56.1
#8 lore raw

PATCH v2 6/9 nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support

In reply to Daniel Wagner

The authentication tests fail against a target that can't do DH-HMAC-CHAP, and nvme/042 and nvme/043 fail on every hash or DH group the target doesn't support.

Skip the authentication tests if the target doesn't list dhchap-sha256, the hash every DH-HMAC-CHAP target supports, and skip just the steps of nvme/042 and nvme/043 for the other algorithms the target doesn't list.

---
 Documentation/running-tests.md |  7 +++++--
 tests/nvme/041                 |  1 +
 tests/nvme/042                 |  3 ++-
 tests/nvme/043                 |  4 +++-
 tests/nvme/044                 |  2 +-
 tests/nvme/045                 |  2 +-
 tests/nvme/063                 |  2 +-
 tests/nvme/rc                  | 31 +++++++++++++++++++++++++------
 8 files changed, 39 insertions(+), 13 deletions(-)
Documentation/running-tests.md +5 -2
index b66bdf9cb2e8..d556f1d3b7cc 100644
@@ -261,8 +261,11 @@ The blktests expects that the script interface implements following
   --subsysnqn SUBSYSNQN
 
 config --show-features prints the optional commands the script supports,
-e.g. add-port, set-ana or set-host, and tls if the target can set up TLS.
-blktests skips the tests which need a feature the list lacks.
+e.g. add-port, set-ana or set-host, the DH-HMAC-CHAP hashes and DH groups
+the target supports, e.g. dhchap-sha256 or dhchap-ffdhe2048, and tls if
+the target can set up TLS. blktests skips the tests which need a feature
+the list lacks: the authentication tests without dhchap-sha256, and
+nvme/042 and nvme/043 only the steps for the other missing algorithms.
 
 contrib/nvme-target-control implements this interface. It configures a Linux
 nvmet target over ssh and can be extended for other targets, see
tests/nvme/041 +1 -0
index 9c3d9aaf4e12..2571c851be4d 100755
@@ -16,6 +16,7 @@ requires() {
 	_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
+	_require_nvme_target_control_feature dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/042 +2 -1
index e771cb6ca4aa..f9019e9640c4 100755
@@ -16,7 +16,7 @@ requires() {
 	_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
@@ -37,6 +37,7 @@ test() {
 
 	for hash in none sha256 sha384 sha512; do
 		echo "Testing hash ${hash}"
+		_have_nvme_target_dhchap "${hash}" || continue
 		hostkey="$(_nvme_gen_kxchap_secret --hash="${hash}" 2> /dev/null)"
 		if [ -z "$hostkey" ] ; then
 			echo "couldn't generate host key for hash ${hash}"
tests/nvme/043 +3 -1
index eb8f8b035f6d..695edaab9741 100755
@@ -17,7 +17,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
@@ -45,6 +45,7 @@ test() {
 	for hash in sha256 sha384 sha512; do
 
 		echo "Testing hash ${hash}"
+		_have_nvme_target_dhchap "${hash}" || continue
 
 		_set_nvmet_hash "${def_hostnqn}" "hmac(${hash})"
 
@@ -56,6 +57,7 @@ test() {
 	for dhgroup in ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192; do
 
 		echo "Testing DH group ${dhgroup}"
+		_have_nvme_target_dhchap "${dhgroup}" || continue
 
 		_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
 
tests/nvme/044 +1 -1
index c1a48f1e3d86..01a153e1f2a0 100755
@@ -17,7 +17,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/045 +1 -1
index 14f4949e198e..52d04ce40860 100755
@@ -18,7 +18,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/063 +1 -1
index 20aabd91ca80..578cb8799a6d 100755
@@ -19,7 +19,7 @@ requires() {
 	_require_nvme_trtype tcp
 	_require_nvme_cli_auth
 	_have_systemd_tlshd_service
-	_require_nvme_target_control_feature set-host tls
+	_require_nvme_target_control_feature set-host tls dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/rc +25 -6
index 41811c033069..0d74c427313c 100644
@@ -155,18 +155,37 @@ _require_remote_nvme_target() {
 	return 0
 }
 
-# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features,
-# the optional commands and e.g. tls, see Documentation/running-tests.md.
-_require_nvme_target_control_feature() {
-	local features feature
+# Check if the NVME_TARGET_CONTROL target lists the feature, one of the
+# optional commands or e.g. tls, see Documentation/running-tests.md. The
+# local target has all of them.
+_have_nvme_target_control_feature() {
+	local features
 
 	if [[ -z "${nvme_target_control}" ]]; then
 		return 0
 	fi
 	features=" $("${nvme_target_control}" config --show-features) "
+	# shellcheck disable=SC2076 # match the feature literally
+	[[ "${features}" =~ " $1 " ]]
+}
+
+# Check if the target supports the DH-HMAC-CHAP hash or DH group, e.g. sha384
+# or ffdhe2048, and log it if it doesn't. Every target which can do
+# DH-HMAC-CHAP supports sha256, a secret with hash none needs no support.
+_have_nvme_target_dhchap() {
+	if [[ "$1" == none ]] || _have_nvme_target_control_feature "dhchap-$1"; then
+		return 0
+	fi
+	echo "Target lacks $1, skipped" >> "$FULL"
+	return 1
+}
+
+# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features.
+_require_nvme_target_control_feature() {
+	local feature
+
 	for feature in "$@"; do
-		# shellcheck disable=SC2076 # match the feature literally
-		if [[ ! "${features}" =~ " ${feature} " ]]; then
+		if ! _have_nvme_target_control_feature "${feature}"; then
 			SKIP_REASONS+=("NVME_TARGET_CONTROL target does not support ${feature}")
 			return 1
 		fi
Signature · 1 line
2.56.1
#9 lore raw

Re: [PATCH blktests v2 6/9] nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support

Quoted 9 lines · Daniel Wagner

The authentication tests fail against a target that can't do DH-HMAC-CHAP, and nvme/042 and nvme/043 fail on every hash or DH group the target doesn't support.

Skip the authentication tests if the target doesn't list dhchap-sha256, the hash every DH-HMAC-CHAP target supports, and skip just the steps of nvme/042 and nvme/043 for the other algorithms the target doesn't list.

Quoted 10 lines
---
 Documentation/running-tests.md |  7 +++++--
 tests/nvme/041                 |  1 +
 tests/nvme/042                 |  3 ++-
 tests/nvme/043                 |  4 +++-
 tests/nvme/044                 |  2 +-
 tests/nvme/045                 |  2 +-
 tests/nvme/063                 |  2 +-
 tests/nvme/rc                  | 31 +++++++++++++++++++++++++------
 8 files changed, 39 insertions(+), 13 deletions(-)

The commit message mentions the test cases nvme/042 and nvme/043 only, but this patch touches more test cases listed above. I guess all those test cases are modified for the same reason, right? If so, I can edit the commit message when I apply this patch.

Quoted 135 lines
Documentation/running-tests.md +5 -2
index b66bdf9cb2e8..d556f1d3b7cc 100644
@@ -261,8 +261,11 @@ The blktests expects that the script interface implements following
   --subsysnqn SUBSYSNQN
 
 config --show-features prints the optional commands the script supports,
-e.g. add-port, set-ana or set-host, and tls if the target can set up TLS.
-blktests skips the tests which need a feature the list lacks.
+e.g. add-port, set-ana or set-host, the DH-HMAC-CHAP hashes and DH groups
+the target supports, e.g. dhchap-sha256 or dhchap-ffdhe2048, and tls if
+the target can set up TLS. blktests skips the tests which need a feature
+the list lacks: the authentication tests without dhchap-sha256, and
+nvme/042 and nvme/043 only the steps for the other missing algorithms.
 
 contrib/nvme-target-control implements this interface. It configures a Linux
 nvmet target over ssh and can be extended for other targets, see
tests/nvme/041 +1 -0
index 9c3d9aaf4e12..2571c851be4d 100755
@@ -16,6 +16,7 @@ requires() {
 	_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
+	_require_nvme_target_control_feature dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/042 +2 -1
index e771cb6ca4aa..f9019e9640c4 100755
@@ -16,7 +16,7 @@ requires() {
 	_require_kernel_nvme_fabrics_feature dhchap_ctrl_secret
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
@@ -37,6 +37,7 @@ test() {
 
 	for hash in none sha256 sha384 sha512; do
 		echo "Testing hash ${hash}"
+		_have_nvme_target_dhchap "${hash}" || continue
 		hostkey="$(_nvme_gen_kxchap_secret --hash="${hash}" 2> /dev/null)"
 		if [ -z "$hostkey" ] ; then
 			echo "couldn't generate host key for hash ${hash}"
tests/nvme/043 +3 -1
index eb8f8b035f6d..695edaab9741 100755
@@ -17,7 +17,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
@@ -45,6 +45,7 @@ test() {
 	for hash in sha256 sha384 sha512; do
 
 		echo "Testing hash ${hash}"
+		_have_nvme_target_dhchap "${hash}" || continue
 
 		_set_nvmet_hash "${def_hostnqn}" "hmac(${hash})"
 
@@ -56,6 +57,7 @@ test() {
 	for dhgroup in ffdhe2048 ffdhe3072 ffdhe4096 ffdhe6144 ffdhe8192; do
 
 		echo "Testing DH group ${dhgroup}"
+		_have_nvme_target_dhchap "${dhgroup}" || continue
 
 		_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
 
tests/nvme/044 +1 -1
index c1a48f1e3d86..01a153e1f2a0 100755
@@ -17,7 +17,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/045 +1 -1
index 14f4949e198e..52d04ce40860 100755
@@ -18,7 +18,7 @@ requires() {
 	_require_nvme_trtype_is_fabrics
 	_require_nvme_cli_auth
 	_have_crypto_algorithm dh-generic
-	_require_nvme_target_control_feature set-host
+	_require_nvme_target_control_feature set-host dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/063 +1 -1
index 20aabd91ca80..578cb8799a6d 100755
@@ -19,7 +19,7 @@ requires() {
 	_require_nvme_trtype tcp
 	_require_nvme_cli_auth
 	_have_systemd_tlshd_service
-	_require_nvme_target_control_feature set-host tls
+	_require_nvme_target_control_feature set-host tls dhchap-sha256
 }
 
 set_conditions() {
tests/nvme/rc +3 -4
index 41811c033069..0d74c427313c 100644
@@ -155,18 +155,37 @@ _require_remote_nvme_target() {
 	return 0
 }
 
-# Skip the test if the NVME_TARGET_CONTROL target lacks one of the features,
-# the optional commands and e.g. tls, see Documentation/running-tests.md.
-_require_nvme_target_control_feature() {
-	local features feature
+# Check if the NVME_TARGET_CONTROL target lists the feature, one of the
+# optional commands or e.g. tls, see Documentation/running-tests.md. The
+# local target has all of them.

tests/nvme/rc _require_remote_nvme_target() { · line 170

Quoted 10 lines
tests/nvme/rc +5 -0
+_have_nvme_target_control_feature() {
+	local features
 
 	if [[ -z "${nvme_target_control}" ]]; then
 		return 0
 	fi
 	features=" $("${nvme_target_control}" config --show-features) "
+	# shellcheck disable=SC2076 # match the feature literally
+	[[ "${features}" =~ " $1 " ]]
+}

Nit: I think the shellcehck exception above can be avoided by a local variable. I will add another follow-up commit as below. Just in case you think wrong, please let me know.

tests/nvme/rc +3 -3
index e4fa9e0..879eb40 100644
@@ -159,14 +159,14 @@ _require_remote_nvme_target() {
 # optional commands or e.g. tls, see Documentation/running-tests.md. The
 # local target has all of them.
 _have_nvme_target_control_feature() {
-       local features
+       local features feature
 
        if [[ -z "${nvme_target_control}" ]]; then
                return 0
        fi
        features=" $("${nvme_target_control}" config --show-features) "
-       # shellcheck disable=SC2076 # match the feature literally
-       [[ "${features}" =~ " $1 " ]]
+       feature=" $1 "
+       [[ "${features}" =~ $feature ]]
 }
 
#10 lore raw

PATCH v2 7/9 common/nvme: support the ports of a remote target

In reply to Daniel Wagner

The port helpers always use the local nvmet configfs, so tests that use more than one port don't work with a remote target. Use the port commands of the target control script instead and document them.

---
 Documentation/running-tests.md | 29 +++++++++++++++++
 common/nvme                    | 70 +++++++++++++++++++++++++++++++++++-------
 2 files changed, 88 insertions(+), 11 deletions(-)
Documentation/running-tests.md +29 -0
index d556f1d3b7cc..8300d9aa4842 100644
@@ -256,6 +256,8 @@ The blktests expects that the script interface implements following
   --hostnqn HOSTNQN
   --ctrlkey CTRLKEY
   --hostkey HOSTKEY
+  --ports NR_PORTS
+  --tls | --force-tls
 
 cleanup:
   --subsysnqn SUBSYSNQN
@@ -267,6 +269,33 @@ the target can set up TLS. blktests skips the tests which need a feature
 the list lacks: the authentication tests without dhchap-sha256, and
 nvme/042 and nvme/043 only the steps for the other missing algorithms.
 
+The tests which use more than one port, or add and remove ports, also need
+the port commands. A port is named by an ID the script picks:
+
+add-ports: export the subsystem on NR_PORTS more ports, print their IDs
+  --subsysnqn SUBSYSNQN
+  --ports NR_PORTS
+  --tls | --force-tls
+
+add-port: create a port which exports no subsystem, print its ID
+  --tls | --force-tls
+
+remove-port:
+  --port PORT
+
+list-ports: print the IDs of the ports which export the subsystem
+  --subsysnqn SUBSYSNQN
+
+show-port: print the transport type, address and service ID of the port
+  --port PORT
+
+set-ana: set the state of an ANA group on the port
+  --port PORT
+  --grpid GRPID
+  --state STATE
+
+If list-ports prints nothing, blktests connects to the address config shows.
+
 contrib/nvme-target-control implements this interface. It configures a Linux
 nvmet target over ssh and can be extended for other targets, see
 contrib/nvme-target-control/README.md.
common/nvme +59 -11

147 lines not on this page · raw message

Signature · 1 line
2.56.1
#11 lore raw

PATCH v2 8/9 nvme/rc: change the host keys on a remote target

In reply to Daniel Wagner

The helpers that change the DH-CHAP settings of the host write to the local nvmet configfs, so a remote target never sees the new values. Use the set-host command of the target control script instead and document it.

---
 Documentation/running-tests.md |  9 +++++++++
 tests/nvme/rc                  | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+)
Documentation/running-tests.md +9 -0
index 8300d9aa4842..149b3656d7c8 100644
@@ -296,6 +296,15 @@ set-ana: set the state of an ANA group on the port
 
 If list-ports prints nothing, blktests connects to the address config shows.
 
+The authentication tests change the DH-CHAP attributes of the host:
+
+set-host:
+  --hostnqn HOSTNQN
+  --hostkey HOSTKEY
+  --ctrlkey CTRLKEY
+  --hash HASH
+  --dhgroup DHGROUP
+
 contrib/nvme-target-control implements this interface. It configures a Linux
 nvmet target over ssh and can be extended for other targets, see
 contrib/nvme-target-control/README.md.
tests/nvme/rc +20 -0
index 0d74c427313c..47710efc5096 100644
@@ -285,6 +285,11 @@ _set_nvmet_hostkey() {
 	local nvmet_hostkey="$2"
 	local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
 
+	if [[ -n "${nvme_target_control}" ]]; then
+		"${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+			--hostkey "${nvmet_hostkey}"
+		return
+	fi
 	_set_attr "${nvmet_hostkey}" "${cfs_path}/dhchap_key"
 }
 
@@ -293,6 +298,11 @@ _set_nvmet_ctrlkey() {
 	local nvmet_ctrlkey="$2"
 	local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
 
+	if [[ -n "${nvme_target_control}" ]]; then
+		"${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+			--ctrlkey "${nvmet_ctrlkey}"
+		return
+	fi
 	_set_attr "${nvmet_ctrlkey}" "${cfs_path}/dhchap_ctrl_key"
 }
 
@@ -301,6 +311,11 @@ _set_nvmet_hash() {
 	local nvmet_hash="$2"
 	local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
 
+	if [[ -n "${nvme_target_control}" ]]; then
+		"${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+			--hash "${nvmet_hash}"
+		return
+	fi
 	_set_attr "${nvmet_hash}" "${cfs_path}/dhchap_hash"
 }
 
@@ -309,6 +324,11 @@ _set_nvmet_dhgroup() {
 	local nvmet_dhgroup="$2"
 	local cfs_path="${NVMET_CFS}/hosts/${nvmet_hostnqn}"
 
+	if [[ -n "${nvme_target_control}" ]]; then
+		"${nvme_target_control}" set-host --hostnqn "${nvmet_hostnqn}" \
+			--dhgroup "${nvmet_dhgroup}"
+		return
+	fi
 	_set_attr "${nvmet_dhgroup}" "${cfs_path}/dhchap_dhgroup"
 }
 
Signature · 1 line
2.56.1
#12 lore raw

PATCH v2 9/9 contrib/nvme-target-control: add a NetApp ONTAP target

In reply to Daniel Wagner

Add a target that configures a NetApp ONTAP storage virtual machine through its REST API. It implements list-ports, show-port and set-host, and shows how a target that can do less than nvmet works with the tests. README.md documents the configuration and the limitations.

---
 Documentation/running-tests.md                     |   3 +-
 contrib/nvme-target-control/README.md              |  48 +++
 .../nvme_target_control/target.py                  |   1 +
 .../nvme_target_control/targets/ontap.py           | 397 +++++++++++++++++++++
 contrib/nvme-target-control/tests/test_ontap.py    | 357 ++++++++++++++++++
 5 files changed, 805 insertions(+), 1 deletion(-)
Documentation/running-tests.md +2 -1
index 149b3656d7c8..6ce406a61423 100644
@@ -306,5 +306,6 @@ If list-ports prints nothing, blktests connects to the address config shows.
   --dhgroup DHGROUP
 
 contrib/nvme-target-control implements this interface. It configures a Linux
-nvmet target over ssh and can be extended for other targets, see
+nvmet target over ssh or a NetApp ONTAP storage virtual machine through its
+REST API, and can be extended for other targets, see
 contrib/nvme-target-control/README.md.
contrib/nvme-target-control/README.md +48 -0

60 lines not on this page · raw message

contrib/nvme-target-control/nvme_target_control/target.py +1 -0
index 1b3576bffbbf..1661b822e2aa 100644
@@ -228,6 +228,7 @@ OPTIONAL_COMMANDS = {
 
 TARGETS = {
     'nvmet': 'nvme_target_control.targets.nvmet:NvmetTarget',
+    'ontap': 'nvme_target_control.targets.ontap:OntapTarget',
 }
 
 
contrib/nvme-target-control/nvme_target_control/targets/ontap.py new file +397 -0

397 lines not on this page · raw message

contrib/nvme-target-control/tests/test_ontap.py new file +357 -0

357 lines not on this page · raw message

Signature · 1 line
2.56.1
#13 lore raw
In reply to Daniel Wagner
Quoted 89 lines · Daniel Wagner

Hi all,

this series makes running the nvme tests against a remote target with NVME_TARGET_CONTROL actually work. The first six patches of v1 have been applied, this is the rest. It applies on top of the series that makes tests skip when a program they need is missing.

The first two patches are fixes: nvme/047 looks up the namespace again after reconnecting, and the nvmet target picks free service IDs for its ports. The third is a cleanup, nvme/042 and nvme/043 iterate over the DH-HMAC-CHAP hashes by name.

The remaining patches let tests skip instead of failing when the remote target lacks a feature they need, including the DH-HMAC-CHAP hashes and DH groups the target doesn't support, add port and host key support for remote targets, and add a NetApp ONTAP target as an example of a target that can do less than nvmet.

Tested against nvmet in a second VM, which also exported other subsystems on its own ports, and against a NetApp ONTAP array. All tests that can run against a remote target pass, except nvme/077 against nvmet, which checks attr_qid_max in the local nvmet configfs. Against the array, nvme/061 and nvme/070 fail because it refuses the reconnect after a subsystem is deleted and doesn't support Identify CNS 07h, and nvme/068 because the host runs a 6.4 kernel. The tests that need the kernel target still pass with the local target.

---
Changes in v2:
- Drop the six patches that were applied.
- Fix nvme/047 to look up the namespace again after reconnecting.
- Pick free service IDs for new nvmet ports.
- Pass the TLS option in the argument array instead of an unquoted
command substitution; quoting it would pass an empty argument without
TLS. (Shin'ichiro)
- Check the features with =~, with an SC2076 exception for the literal
match. (Shin'ichiro)
- List the DH-HMAC-CHAP algorithms a target supports, iterate over them
by name in nvme/042 and nvme/043 and skip the ones the target lacks.
- Put the fixes first, then the cleanup, then the features.
- Depend on the series that makes tests skip when a program is missing.
- Link to v1: https://patch.msgid.link/[email protected]

---
Daniel Wagner (9):
nvme/047: look up the namespace again after reconnecting contrib/nvme-target-control: pick a free service ID for new nvmet ports nvme/042, nvme/043: iterate over the DH-HMAC-CHAP hashes by name
nvme: skip tests that need a feature the remote target lacks contrib/nvme-target-control: list the DH-HMAC-CHAP algorithms
nvme: skip the DH-HMAC-CHAP algorithms the target doesn't support common/nvme: support the ports of a remote target
nvme/rc: change the host keys on a remote target contrib/nvme-target-control: add a NetApp ONTAP target

  Documentation/running-tests.md                     |  49 ++-
  common/nvme                                        |  88 ++++-
  contrib/nvme-target-control/README.md              |  72 +++-
  .../nvme_target_control/target.py                  |  19 +
  .../nvme_target_control/targets/nvmet.py           |  12 +-
  .../nvme_target_control/targets/nvmet.sh           |   7 +-
  .../nvme_target_control/targets/ontap.py           | 397 +++++++++++++++++++++
  contrib/nvme-target-control/tests/test_ontap.py    | 357 ++++++++++++++++++
  .../tests/test_target_control.py                   |   4 +-
  tests/nvme/031                                     |   1 +
  tests/nvme/041                                     |   1 +
  tests/nvme/042                                     |  12 +-
  tests/nvme/042.out                                 |   8 +-
  tests/nvme/043                                     |   9 +-
  tests/nvme/043.out                                 |   6 +-
  tests/nvme/044                                     |   1 +
  tests/nvme/045                                     |   1 +
  tests/nvme/047                                     |   2 +
  tests/nvme/057                                     |   1 +
  tests/nvme/062                                     |   1 +
  tests/nvme/063                                     |   5 +-
  tests/nvme/rc                                      |  58 +++
  22 files changed, 1069 insertions(+), 42 deletions(-)

---
base-commit: 79c32fb31b7bca6a4383b749030128683cf6b6b4
change-id: 20261104-nvme-target-control-f0b239e68b29
prerequisite-change-id: 20261117-skip-missing-deps-30b4084698c4:v1
prerequisite-patch-id: 9478a4106d922c8432a4d297dcb18ed68a9c8d61
prerequisite-patch-id: 635fcb82ae72c78b84ad593a58d82315a166724d
prerequisite-patch-id: 528ad89bda84f0b0d9cbc0d38b6e1384332f86cd
prerequisite-patch-id: 2758a16b44a326eea5113ff4967e6093ad42e71c
prerequisite-patch-id: 9acbf0ff52b0b46035e4635035662cd9d9309f77

Quoted 5 lines

Best regards,
--
Daniel Wagner <[email protected]>

Very nice, thank you!

Cheers,

Hannes

Signature · 4 lines
Dr. Hannes Reinecke                  Kernel Storage Architect
[email protected]                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
#14 lore raw
In reply to Daniel Wagner
Quoted 27 lines · Daniel Wagner

Hi all,

this series makes running the nvme tests against a remote target with NVME_TARGET_CONTROL actually work. The first six patches of v1 have been applied, this is the rest. It applies on top of the series that makes tests skip when a program they need is missing.

The first two patches are fixes: nvme/047 looks up the namespace again after reconnecting, and the nvmet target picks free service IDs for its ports. The third is a cleanup, nvme/042 and nvme/043 iterate over the DH-HMAC-CHAP hashes by name.

The remaining patches let tests skip instead of failing when the remote target lacks a feature they need, including the DH-HMAC-CHAP hashes and DH groups the target doesn't support, add port and host key support for remote targets, and add a NetApp ONTAP target as an example of a target that can do less than nvmet.

Tested against nvmet in a second VM, which also exported other subsystems on its own ports, and against a NetApp ONTAP array. All tests that can run against a remote target pass, except nvme/077 against nvmet, which checks attr_qid_max in the local nvmet configfs. Against the array, nvme/061 and nvme/070 fail because it refuses the reconnect after a subsystem is deleted and doesn't support Identify CNS 07h, and nvme/068 because the host runs a 6.4 kernel. The tests that need the kernel target still pass with the local target.

Quoted 1 line

Daniel, thank you for the series. I think this series is almost ready to apply.

Hannes made one comment on the 1st patch. I see the point, but IMO, it can be put out of the scope of the series.

I made a few minor comments. Let me wait a few more days to wait for some more comments before I apply this series with some commit message edits and with a follow-up commit.

#15 lore raw

On Nov 28, 2026 / 11:34, Shin'ichiro Kawasaki wrote:
[...]

Quoted 3 lines

I made a few minor comments. Let me wait a few more days to wait for some more comments before I apply this series with some commit message edits and with a follow-up commit.

FYI, I applied the patches with the commit message edits and the follow-up commit. Thanks!