Testsuite for nvme in-band authentication
Subsystems (2)
Hannes Reinecke
maintainercover Testsuite for nvme in-band authentication
Hi all,
some people (Hi Sagi!) have complained that nvme in-band authentication provide far too many configuration options to test it with some easy commands. So here's a test suite for testing (most of) the various configuration options and features.
As usual, comments and reviews are welcome.
Hannes Reinecke (6):
nvmeof-tcp/001: simple test for nvmeof-tcp connection nvmeof-tcp/002: create an authenticated nvmeof-tcp connection nvmeof-tcp/003: test different key types nvmeof-tcp/004: test hash and dhgroup variations nvmeof-tcp/005: test bi-directional authentication nvmeof-tcp/006: test re-authentication
tests/nvmeof-tcp/001 | 55 +++++++ tests/nvmeof-tcp/001.out | 6 + tests/nvmeof-tcp/002 | 62 +++++++ tests/nvmeof-tcp/002.out | 6 + tests/nvmeof-tcp/003 | 100 +++++++++++ tests/nvmeof-tcp/003.out | 36 ++++ tests/nvmeof-tcp/004 | 86 ++++++++++ tests/nvmeof-tcp/004.out | 37 +++++ tests/nvmeof-tcp/005 | 74 +++++++++ tests/nvmeof-tcp/005.out | 6 + tests/nvmeof-tcp/006 | 113 +++++++++++++ tests/nvmeof-tcp/006.out | 23 +++ tests/nvmeof-tcp/rc | 347 +++++++++++++++++++++++++++++++++++++++ 13 files changed, 951 insertions(+) create mode 100644 tests/nvmeof-tcp/001 create mode 100644 tests/nvmeof-tcp/001.out create mode 100644 tests/nvmeof-tcp/002 create mode 100644 tests/nvmeof-tcp/002.out create mode 100644 tests/nvmeof-tcp/003 create mode 100644 tests/nvmeof-tcp/003.out create mode 100644 tests/nvmeof-tcp/004 create mode 100644 tests/nvmeof-tcp/004.out create mode 100644 tests/nvmeof-tcp/005 create mode 100644 tests/nvmeof-tcp/005.out create mode 100644 tests/nvmeof-tcp/006 create mode 100644 tests/nvmeof-tcp/006.out create mode 100644 tests/nvmeof-tcp/rc
Signature · 1 line
2.26.2
Hannes Reinecke
maintainerPATCH 1/6 nvmeof-tcp/001: simple test for nvmeof-tcp connection
--- tests/nvmeof-tcp/001 | 55 +++++++ tests/nvmeof-tcp/001.out | 6 + tests/nvmeof-tcp/rc | 347 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 408 insertions(+) create mode 100644 tests/nvmeof-tcp/001 create mode 100644 tests/nvmeof-tcp/001.out create mode 100644 tests/nvmeof-tcp/rc
tests/nvmeof-tcp/001 new file +55 -0
@@ -0,0 +1,55 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp connection + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Create single 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" + + echo "Running ${TEST_NAME}" + + _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}" + + nvme connect -t "${nvme_trtype}" -n "${subsys}1" \ + -a "${def_traddr}" -s "${def_trsvcid}" \ + --hostnqn="${hostnqn}" --hostid="${hostid}" + + nvme list-subsys + + nvme disconnect -n "${subsys}1" + + _remove_nvmet_subsystem_from_port "${port}" "${subsys}1" + _remove_nvmet_subsystem "${subsys}1" + + _remove_nvmet_port "${port}" + + rm ${scratch} + + echo "Test complete" +}
tests/nvmeof-tcp/001.out new file +6 -0
@@ -0,0 +1,6 @@ +Running nvmeof-tcp/001 +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
tests/nvmeof-tcp/rc new file +347 -0
347 lines not on this page · raw message
Signature · 1 line
2.26.2
Sagi Grimberg
maintainerRe: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
Quoted 6 lines
Signed-off-by Hannes Reinecke <[email protected]>--- tests/nvmeof-tcp/001 | 55 +++++++ tests/nvmeof-tcp/001.out | 6 + tests/nvmeof-tcp/rc | 347 +++++++++++++++++++++++++++++++++++++++
Why another directory? why nvmeof-tcp? what prevents inband-auth to be tested with loop/rdma?
Quoted 84 lines
3 files changed, 408 insertions(+)create mode 100644 tests/nvmeof-tcp/001
create mode 100644 tests/nvmeof-tcp/001.out
create mode 100644 tests/nvmeof-tcp/rctests/nvmeof-tcp/001 new file +55
-0@@ -0,0 +1,55 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp connection + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Create single 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" + + echo "Running ${TEST_NAME}" + + _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}" + + nvme connect -t "${nvme_trtype}" -n "${subsys}1" \ + -a "${def_traddr}" -s "${def_trsvcid}" \ + --hostnqn="${hostnqn}" --hostid="${hostid}" + + nvme list-subsys + + nvme disconnect -n "${subsys}1" + + _remove_nvmet_subsystem_from_port "${port}" "${subsys}1" + _remove_nvmet_subsystem "${subsys}1" + + _remove_nvmet_port "${port}" + + rm ${scratch} + + echo "Test complete" +}tests/nvmeof-tcp/001.out new file +6
-0@@ -0,0 +1,6 @@ +Running nvmeof-tcp/001 +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 completetests/nvmeof-tcp/rc new file +0
-0
tests/nvmeof-tcp/rc line 5
Quoted 5 lines
tests/nvmeof-tcp/rc new file +5
-0@@ -0,0 +1,347 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Johannes Thumshirn +# +# Test specific to NVMe devices
Isn't this just a copy of nvme/rc?
Hannes Reinecke
maintainerRe: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
Quoted 10 lines · Sagi Grimberg
Quoted 6 lines
Signed-off-by Hannes Reinecke <[email protected]>---
tests/nvmeof-tcp/001 | 55 +++++++ tests/nvmeof-tcp/001.out | 6 +
tests/nvmeof-tcp/rc | 347 +++++++++++++++++++++++++++++++++++++++Why another directory? why nvmeof-tcp? what prevents inband-auth to be tested with loop/rdma?
Technically, nothing.
But as I'll be looking into tcp in-band _encryption_ as the next step I found it logical to have a disinct directory. Especially as I still fail to see the actual use-case for using in-band authentication _without_ encryption.
We could rename it to nvmeof-auth, though.
Especially as there's the nvmeof-mp precedent, which also has a separate directory.
Quoted 83 lines
Quoted 83 lines
3 files changed, 408 insertions(+)create mode 100644 tests/nvmeof-tcp/001
create mode 100644 tests/nvmeof-tcp/001.out
create mode 100644 tests/nvmeof-tcp/rctests/nvmeof-tcp/001 new file +55
-0@@ -0,0 +1,55 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp connection + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Create single 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" + + echo "Running ${TEST_NAME}" + + _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}" + + nvme connect -t "${nvme_trtype}" -n "${subsys}1" \ + -a "${def_traddr}" -s "${def_trsvcid}" \ + --hostnqn="${hostnqn}" --hostid="${hostid}" + + nvme list-subsys + + nvme disconnect -n "${subsys}1" + + _remove_nvmet_subsystem_from_port "${port}" "${subsys}1" + _remove_nvmet_subsystem "${subsys}1" + + _remove_nvmet_port "${port}" + + rm ${scratch} + + echo "Test complete" +}tests/nvmeof-tcp/001.out new file +6
-0@@ -0,0 +1,6 @@ +Running nvmeof-tcp/001 +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 completetests/nvmeof-tcp/rc new file +0
-0
Quoted 8 lines
tests/nvmeof-tcp/rc line 5
Quoted 6 lines
tests/nvmeof-tcp/rc new file +5
-0@@ -0,0 +1,347 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Johannes Thumshirn +# +# Test specific to NVMe devicesIsn't this just a copy of nvme/rc?
Essentially, yes.
And I'd be happy to merge them, like having a common nvme rc file to be used for all nvme related tests.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Sagi Grimberg
maintainerRe: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
Quoted 8 lines · Hannes Reinecke
Quoted 7 lines · Sagi Grimberg
Quoted 6 lines
Signed-off-by Hannes Reinecke <[email protected]>---
tests/nvmeof-tcp/001 | 55 +++++++ tests/nvmeof-tcp/001.out | 6 +
tests/nvmeof-tcp/rc | 347 +++++++++++++++++++++++++++++++++++++++
Quoted 5 lines
Quoted 3 lines
Why another directory? why nvmeof-tcp? what prevents inband-auth to be tested with loop/rdma?
Technically, nothing.
But as I'll be looking into tcp in-band _encryption_ as the next step I found it logical to have a disinct directory.
It is unclear to me why the separate directory is needed. But at least call it something else if you must have it.
Quoted 1 line
Especially as I still fail to see the actual use-case for using in-band authentication _without_ encryption.
Not sure what you mean. For the same use-case that iscsi chap exists for. The secrets are pre-shared.
Perhaps you can explain? My understanding is that the extension for nvme-tcp TLS based auth is to avoid maintaining two sets of pre-shared keys, i.e just maintain the TLS ones and not the dhchap ones. But maybe I am missing something.
Quoted 1 line
We could rename it to nvmeof-auth, though.
or just add it as more tests under nvme (or create a subdirectory).
Quoted 1 line
Especially as there's the nvmeof-mp precedent, which also has a separate directory.
That one is for nvme and dm-multipath, not really a native suite for nvme.
Re: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
Hannes,
Quoted 35 lines · Sagi Grimberg
Quoted 9 lines · Hannes Reinecke
Quoted 8 lines · Sagi Grimberg
Quoted 7 lines
Signed-off-by Hannes Reinecke <[email protected]>---
tests/nvmeof-tcp/001 | 55 +++++++
tests/nvmeof-tcp/001.out | 6 +
tests/nvmeof-tcp/rc | 347
+++++++++++++++++++++++++++++++++++++++Quoted 6 lines
Quoted 3 lines
Why another directory? why nvmeof-tcp? what prevents inband-auth to be tested with loop/rdma?
Technically, nothing.
But as I'll be looking into tcp in-band _encryption_ as the next step I found it logical to have a disinct directory.It is unclear to me why the separate directory is needed. But at least call it something else if you must have it.
Quoted 2 lines
Especially as I still fail to see the actual use-case for using in-band authentication _without_ encryption.
Not sure what you mean. For the same use-case that iscsi chap exists for. The secrets are pre-shared.
Perhaps you can explain? My understanding is that the extension for nvme-tcp TLS based auth is to avoid maintaining two sets of pre-shared keys, i.e just maintain the TLS ones and not the dhchap ones. But maybe I am missing something.
Quoted 1 line
We could rename it to nvmeof-auth, though.
Quoted 8 lines
or just add it as more tests under nvme (or create a subdirectory).
Quoted 2 lines
Especially as there's the nvmeof-mp precedent, which also has a separate directory.
That one is for nvme and dm-multipath, not really a native suite for nvme.
It will be great if we can avoid crating a different directory as we need to make make sure our tests are generic and can be applied to different transports and new testcases that will get added to nvme category (non-mp) can use this and existing infrastructure...
Hannes Reinecke
maintainerRe: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
In reply to Sagi GrimbergQuoted 18 lines · Sagi Grimberg
Quoted 9 lines · Hannes Reinecke
Quoted 8 lines · Sagi Grimberg
Quoted 7 lines
Signed-off-by Hannes Reinecke <[email protected]>---
tests/nvmeof-tcp/001 | 55 +++++++
tests/nvmeof-tcp/001.out | 6 +
tests/nvmeof-tcp/rc | 347
+++++++++++++++++++++++++++++++++++++++Quoted 5 lines
Quoted 3 lines
Why another directory? why nvmeof-tcp? what prevents inband-auth to be tested with loop/rdma?
Technically, nothing.
But as I'll be looking into tcp in-band _encryption_ as the next step I found it logical to have a disinct directory.
Quoted 8 lines
It is unclear to me why the separate directory is needed. But at least call it something else if you must have it.
Quoted 1 line
Especially as I still fail to see the actual use-case for using in-band authentication _without_ encryption.
Not sure what you mean. For the same use-case that iscsi chap exists for. The secrets are pre-shared.
And that's the use case I don't really get; the authentication is done only once during connection establishment, and then completely ignored for the remainder of the session.
Quoted 5 lines
Perhaps you can explain? My understanding is that the extension for nvme-tcp TLS based auth is to avoid maintaining two sets of pre-shared keys, i.e just maintain the TLS ones and not the dhchap ones. But maybe I am missing something.
Yes, and no.
Technically TLS is independent from authentication, and as such you can 'just' use encryption.
But if you want to have both there is the so-called secure concatenation, which allows you to use the negotiated shared key from authentication as PSK for TLS.
And that's where I think the real value lies for authentication; you precisely do _not_ have to maintain two sets of keys.
Quoted 4 lines
Quoted 1 line
We could rename it to nvmeof-auth, though.
or just add it as more tests under nvme (or create a subdirectory).
Sure we can. I just found it easier to create my own directory, especially seeing that the nvme subdir has the largest number of tests already. But if you prefer I can move it under the 'nvme' directory.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Sagi Grimberg
maintainerRe: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
Quoted 11 lines
Quoted 9 lines
It is unclear to me why the separate directory is needed. But at least call it something else if you must have it.
Quoted 1 line
Especially as I still fail to see the actual use-case for using in-band authentication _without_ encryption.
Not sure what you mean. For the same use-case that iscsi chap exists for. The secrets are pre-shared.
And that's the use case I don't really get; the authentication is done only once during connection establishment, and then completely ignored for the remainder of the session.
I have a different view on this. Authentication isn't really related to the datapath, but really only relevant to the queue establishment.
Quoted 9 lines
Quoted 6 lines
Perhaps you can explain? My understanding is that the extension for nvme-tcp TLS based auth is to avoid maintaining two sets of pre-shared keys, i.e just maintain the TLS ones and not the dhchap ones. But maybe I am missing something.
Yes, and no.
Technically TLS is independent from authentication, and as such you can 'just' use encryption.
But if you want to have both there is the so-called secure concatenation, which allows you to use the negotiated shared key from authentication as PSK for TLS.
Well, TLS is a longer journey for a number of reasons which I won't elaborate here.
Quoted 1 line
And that's where I think the real value lies for authentication; you precisely do _not_ have to maintain two sets of keys.
I can't say I completely agree with you. There are means today to encrypt data over the wire. Granted, it will negate possible data reduction gains, but still a mitigation exists.
On the other hand, today any unauthenticated host can connect to any fabrics controller, which is a problem. I don't think you should minimize the magnitude of your contribution as this is a real issue with nvmeof acceptance in enterprise environments.
I do agree that when TLS is used, it is indeed very useful to not have to maintain two sets of pre-shared secrets, but I don't think that there is no use-case for inband authentication in the absence of TLS.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
We could rename it to nvmeof-auth, though.
or just add it as more tests under nvme (or create a subdirectory).
Sure we can. I just found it easier to create my own directory, especially seeing that the nvme subdir has the largest number of tests already. But if you prefer I can move it under the 'nvme' directory.
I think that it would definitely be an improvement, also because people usually run the nvme directory tests which is nice and simple, we should strive to keep it this way.
Hannes Reinecke
maintainerRe: [PATCH 1/6] nvmeof-tcp/001: simple test for nvmeof-tcp connection
Quoted 30 lines · Sagi Grimberg
Quoted 7 lines
Quoted 7 lines
It is unclear to me why the separate directory is needed. But at least call it something else if you must have it.
Quoted 2 lines
Especially as I still fail to see the actual use-case for using in-band authentication _without_ encryption.
Quoted 6 lines
Quoted 3 lines
Not sure what you mean. For the same use-case that iscsi chap exists for. The secrets are pre-shared.
And that's the use case I don't really get; the authentication is done only once during connection establishment, and then completely ignored for the remainder of the session.
I have a different view on this. Authentication isn't really related to the datapath, but really only relevant to the queue establishment.
Quoted 6 lines
Quoted 6 lines
Perhaps you can explain? My understanding is that the extension for nvme-tcp TLS based auth is to avoid maintaining two sets of pre-shared keys, i.e just maintain the TLS ones and not the dhchap ones. But maybe I am missing something.
Quoted 6 lines
Yes, and no.
Technically TLS is independent from authentication, and as such you can 'just' use encryption.
But if you want to have both there is the so-called secure concatenation, which allows you to use the negotiated shared key from authentication as PSK for TLS.
Quoted 3 lines
Well, TLS is a longer journey for a number of reasons which I won't elaborate here.
Quite.
Quoted 12 lines
Quoted 2 lines
And that's where I think the real value lies for authentication; you precisely do _not_ have to maintain two sets of keys.
I can't say I completely agree with you. There are means today to encrypt data over the wire. Granted, it will negate possible data reduction gains, but still a mitigation exists.
On the other hand, today any unauthenticated host can connect to any fabrics controller, which is a problem. I don't think you should minimize the magnitude of your contribution as this is a real issue with nvmeof acceptance in enterprise environments.
That why I always took care to state that it's _my_ view. Security is still a rather new topic to me, and as such quite some techniques used here (derive key (a) from key (b) which is derived from key (c) etc) feel rather redundant to me.
So there's a bit of a learning curve ahead :-)
Quoted 5 lines
I do agree that when TLS is used, it is indeed very useful to not have to maintain two sets of pre-shared secrets, but I don't think that there is no use-case for inband authentication in the absence of TLS.
Oh, surely not. I have been assured from several parties that they want to use authentication, so who am I to argue with them :-) And anyway, motivation was to have a working implementation before HW vendors have a chance to mess things up :-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
We could rename it to nvmeof-auth, though.
or just add it as more tests under nvme (or create a subdirectory).
Quoted 8 lines
Quoted 4 lines
Sure we can. I just found it easier to create my own directory, especially seeing that the nvme subdir has the largest number of tests already.
But if you prefer I can move it under the 'nvme' directory.I think that it would definitely be an improvement, also because people usually run the nvme directory tests which is nice and simple, we should strive to keep it this way.
Okay, will be doing so.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Hannes Reinecke
maintainerPATCH 2/6 nvmeof-tcp/002: create an authenticated nvmeof-tcp connection
In reply to Hannes Reinecke--- tests/nvmeof-tcp/002 | 62 ++++++++++++++++++++++++++++++++++++++++ tests/nvmeof-tcp/002.out | 6 ++++ 2 files changed, 68 insertions(+) create mode 100644 tests/nvmeof-tcp/002 create mode 100644 tests/nvmeof-tcp/002.out
tests/nvmeof-tcp/002 new file +62 -0
@@ -0,0 +1,62 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp authentication + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Create 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" + + _remove_nvmet_subsystem_from_port "${port}" "${subsys}1" + _remove_nvmet_subsystem "${subsys}1" + + _remove_nvmet_port "${port}" + + rm ${scratch} + + echo "Test complete" +}
tests/nvmeof-tcp/002.out new file +6 -0
@@ -0,0 +1,6 @@ +Running nvmeof-tcp/002 +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
Signature · 1 line
2.26.2
Hannes Reinecke
maintainerPATCH 3/6 nvmeof-tcp/003: test different key types
In reply to Hannes Reinecke--- 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
tests/nvmeof-tcp/003 new file +100 -0
@@ -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" +}
tests/nvmeof-tcp/003.out new file +36 -0
@@ -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
Signature · 1 line
2.26.2
Hannes Reinecke
maintainerPATCH 4/6 nvmeof-tcp/004: test hash and dhgroup variations
In reply to Hannes Reinecke--- tests/nvmeof-tcp/004 | 86 ++++++++++++++++++++++++++++++++++++++++ tests/nvmeof-tcp/004.out | 37 +++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 tests/nvmeof-tcp/004 create mode 100644 tests/nvmeof-tcp/004.out
tests/nvmeof-tcp/004 new file +86 -0
@@ -0,0 +1,86 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp hash and dh group selection + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Test hash and DH group 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}" + + for hash in "hmac(sha384)" "hmac(sha512)" ; do + + echo "Testing hash ${hash}" + + _set_nvmet_hash "${hostnqn}" "${hash}" + + 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 dhgroup in "ffdhe2048" "ffdhe3072" "ffdhe4096" "ffdhe6144" "ffdhe8192" ; do + + echo "Testing DH group ${dhgroup}" + + _set_nvmet_dhgroup "${hostnqn}" "${dhgroup}" + + 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" +}
tests/nvmeof-tcp/004.out new file +37 -0
@@ -0,0 +1,37 @@ +Running nvmeof-tcp/004 +Testing hash hmac(sha384) +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 hash hmac(sha512) +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 DH group ffdhe2048 +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 DH group ffdhe3072 +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 DH group ffdhe4096 +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 DH group ffdhe6144 +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 DH group ffdhe8192 +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
Signature · 1 line
2.26.2
Hannes Reinecke
maintainerPATCH 5/6 nvmeof-tcp/005: test bi-directional authentication
In reply to Hannes Reinecke--- tests/nvmeof-tcp/005 | 74 ++++++++++++++++++++++++++++++++++++++++ tests/nvmeof-tcp/005.out | 6 ++++ 2 files changed, 80 insertions(+) create mode 100644 tests/nvmeof-tcp/005 create mode 100644 tests/nvmeof-tcp/005.out
tests/nvmeof-tcp/005 new file +74 -0
@@ -0,0 +1,74 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp bi-directional authentication + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Test bi-directional authentication for 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 + + ctrlkey="$(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}" + + _set_nvmet_dhgroup "${hostnqn}" "ffdhe2048" + _set_nvmet_ctrlkey "${hostnqn}" "${ctrlkey}" + + nvme connect -t "${nvme_trtype}" -n "${subsys}1" \ + -a "${def_traddr}" -s "${def_trsvcid}" \ + -S "${hostkey}" -C "${ctrlkey}" \ + --hostnqn="${hostnqn}" --hostid="${hostid}" + + nvme list-subsys + + nvme disconnect -n "${subsys}1" + + _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" +}
tests/nvmeof-tcp/005.out new file +6 -0
@@ -0,0 +1,6 @@ +Running nvmeof-tcp/005 +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
Signature · 1 line
2.26.2
Sagi Grimberg
maintainerRe: [PATCH 5/6] nvmeof-tcp/005: test bi-directional authentication
Hannes,
Should we add negative test cases for each of these tests? Currently for some reason I'm able to connect even though I provide the host a different dhchap_ctrl_key.
Controller:
--
# grep -r '' /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4 /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_dhgroup:null /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_hash:hmac(sha512) /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_ctrl_key:DHHC-1:03:M4ik+B5zPy9vqzH0Ef9sLWXLL7HQ1JEqx0IkhMWwNPc0tq8ZLkTQstMl1A9wkMFzzo52hJwQ0wP9GELWmUwUgFisuGw=: /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_key:DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=: --
Host (use same key for -S and -C):
--
# ./nvme connect -t tcp -a 192.168.123.1 -n testnqn1 -s 8009 -S "DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=:" -C "DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=:"
# nvme list
Node SN Model
Namespace Usage Format FW Rev
--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 c7ebe13b94f6ad3885c7 Linux
1 268.44 GB / 268.44 GB 512 B + 0 B 5.15.0-r
--Am I doing something wrong?
Hannes Reinecke
maintainerRe: [PATCH 5/6] nvmeof-tcp/005: test bi-directional authentication
Quoted 39 lines · Sagi Grimberg
Hannes,
Should we add negative test cases for each of these tests? Currently for some reason I'm able to connect even though I provide the host a different
dhchap_ctrl_key.Controller:
Signature · 31 lines
# grep -r '' /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4 /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_dhgroup:null /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_hash:hmac(sha512) /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_ctrl_key:DHHC-1:03:M4ik+B5zPy9vqzH0Ef9sLWXLL7HQ1JEqx0IkhMWwNPc0tq8ZLkTQstMl1A9wkMFzzo52hJwQ0wP9GELWmUwUgFisuGw=: /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_key:DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=: -- Host (use same key for -S and -C): -- # ./nvme connect -t tcp -a 192.168.123.1 -n testnqn1 -s 8009 -S "DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=:" -C "DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=:" # nvme list Node SN Model Namespace Usage Format FW Rev --------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- -------- /dev/nvme0n1 c7ebe13b94f6ad3885c7 Linux 1 268.44 GB / 268.44 GB 512 B + 0 B 5.15.0-r -- Am I doing something wrong?
Hmm. Not that I can see.
I'll be checking what's going on here.
And yes, some negative tests won't go amiss.
I'll be adding them; or, rather, update the current ones to test with mismatched credentials, too.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Hannes Reinecke
maintainerRe: [PATCH 5/6] nvmeof-tcp/005: test bi-directional authentication
In reply to Sagi GrimbergQuoted 40 lines · Sagi Grimberg
Hannes,
Should we add negative test cases for each of these tests? Currently for some reason I'm able to connect even though I provide the host a different
dhchap_ctrl_key.Controller:
Signature · 31 lines
# grep -r '' /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4 /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_dhgroup:null /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_hash:hmac(sha512) /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_ctrl_key:DHHC-1:03:M4ik+B5zPy9vqzH0Ef9sLWXLL7HQ1JEqx0IkhMWwNPc0tq8ZLkTQstMl1A9wkMFzzo52hJwQ0wP9GELWmUwUgFisuGw=: /sys/kernel/config/nvmet/hosts/nqn.2014-08.org.nvmexpress:uuid:b73ff014-2723-4114-aa8d-2f784ecba4f4/dhchap_key:DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=: -- Host (use same key for -S and -C): -- # ./nvme connect -t tcp -a 192.168.123.1 -n testnqn1 -s 8009 -S "DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=:" -C "DHHC-1:03:ynOWXFT8AC/OlvuIkpQ1RQlDAuHz2axeP43zmws90yRhPHNP5HyDQSI3m+WCBKcUfl7gRraflcb7nHAHR5mTh9t22Js=:" # nvme list Node SN Model Namespace Usage Format FW Rev --------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- -------- /dev/nvme0n1 c7ebe13b94f6ad3885c7 Linux 1 268.44 GB / 268.44 GB 512 B + 0 B 5.15.0-r -- Am I doing something wrong?
D'oh. Fix is:
drivers/nvme/host/auth.c +1 -1
@@ -1351,7 +1351,7 @@ static void __nvme_auth_work(struct work_struct *work) } ret =nvme_auth_process_dhchap_success1 (ctrl, chap); -if (ret <0 ) { +if (ret) {/* Controller authentication failed */ goto fail2; }
I'll fold it into the next version.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), GF: Felix Imendörffer
Hannes Reinecke
maintainerPATCH 6/6 nvmeof-tcp/006: test re-authentication
In reply to Hannes Reinecke--- tests/nvmeof-tcp/006 | 113 +++++++++++++++++++++++++++++++++++++++ tests/nvmeof-tcp/006.out | 23 ++++++++ 2 files changed, 136 insertions(+) create mode 100644 tests/nvmeof-tcp/006 create mode 100644 tests/nvmeof-tcp/006.out
tests/nvmeof-tcp/006 new file +113 -0
@@ -0,0 +1,113 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2021 Hannes Reinecke, SUSE Labs +# +# Test nvme over tcp re-authentication + +. tests/nvmeof-tcp/rc + +DESCRIPTION="Test re-authentication for 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 + + ctrlkey="$(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}" + + _set_nvmet_dhgroup "${hostnqn}" "ffdhe2048" + _set_nvmet_ctrlkey "${hostnqn}" "${ctrlkey}" + + nvme connect -t "${nvme_trtype}" -n "${subsys}1" \ + -a "${def_traddr}" -s "${def_trsvcid}" \ + -S "${hostkey}" -C "${ctrlkey}" \ + --hostnqn="${hostnqn}" --hostid="${hostid}" + + nvme list-subsys + + ctrl=$(_find_nvme_dev "${subsys}1") + + echo "Re-authenticate with original host key" + + echo "${hostkey}" > /sys/class/nvme/${ctrl}/dhchap_secret + + echo "Renew host key on the controller" + + new_hostkey="$(nvme gen-dhchap-key -n ${subsys}1 2> /dev/null)" + + _set_nvmet_hostkey "${hostnqn}" "${new_hostkey}" + + echo "Re-authenticate with new host key" + + echo "${new_hostkey}" > /sys/class/nvme/${ctrl}/dhchap_secret + + nvme list-subsys + + echo "Renew ctrl key on the controller" + + new_ctrlkey="$(nvme gen-dhchap-key -n ${subsys}1 2> /dev/null)" + + _set_nvmet_ctrlkey "${hostnqn}" "${new_ctrlkey}" + + echo "Re-authenticate with new ctrl key" + + echo "${new_ctrlkey}" > /sys/class/nvme/${ctrl}/dhchap_ctrl_secret + + nvme list-subsys + + echo "Change DH group to ffdhe8192" + + _nvmet_set_dhgroup "${subsys}1" "ffdhe8192" + + echo "Re-authenticate with changed DH group" + echo "${new_hostkey}" > /sys/class/nvme/${ctrl}/dhchap_secret + + nvme list-subsys + + nvme disconnect -n "${subsys}1" + + _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" +}
tests/nvmeof-tcp/006.out new file +23 -0
@@ -0,0 +1,23 @@ +Running nvmeof-tcp/006 +nvme-subsys0 - NQN=blktests-subsystem-1 +\ + +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live +Re-authenticate with original host key +Renew host key on the controller +Re-authenticate with new host key +nvme-subsys0 - NQN=blktests-subsystem-1 +\ + +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live +Renew ctrl key on the controller +Re-authenticate with new ctrl key +nvme-subsys0 - NQN=blktests-subsystem-1 +\ + +- nvme0 tcp traddr=127.0.0.1,trsvcid=4420 live +Change DH group to ffdhe8192 +tests/nvmeof-tcp/006: line 94: _nvmet_set_dhgroup: command not found +Re-authenticate with changed DH group +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
Signature · 1 line
2.26.2