]> www.infradead.org Git - users/hch/blktests.git/commitdiff
nvme/rc: add more arguments to _nvme_connect_subsys()
authorHannes Reinecke <hare@suse.com>
Mon, 22 Nov 2021 15:22:25 +0000 (16:22 +0100)
committerHannes Reinecke <hare@suse.com>
Wed, 20 Jul 2022 14:38:27 +0000 (16:38 +0200)
Add optional arguments for setting 'hostnqn', 'hostid', 'hostkey',
and 'ctrlkey' to _nvme_connect_subsys() to make it usable for
testing nvme in-band authentication.

Signed-off-by: Hannes Reinecke <hare@suse.de>
tests/nvme/rc

index cbc6f68d47f1a345b2ed29430680b2e8879d18b5..0e14068fbe4785dfdbf74092276e715d51eff3bc 100644 (file)
@@ -10,6 +10,8 @@
 def_traddr="127.0.0.1"
 def_adrfam="ipv4"
 def_trsvcid="4420"
+def_hostnqn="$(cat /etc/nvme/hostnqn 2> /dev/null)"
+def_hostid="$(cat /etc/nvme/hostid 2> /dev/null)"
 nvme_trtype=${nvme_trtype:-"loop"}
 
 _nvme_requires() {
@@ -213,11 +215,27 @@ _nvme_connect_subsys() {
        local subsysnqn="$2"
        local traddr="${3:-$def_traddr}"
        local trsvcid="${4:-$def_trsvcid}"
+       local hostnqn="${5:-$def_hostnqn}"
+       local hostid="${6:-$def_hostid}"
+       local hostkey="${7}"
+       local ctrlkey="${8}"
 
        ARGS=(-t "${trtype}" -n "${subsysnqn}")
        if [[ "${trtype}" != "loop" ]]; then
                ARGS+=(-a "${traddr}" -s "${trsvcid}")
        fi
+       if [[ "${hostnqn}" != "$def_hostnqn" ]]; then
+               ARGS+=(--hostnqn="${hostnqn}")
+       fi
+       if [[ "${hostid}" != "$def_hostid" ]]; then
+               ARGS+=(--hostid="${hostid}")
+       fi
+       if [[ -n "${hostkey}" ]]; then
+               ARGS+=(--dhchap-secret="${hostkey}")
+       fi
+       if [[ -n "${ctrlkey}" ]]; then
+               ARGS+=(--dhchap-ctrl-secret="${ctrlkey}")
+       fi
        nvme connect "${ARGS[@]}"
 }