Skip to content

Commit 8068ca1

Browse files
dwsusekawasaki
authored andcommitted
nvme/{041,042,043,044,045,048}: Remove local variable hostnqn and hostid
Commit acc4084 ("nvme/{041,042,043,044,045,048}: Use default hostnqn and hostid") switched the test over to use the default hostnqn. It missed the change to remove the local variable and use the def_hostnqn/def_hostid directly. Signed-off-by: Daniel Wagner <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 7641622 commit 8068ca1

6 files changed

Lines changed: 47 additions & 75 deletions

File tree

tests/nvme/041

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ test() {
2525
_setup_nvmet
2626

2727
local port
28-
local hostid
29-
local hostnqn
3028
local file_path="${TMPDIR}/img"
3129
local hostkey
3230
local ctrldev
3331

34-
hostid="${def_hostid}"
35-
hostnqn="${def_hostnqn}"
3632
hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
3733
if [ -z "$hostkey" ] ; then
3834
echo "nvme gen-dhchap-key failed"
@@ -45,21 +41,21 @@ test() {
4541
"b92842df-a394-44b1-84a4-92ae7d112861"
4642
port="$(_create_nvmet_port "${nvme_trtype}")"
4743
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
48-
_create_nvmet_host "${def_subsysnqn}" "${hostnqn}" "${hostkey}"
44+
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}"
4945

5046
# Test unauthenticated connection (should fail)
5147
echo "Test unauthenticated connection (should fail)"
5248
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
53-
--hostnqn "${hostnqn}" \
54-
--hostid "${hostid}"
49+
--hostnqn "${def_hostnqn}" \
50+
--hostid "${def_hostid}"
5551

5652
_nvme_disconnect_subsys "${def_subsysnqn}"
5753

5854
# Test authenticated connection
5955
echo "Test authenticated connection"
6056
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
61-
--hostnqn "${hostnqn}" \
62-
--hostid "${hostid}" \
57+
--hostnqn "${def_hostnqn}" \
58+
--hostid "${def_hostid}" \
6359
--dhchap-secret "${hostkey}"
6460

6561
udevadm settle
@@ -71,7 +67,7 @@ test() {
7167

7268
_remove_nvmet_port "${port}"
7369

74-
_remove_nvmet_host "${hostnqn}"
70+
_remove_nvmet_host "${def_hostnqn}"
7571

7672
rm "${file_path}"
7773

tests/nvme/042

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,18 @@ test() {
2525
_setup_nvmet
2626

2727
local port
28-
local hostid
29-
local hostnqn
3028
local file_path="${TMPDIR}/img"
3129
local hmac
3230
local key_len
3331
local hostkey
3432
local ctrldev
3533

36-
hostid="${def_hostid}"
37-
hostnqn="${def_hostnqn}"
38-
3934
truncate -s "${nvme_img_size}" "${file_path}"
4035

4136
_create_nvmet_subsystem "${def_subsysnqn}" "${file_path}"
4237
port="$(_create_nvmet_port "${nvme_trtype}")"
4338
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
44-
_create_nvmet_host "${def_subsysnqn}" "${hostnqn}"
39+
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
4540

4641
for hmac in 0 1 2 3; do
4742
echo "Testing hmac ${hmac}"
@@ -50,11 +45,11 @@ test() {
5045
echo "couldn't generate host key for hmac ${hmac}"
5146
return 1
5247
fi
53-
_set_nvmet_hostkey "${hostnqn}" "${hostkey}"
48+
_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
5449

5550
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
56-
--hostnqn "${hostnqn}" \
57-
--hostid "${hostid}" \
51+
--hostnqn "${def_hostnqn}" \
52+
--hostid "${def_hostid}" \
5853
--dhchap-secret "${hostkey}"
5954
udevadm settle
6055

@@ -68,11 +63,11 @@ test() {
6863
echo "couldn't generate host key for length ${key_len}"
6964
return 1
7065
fi
71-
_set_nvmet_hostkey "${hostnqn}" "${hostkey}"
66+
_set_nvmet_hostkey "${def_hostnqn}" "${hostkey}"
7267

7368
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
74-
--hostnqn "${hostnqn}" \
75-
--hostid "${hostid}" \
69+
--hostnqn "${def_hostnqn}" \
70+
--hostid "${def_hostid}" \
7671
--dhchap-secret "${hostkey}"
7772

7873
udevadm settle
@@ -85,7 +80,7 @@ test() {
8580

8681
_remove_nvmet_port "${port}"
8782

88-
_remove_nvmet_host "${hostnqn}"
83+
_remove_nvmet_host "${def_hostnqn}"
8984

9085
rm "${file_path}"
9186

tests/nvme/043

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ test() {
2626
_setup_nvmet
2727

2828
local port
29-
local subsys_name="blktests-subsystem-1"
30-
local hostid
31-
local hostnqn
3229
local file_path="${TMPDIR}/img"
3330
local hash
3431
local dhgroup
3532
local hostkey
3633
local ctrldev
3734

38-
hostid="${def_hostid}"
39-
hostnqn="${def_hostnqn}"
40-
hostkey="$(nvme gen-dhchap-key -n ${hostnqn} 2> /dev/null)"
35+
hostkey="$(nvme gen-dhchap-key -n ${def_hostnqn} 2> /dev/null)"
4136
if [ -z "$hostkey" ] ; then
4237
echo "nvme gen-dhchap-key failed"
4338
return 1
@@ -48,17 +43,17 @@ test() {
4843
_create_nvmet_subsystem "${def_subsysnqn}" "${file_path}"
4944
port="$(_create_nvmet_port "${nvme_trtype}")"
5045
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
51-
_create_nvmet_host "${def_subsysnqn}" "${hostnqn}" "${hostkey}"
46+
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}"
5247

5348
for hash in "hmac(sha256)" "hmac(sha384)" "hmac(sha512)" ; do
5449

5550
echo "Testing hash ${hash}"
5651

57-
_set_nvmet_hash "${hostnqn}" "${hash}"
52+
_set_nvmet_hash "${def_hostnqn}" "${hash}"
5853

5954
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
60-
--hostnqn "${hostnqn}" \
61-
--hostid "${hostid}" \
55+
--hostnqn "${def_hostnqn}" \
56+
--hostid "${def_hostid}" \
6257
--dhchap-secret "${hostkey}"
6358

6459
udevadm settle
@@ -70,11 +65,11 @@ test() {
7065

7166
echo "Testing DH group ${dhgroup}"
7267

73-
_set_nvmet_dhgroup "${hostnqn}" "${dhgroup}"
68+
_set_nvmet_dhgroup "${def_hostnqn}" "${dhgroup}"
7469

7570
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
76-
--hostnqn "${hostnqn}" \
77-
--hostid "${hostid}" \
71+
--hostnqn "${def_hostnqn}" \
72+
--hostid "${def_hostid}" \
7873
--dhchap-secret "${hostkey}"
7974

8075
udevadm settle
@@ -87,7 +82,7 @@ test() {
8782

8883
_remove_nvmet_port "${port}"
8984

90-
_remove_nvmet_host "${hostnqn}"
85+
_remove_nvmet_host "${def_hostnqn}"
9186

9287
rm "${file_path}"
9388

tests/nvme/044

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,11 @@ test() {
2626
_setup_nvmet
2727

2828
local port
29-
local hostid
30-
local hostnqn
3129
local file_path="${TMPDIR}/img"
3230
local hostkey
3331
local ctrlkey
3432
local ctrldev
3533

36-
hostid="${def_hostid}"
37-
hostnqn="${def_hostnqn}"
38-
3934
hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
4035
if [ -z "$hostkey" ] ; then
4136
echo "failed to generate host key"
@@ -53,16 +48,16 @@ test() {
5348
_create_nvmet_subsystem "${def_subsysnqn}" "${file_path}"
5449
port="$(_create_nvmet_port "${nvme_trtype}")"
5550
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
56-
_create_nvmet_host "${def_subsysnqn}" "${hostnqn}" \
51+
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" \
5752
"${hostkey}" "${ctrlkey}"
5853

59-
_set_nvmet_dhgroup "${hostnqn}" "ffdhe2048"
54+
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
6055

6156
# Step 1: Connect with host authentication only
6257
echo "Test host authentication"
6358
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
64-
--hostnqn "${hostnqn}" \
65-
--hostid "${hostid}" \
59+
--hostnqn "${def_hostnqn}" \
60+
--hostid "${def_hostid}" \
6661
--dhchap-secret "${hostkey}"
6762

6863
udevadm settle
@@ -73,8 +68,8 @@ test() {
7368
# and invalid ctrl authentication
7469
echo "Test invalid ctrl authentication (should fail)"
7570
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
76-
--hostnqn "${hostnqn}" \
77-
--hostid "${hostid}" \
71+
--hostnqn "${def_hostnqn}" \
72+
--hostid "${def_hostid}" \
7873
--dhchap-secret "${hostkey}" \
7974
--dhchap-ctrl-secret "${hostkey}"
8075

@@ -86,8 +81,8 @@ test() {
8681
# and valid ctrl authentication
8782
echo "Test valid ctrl authentication"
8883
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
89-
--hostnqn "${hostnqn}" \
90-
--hostid "${hostid}" \
84+
--hostnqn "${def_hostnqn}" \
85+
--hostid "${def_hostid}" \
9186
--dhchap-secret "${hostkey}" \
9287
--dhchap-ctrl-secret "${ctrlkey}"
9388

@@ -100,8 +95,8 @@ test() {
10095
echo "Test invalid ctrl key (should fail)"
10196
invkey="DHHC-1:00:Jc/My1o0qtLCWRp+sHhAVafdfaS7YQOMYhk9zSmlatobqB8C:"
10297
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
103-
--hostnqn "${hostnqn}" \
104-
--hostid "${hostid}" \
98+
--hostnqn "${def_hostnqn}" \
99+
--hostid "${def_hostid}" \
105100
--dhchap-secret "${hostkey}" \
106101
--dhchap-ctrl-secret "${invkey}"
107102

@@ -114,7 +109,7 @@ test() {
114109

115110
_remove_nvmet_port "${port}"
116111

117-
_remove_nvmet_host "${hostnqn}"
112+
_remove_nvmet_host "${def_hostnqn}"
118113

119114
rm "${file_path}"
120115

tests/nvme/045

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ test() {
2727
_setup_nvmet
2828

2929
local port
30-
local hostid
31-
local hostnqn
3230
local file_path="${TMPDIR}/img"
3331
local hostkey
3432
local new_hostkey
@@ -37,9 +35,6 @@ test() {
3735
local ctrldev
3836
local rand_io_size
3937

40-
hostid="${def_hostid}"
41-
hostnqn="${def_hostnqn}"
42-
4338
hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
4439
if [ -z "$hostkey" ] ; then
4540
echo "failed to generate host key"
@@ -57,13 +52,13 @@ test() {
5752
_create_nvmet_subsystem "${def_subsysnqn}" "${file_path}"
5853
port="$(_create_nvmet_port "${nvme_trtype}")"
5954
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
60-
_create_nvmet_host "${def_subsysnqn}" "${hostnqn}" "${hostkey}" "${ctrlkey}"
55+
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}" "${hostkey}" "${ctrlkey}"
6156

62-
_set_nvmet_dhgroup "${hostnqn}" "ffdhe2048"
57+
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe2048"
6358

6459
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
65-
--hostnqn "${hostnqn}" \
66-
--hostid "${hostid}" \
60+
--hostnqn "${def_hostnqn}" \
61+
--hostid "${def_hostid}" \
6762
--dhchap-secret "${hostkey}" \
6863
--dhchap-ctrl-secret "${ctrlkey}"
6964

@@ -82,7 +77,7 @@ test() {
8277

8378
new_hostkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
8479

85-
_set_nvmet_hostkey "${hostnqn}" "${new_hostkey}"
80+
_set_nvmet_hostkey "${def_hostnqn}" "${new_hostkey}"
8681

8782
echo "Re-authenticate with new host key"
8883

@@ -92,7 +87,7 @@ test() {
9287

9388
new_ctrlkey="$(nvme gen-dhchap-key -n ${def_subsysnqn} 2> /dev/null)"
9489

95-
_set_nvmet_ctrlkey "${hostnqn}" "${new_ctrlkey}"
90+
_set_nvmet_ctrlkey "${def_hostnqn}" "${new_ctrlkey}"
9691

9792
echo "Re-authenticate with new ctrl key"
9893

@@ -101,15 +96,15 @@ test() {
10196

10297
echo "Change DH group to ffdhe8192"
10398

104-
_set_nvmet_dhgroup "${hostnqn}" "ffdhe8192"
99+
_set_nvmet_dhgroup "${def_hostnqn}" "ffdhe8192"
105100

106101
echo "Re-authenticate with changed DH group"
107102

108103
echo "${new_hostkey}" > "${hostkey_file}"
109104

110105
echo "Change hash to hmac(sha512)"
111106

112-
_set_nvmet_hash "${hostnqn}" "hmac(sha512)"
107+
_set_nvmet_hash "${def_hostnqn}" "hmac(sha512)"
113108

114109
echo "Re-authenticate with changed hash"
115110

@@ -127,7 +122,7 @@ test() {
127122

128123
_remove_nvmet_port "${port}"
129124

130-
_remove_nvmet_host "${hostnqn}"
125+
_remove_nvmet_host "${def_hostnqn}"
131126

132127
rm "${file_path}"
133128

tests/nvme/048

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,21 @@ test() {
8888
local cfs_path="${NVMET_CFS}/subsystems/${def_subsysnqn}"
8989
local file_path="${TMPDIR}/img"
9090
local skipped=false
91-
local hostnqn
92-
local hostid
9391
local port
9492

95-
hostid="${def_hostid}"
96-
hostnqn="${def_hostnqn}"
97-
9893
truncate -s "${nvme_img_size}" "${file_path}"
9994

10095
_create_nvmet_subsystem "${def_subsysnqn}" "${file_path}" \
10196
"b92842df-a394-44b1-84a4-92ae7d112861"
10297
port="$(_create_nvmet_port "${nvme_trtype}")"
98+
10399
_add_nvmet_subsys_to_port "${port}" "${def_subsysnqn}"
104100
_create_nvmet_host "${def_subsysnqn}" "${def_hostnqn}"
105101

106102
if [[ -f "${cfs_path}/attr_qid_max" ]] ; then
107103
_nvme_connect_subsys "${nvme_trtype}" "${def_subsysnqn}" \
108-
--hostnqn "${hostnqn}" \
109-
--hostid "${hostid}" \
104+
--hostnqn "${def_hostnqn}" \
105+
--hostid "${def_hostid}" \
110106
--keep-alive-tmo 1 \
111107
--reconnect-delay 2
112108

@@ -126,7 +122,7 @@ test() {
126122
_remove_nvmet_subsystem_from_port "${port}" "${def_subsysnqn}"
127123
_remove_nvmet_subsystem "${def_subsysnqn}"
128124
_remove_nvmet_port "${port}"
129-
_remove_nvmet_host "${hostnqn}"
125+
_remove_nvmet_host "${def_hostnqn}"
130126

131127
rm "${file_path}"
132128

0 commit comments

Comments
 (0)