1#!/usr/bin/env bash 2# SPDX-License-Identifier: BSD-3-Clause 3# Copyright (C) 2021 Intel Corporation 4# All rights reserved. 5# 6testdir=$(readlink -f $(dirname $0)) 7rootdir=$(readlink -f $testdir/../../..) 8rpc_py=$rootdir/scripts/rpc.py 9 10source $rootdir/test/common/autotest_common.sh 11source $rootdir/test/nvmf/common.sh 12 13null_bdev_size=1024 14null_block_size=512 15null_bdev=null0 16nvme_bdev=nvme0 17 18# Since we're connecting the same bdev, we need to use a different NGUID to avoid errors when 19# registering the bdev during bdev_nvme_attach_controller 20nguid=$(uuidgen | tr -d '-') 21 22nvmftestinit 23nvmfappstart -m 0x1 24 25# First create a null bdev and expose it over NVMeoF 26$rpc_py nvmf_create_transport $NVMF_TRANSPORT_OPTS 27$rpc_py bdev_null_create $null_bdev $null_bdev_size $null_block_size 28$rpc_py bdev_wait_for_examine 29$rpc_py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode0 -a 30$rpc_py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode0 $null_bdev -g $nguid 31$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode0 -t $TEST_TRANSPORT \ 32 -a $NVMF_FIRST_TARGET_IP -s $NVMF_PORT 33 34# Then attach NVMe bdev by connecting back to itself, with the target app running on a single core. 35# This verifies that the initialization is completely asynchronous, as each blocking call would 36# stall the application. 37$rpc_py bdev_nvme_attach_controller -b $nvme_bdev -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \ 38 -f ipv4 -s $NVMF_PORT -n nqn.2016-06.io.spdk:cnode0 39 40# Make sure the bdev was created successfully 41$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 42 43# Make sure the reset is also asynchronous 44$rpc_py bdev_nvme_reset_controller $nvme_bdev 45 46# And that the bdev is still available after a reset 47$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 48 49# Finally, detach the controller to verify the detach path 50$rpc_py bdev_nvme_detach_controller $nvme_bdev 51 52# Add new listener with TLS using PSK 53key_path=$(mktemp) 54echo -n "NVMeTLSkey-1:01:MDAxMTIyMzM0NDU1NjY3Nzg4OTlhYWJiY2NkZGVlZmZwJEiQ:" > $key_path 55chmod 0600 $key_path 56$rpc_py keyring_file_add_key key0 "$key_path" 57$rpc_py nvmf_subsystem_allow_any_host nqn.2016-06.io.spdk:cnode0 --disable 58$rpc_py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode0 -t $TEST_TRANSPORT \ 59 -a $NVMF_FIRST_TARGET_IP -s $NVMF_SECOND_PORT --secure-channel 60$rpc_py nvmf_subsystem_add_host nqn.2016-06.io.spdk:cnode0 nqn.2016-06.io.spdk:host1 \ 61 --psk key0 62 63# Then attach NVMe bdev by connecting back to itself, with the target app running on a single core. 64# This verifies that the initialization is completely asynchronous, as each blocking call would 65# stall the application. 66$rpc_py bdev_nvme_attach_controller -b $nvme_bdev -t $TEST_TRANSPORT -a $NVMF_FIRST_TARGET_IP \ 67 -f ipv4 -s $NVMF_SECOND_PORT -n nqn.2016-06.io.spdk:cnode0 -q nqn.2016-06.io.spdk:host1 --psk $key_path 68 69# Make sure the bdev was created successfully 70$rpc_py bdev_get_bdevs -b ${nvme_bdev}n1 71 72# Finally, detach the controller to verify the detach path 73$rpc_py bdev_nvme_detach_controller $nvme_bdev 74 75# cleanup 76rm -f $key_path 77 78trap - SIGINT SIGTERM EXIT 79nvmftestfini 80