From 45ba972bbcf913553866b51dd9278aacf679d05f Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 22 Nov 2021 16:22:25 +0100 Subject: [PATCH] nvme/rc: add more arguments to _nvme_connect_subsys() 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 --- tests/nvme/rc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/nvme/rc b/tests/nvme/rc index cbc6f68..0e14068 100644 --- a/tests/nvme/rc +++ b/tests/nvme/rc @@ -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[@]}" } -- 2.49.0