From: Hannes Reinecke <hare@suse.de>
To: Sagi Grimberg <sagi@grimberg.me>
Cc: Christoph Hellwig <hch@lst.de>, Keith Busch <keith.busch@wdc.com>,
Omar Sandoval <osandov@fb.com>,
linux-nvme@lists.infradead.org, Hannes Reinecke <hare@suse.de>
Subject: [PATCH 3/6] nvmeof-tcp/003: test different key types
Date: Fri, 12 Nov 2021 15:45:07 +0100 [thread overview]
Message-ID: <20211112144510.98523-4-hare@suse.de> (raw)
In-Reply-To: <20211112144510.98523-1-hare@suse.de>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
tests/nvmeof-tcp/003 | 100 +++++++++++++++++++++++++++++++++++++++
tests/nvmeof-tcp/003.out | 36 ++++++++++++++
2 files changed, 136 insertions(+)
create mode 100644 tests/nvmeof-tcp/003
create mode 100644 tests/nvmeof-tcp/003.out
diff --git a/tests/nvmeof-tcp/003 b/tests/nvmeof-tcp/003
new file mode 100644
index 0000000..c8a91e9
--- /dev/null
+++ b/tests/nvmeof-tcp/003
@@ -0,0 +1,100 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2021 Hannes Reinecke, SUSE Labs
+#
+# Test nvme over tcp dhchap keys
+
+. tests/nvmeof-tcp/rc
+
+DESCRIPTION="Test dhchap keys for authenticated TCP connection via localhost"
+QUICK=1
+
+requires() {
+ _nvme_requires
+ _have_modules loop
+ _require_nvme_trtype_is_fabrics
+}
+
+
+test() {
+ local port
+ local genctr
+ local subsys="blktests-subsystem-"
+ local hostid="$(uuidgen)"
+ local hostnqn="nqn.2014-08.org.nvmexpress:uuid:${hostid}"
+ local scratch="/tmp/blktest-ns1.img"
+ local hostkey
+
+ echo "Running ${TEST_NAME}"
+
+ hostkey="$(nvme gen-dhchap-key -n ${subsys}1 2> /dev/null)"
+ if [ $? -ne 0 ] ; then
+ echo "nvme gen-dhchap-key command missing"
+ return 1
+ fi
+
+ _setup_nvmet
+
+ truncate -s 512M "${scratch}"
+
+ port="$(_create_nvmet_port "${nvme_trtype}")"
+
+ _create_nvmet_subsystem "${subsys}1" "${scratch}"
+ _add_nvmet_subsys_to_port "${port}" "${subsys}1"
+ _create_nvmet_host "${subsys}1" "${hostnqn}" "${hostkey}"
+
+ nvme connect -t "${nvme_trtype}" -n "${subsys}1" \
+ -a "${def_traddr}" -s "${def_trsvcid}" -S "${hostkey}" \
+ --hostnqn="${hostnqn}" --hostid="${hostid}"
+
+ nvme list-subsys
+
+ nvme disconnect -n "${subsys}1"
+
+ for hmac in 1 2 3; do
+ echo "Testing hmac ${hmac}"
+ hostkey="$(nvme gen-dhchap-key --hmac=${hmac} -n ${subsys}1 2> /dev/null)"
+ if [ $? -ne 0 ] ; then
+ echo "couldn't generate host key for hmac ${hmac}"
+ return 1
+ fi
+ _set_nvmet_hostkey "${hostnqn}" "${hostkey}"
+
+ nvme connect -t "${nvme_trtype}" -n "${subsys}1" \
+ -a "${def_traddr}" -s "${def_trsvcid}" -S "${hostkey}" \
+ --hostnqn="${hostnqn}" --hostid="${hostid}"
+
+ nvme list-subsys
+
+ nvme disconnect -n "${subsys}1"
+ done
+
+ for key_len in 32 48 64; do
+ echo "Testing key length ${key_len}"
+ hostkey="$(nvme gen-dhchap-key --key-length=${key_len} -n ${subsys}1 2> /dev/null)"
+ if [ $? -ne 0 ] ; then
+ echo "couldn't generate host key for length ${key_len}"
+ return 1
+ fi
+ _set_nvmet_hostkey "${hostnqn}" "${hostkey}"
+
+ nvme connect -t "${nvme_trtype}" -n "${subsys}1" \
+ -a "${def_traddr}" -s "${def_trsvcid}" -S "${hostkey}" \
+ --hostnqn="${hostnqn}" --hostid="${hostid}"
+
+ nvme list-subsys
+
+ nvme disconnect -n "${subsys}1"
+ done
+
+ _remove_nvmet_subsystem_from_port "${port}" "${subsys}1"
+ _remove_nvmet_subsystem "${subsys}1"
+
+ _remove_nvmet_port "${port}"
+
+ _remove_nvmet_host "${hostnqn}"
+
+ rm ${scratch}
+
+ echo "Test complete"
+}
diff --git a/tests/nvmeof-tcp/003.out b/tests/nvmeof-tcp/003.out
new file mode 100644
index 0000000..4d85539
--- /dev/null
+++ b/tests/nvmeof-tcp/003.out
@@ -0,0 +1,36 @@
+Running nvmeof-tcp/003
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Testing hmac 1
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Testing hmac 2
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Testing hmac 3
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Testing key length 32
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Testing key length 48
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Testing key length 64
+nvme-subsys0 - NQN=blktests-subsystem-1
+\
+ +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live
+NQN:blktests-subsystem-1 disconnected 1 controller(s)
+Test complete
--
2.26.2
next prev parent reply other threads:[~2021-11-12 15:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 14:45 [PATCH blktests 0/6] Testsuite for nvme in-band authentication Hannes Reinecke
2021-11-12 14:45 ` [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection Hannes Reinecke
2021-11-14 10:31 ` Sagi Grimberg
2021-11-14 13:50 ` Hannes Reinecke
2021-11-14 14:45 ` Sagi Grimberg
2021-11-15 2:34 ` Chaitanya Kulkarni
2021-11-15 6:56 ` Hannes Reinecke
2021-11-15 8:12 ` Sagi Grimberg
2021-11-15 8:37 ` Hannes Reinecke
2021-11-12 14:45 ` [PATCH 2/6] nvmeof-tcp/002: create an authenticated " Hannes Reinecke
2021-11-12 14:45 ` Hannes Reinecke [this message]
2021-11-12 14:45 ` [PATCH 4/6] nvmeof-tcp/004: test hash and dhgroup variations Hannes Reinecke
2021-11-12 14:45 ` [PATCH 5/6] nvmeof-tcp/005: test bi-directional authentication Hannes Reinecke
2021-11-17 21:50 ` Sagi Grimberg
2021-11-18 9:40 ` Hannes Reinecke
2021-11-19 11:29 ` Hannes Reinecke
2021-11-12 14:45 ` [PATCH 6/6] nvmeof-tcp/006: test re-authentication Hannes Reinecke
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=20211112144510.98523-4-hare@suse.de \
--to=hare@suse.de \
--cc=hch@lst.de \
--cc=keith.busch@wdc.com \
--cc=linux-nvme@lists.infradead.org \
--cc=osandov@fb.com \
--cc=sagi@grimberg.me \
/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 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.